PropertyIQ is a web application that organises and makes accessible relevant market data and is the the go-to source for up-to-date information and trends in the Singapore housing rental market.
Prerequsite software/hardware
- Operating System: Windows 10/11, macOS Catalina above
- Visual Studio Code
- Pgadmin 4 (Graphical User Interface to interact with the database)
- PostgreSQL 15
- https://www.postgresql.org/download/ (Windows)
- https://postgresapp.com/ (Mac)
- Python 3.9 above
Prerequsite API Keys Required
- URA API
- https://www.ura.gov.sg/maps/api/#introduction
a. Register for an account. Fill in NA for Company Name, and put in arbitrary URL (e.g. https://www.google.com)
b. Go to your email and open the confirmation email titled 'URA Data Request - Approved'.
c. Click on the link and the button to generate access key.
d. Go back to your email and open the email titled 'URA Data Request - Access key'.
e. You should see your URA API key there which is required for PropertyIQ. Do not lose this key!
- https://www.ura.gov.sg/maps/api/#introduction
- Google Maps API
- https://www.youtube.com/watch?v=OGTG1l7yin4 (Step-by-step tutorial on how to acquire API Key)
a. Go to https://console.cloud.google.com.
b. Create a new Project. Name it however you want.
c. Open the sidebar, click API & Services, then click on Library.
d. Search for or click on Maps Javascript API.
e. Enable it.
f. Open the sidebar again, click API & Services, then click on Credentials.
g. Click on Create Credentials, then click on API Key.
h. And you're done, that's the API key required for our Google Maps Services for PropertyIQ. Do not lose this key!
- https://www.youtube.com/watch?v=OGTG1l7yin4 (Step-by-step tutorial on how to acquire API Key)
Prerequsite (Others)
- Gmail App Password
- https://myaccount.google.com/
a. Search for App Password on the search bar (Assumed that you have a valid gmail account.)
b. Select the option App Passwords with the subscript security.
c. If this option does not appear, ensure that you have set up your 2FA prior to this. Gmail only supports this if 2FA has been implemented.
d. Else, select App as mail.
e. Select device as either Mac/Windows Computer depending on the OS you are using.
f. And you're done, that's the Gmail App Password required to send emails to users whenever PropertyIQ has any new listings. Do not lose this password!
- https://myaccount.google.com/
- Clone this project
Setup
Please follow carefully during the setup process.
The following was done using a window 11 system, macOS should be relatively similar. Your mileage may vary.
- Create a Python virtual environment in VS Code.
- Start the virtual environment.
- Install dependencies.
https://code.visualstudio.com/docs/python/environments#_using-the-create-environment-command
Opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment
Creating an environment using Venv
Select interpreter path i.e. python
Checked to also install dependencies
Note: You can also manually install dependencies using the following command in the terminal.
pip install -r requirements.txt
For Mac Users:
1. If you face any error installing the library psycopg2, please delete the line 'psycopg2==2.9.5' from the requirements.txt.
2. Only install psycopg2-binary==2.9.5 by running 'pip install psycopg2-binary==2.9.5' in the terminal.
3. That should solve any errors you face.
- Setup of PostgreSQL and database
Download and install both pgAdmin and PostgreSQL.
Install Postgres without changing anything, except entering of master password.
Open the SQL shell by entering psql
in your Windows search menu.
Inside SQL shell, keep pressing enter until it prompts you for your password which you created during the installation. Type your password here even though it doesn't look like it is being keyed in. Press enter once done.
It should look like this. Note: If you receive a warning on console code page, you can safety ignore.
Follow the below commands in the PSQL shell:
To create the database of propertyiq
To list the databases
postgres=# CREATE DATABASE propertyIQ OWNER postgres;
postgres=# \l
It should look like this.
- Create a .env file in the root directory & store relevant information. Ensure that the names match exactly. e.g. 'POSTGRE_USER' must be stored exactly as POSTGRE_USER in the .env file without any typos. Also, the <> signs are not required. There are there only for illustrative purposes. e.g. POSTGRE_USER = 'postgres' is correct without the <> signs at the ends. Note: The default POSTGRE_USER if not set above is automatically 'postgres'.
POSTGRE_USER = '<YOUR POSTGRESQL USER>'
POSTGRE_PASSWORD = '<YOUR POSTGRESQL PASSWORD>'
- Get URA API Key from URA Website & Add it to the .env file.
URA_API_KEY = '<YOUR URA API KEY>'
- Get Google Maps API Key & Add it to the .env file.
GOOGLE_MAPS_KEY = '<YOUR GOOGLE MAPS KEY>'
- Get Gmail App Password & add it to the .env file.
GMAIL_EMAIL = '<YOUR EMAIL>'
GMAIL_APP_PASSWORD = '<ENTER 16 DIGIT CODE HERE>'
The final .env file should look like this:
Create superuser
python manage.py createsuperuser
Example Super User Account:
Username: propertyIQ
Email: <Your valid gmail email which should be the same as the Gmail Email you used to get the Gmail App Password>
Password: sc2006_1234
Note: It is normal if you can't see the password appearing on the screen even when you are typing something. This is for security reasons!
Setting up and running the server
python manage.py migrate
python manage.py runserver
Note: During migrations, you should see all green for the migrations!
First-time setup
Within the website, head over to the login page and login as the superuser. Head to the dashboard and click update property list.
NOTE: THIS WILL TAKE A WHILE ~2-3MIN ON A FAST INTERNET CONNECTION and also depends on the number of users currently registered since it needs to send emails to each and every user everytime there is a new update for new properties.
Every registered user will receive an email like this by the website's superuser whenever the properties are updated:
After this, you should see some listings on the home page and the 'featured listings page'.
pgAdmin
The purpose of installing pgAdmin is to view the data stored in the database using a graphical interface which is much more user-friendly. Note that pgAdmin is more for developers who want to implement some changes or see how the data is being stored. For the front-end users, pgAdmin may not be necessary.
In pgAdmin , enter the same password from PostgreSQL and you should then see the following. Click on server database icon top left and add the password which you entered in psql.
Then, click on 'Databases' and choose the database to examine. It should be 'propertyiq' if your setup process has been the same as proposed above.
Then, click on 'Tables'. Thereafter, choose the table you want to examine.
For example, if you want to examine the property tables, simply right click 'property_property' and click 'View/Edit Data' and select 'All Rows'.
This will display all of the property listing in the database to you as shown below:
-
Search Bar: Users can search for their desired properties using keywords or using the multiple filters the website offers.
-
Bookmarks: Users can bookmark properties and remove their bookmarks. Users can also view their bookmarked properties on the dashboard.
-
Recommendations: PropertyIQ provides recommendations to the users based on proximity to the selected location and rent price.
-
Trends: PropertyIQ provides historical trends of the particular project of the selected property as well as nearby trends of properties near the selected property.
-
Maps: PropertyIQ integrates Google Maps to show the location of the selected property and the recommended properties.
-
Locked Out: PropertyIQ will lock the user out for an hour if the user repeatedly fails to log in after 3 tries.
-
Recently Viewed Properties: PropertyIQ will store whatever you have viewed before for you in case you forget whatever you have viewed before.
1. How do I start the production server?
Run python manage.py runserver in the console.
2. How do I create a super user?
Run this in the console and follow the instructions. Type your password even though it doesn't look like it is being keyed in. Press enter once done.
python manage.py createsuperuser
3. How do I delete the properties in VS code?
python manage.py shell
from property.models import Property
Property.objects.all().delete()
4. How do I delete the database? I can't do it from the Pgadmin GUI.
Open the SQL shell by entering psql
in your Windows search menu.
Inside SQL shell, keep pressing enter until it prompts you for your password which you created during the installation. Type your password here even though it doesn't look like it is being keyed in. Press enter once done.
It should look like...
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
postgres=#
RUN THESE COMMANDS and replace the database name i.e.propertyiq
appropriately to your own database name. This should work.
update pg_database set datallowconn = 'false' where datname = 'propertyiq';
select pg_terminate_backend(pg_stat_activity.pid) from pg_stat_activity where pg_stat_activity.datname = 'propertyiq';
drop database propertyiq;
Note: Should you need to uninstall/re-install you will need to manually delete the folder where you have installed Postgres and pgadmin. This is even after uninstalling from system settings. For some reason, Postgres folder's don't remove entirely even though you select the option.
5. I don't see any properties after I set everything up. Why is that so?
1. Create a super user by typing python manage.py createsuperuser in the console.
2. Login on the web page with that super user account.
3. Go to the Dashboard.
4. Press Update Listings Button.
5. Wait for about 1-2 minutes patiently and grab a cup of coffee.
6. I'm facing errors installing psycopg2 in the initial set up!! I'm a Mac User.
1. If you face any error installing the library psycopg2, please delete the line 'psycopg2==2.9.5' from the requirements.txt.
2. Only install psycopg2-binary==2.9.5.
3. That should solve any errors you face.