- Setup .env variables by running python script.
python3 generate_env.py
- Fill in environment variables missing fields (Password etc.)
- Download Docker/Docker Engine via online platform.
- In the root directory run in terminal,
docker compose up -d --build
- Rerun the above command each time you make edits so that docker can update images.
- By default mysql on port 3306, nodejs default 3000 (changable in .env). [remember to turn off external services or change assignment in .env, if not port conflict will occur]
- On server start, the app attempts to sync HDB resale data from Data.gov.sg and stores it in MySQL table
gov_house_transactions. - You can trigger the sync on-demand and query it via HTTP endpoints.
- Required for MySQL init (Compose reads these):
MYSQL_ROOT_PASSWORDMYSQL_DATABASE=rentwiseDBMYSQL_USER=rentuserMYSQL_PASSWORD=<your password>
- Node container DB config (already mapped to MySQL above):
DB_HOST=rentwiseDBDB_PORT=3306DB_USER=${MYSQL_USER}DB_PASSWORD=${MYSQL_PASSWORD}DB_NAME=${MYSQL_DATABASE}
- Ports:
HOST_DB_PORT=8000(MySQL exposed on your host)NODEJS_PORT=3000andPORT=3000
- Optional:
DATA_GOV_SG_API_KEY=<if you have one>
docker compose up -d --build
docker compose logs -f nodejs
Wait until you see: Server listening on port 3000.
- POST
http://localhost:3000/api/apimanagement/gov/sync - No headers/body required.
- The app paginates the DataStore API, uses backoff for 429s, and batches DB writes.
- GET
http://localhost:3000/api/search/gov/count→{ "count": N } - GET
http://localhost:3000/api/search/gov/sample?limit=5
- GET
http://localhost:3000/api/search/gov/search- Query params:
town,flatType,minPrice,maxPrice,minAreaSqm,maxAreaSqm,limit,offset - Example:
/api/search/gov/search?town=TAMPINES&flatType=4%20ROOM&minPrice=400000&maxPrice=700000&limit=20&offset=0
- Query params:
- Postman can’t connect (ECONNREFUSED):
- Ensure container exposes
3000:3000and logs showServer listening on port 3000.
- Ensure container exposes
- DB access denied for
rentuser:- Ensure
.envhas matchingMYSQL_*, and container initialized with those values. - If needed, inside MySQL run:
GRANT ALL ON rentwiseDB.* TO 'rentuser'@'%' IDENTIFIED BY '<password>'; FLUSH PRIVILEGES;
- Ensure
- Count is 0:
- Trigger sync (POST
/api/apimanagement/gov/sync). If logs show429 Too Many Requests, wait ~60s and re-run; it resumes paging.
- Trigger sync (POST
- “Prepared statement contains too many placeholders” / “Malformed communication packet” during sync:
- The app already handles batching and falls back to per-row upserts. Re-run sync.
mysql -h 127.0.0.1 -P 8000 -u rentuser -p
USE rentwiseDB;
SHOW TABLES;
SELECT COUNT(*) FROM gov_house_transactions;