Assuming we are integrating with AWS Cognito
- User signs up successfully
- Client calls the post endpoint (sending the jwt returned from cognito in headers)
- Backend reads JWT, extracts sub (this is the user id), insert into DB
No request body
No response body: 201 CREATED
This endpoint will be called when user goes to Discover Tab. Frontend to store the state in a global store (RiverPod). Food details are returned together in the same endpoint. No additional endpoint to get food details
- Query params: budget, cuisine
- budget - Accepts a string
- cuisine - Accepts a list of strings
- dietary -
sample response body: 200 OK
[
{
id: f9116a0d-f96e-4d92-96af-deb139fbb99d
name: "Pho Bo"
price: 12.99
restaurantName: "Saigon Noodle"
rating: 4.7
cuisine: Vietnamese
description: "Traditional Vietnamese beef noodle soup with a rich, aromatic broth simmered for 12 hours."
imageKey:
}
]
This endpoint will be called each time the user swipes left or right.
- If user swipes right (like), send post request with status=true
- if user swipes left (dislike), send post request with status=false
food preference logic (user_food_preference)
- if user has no records in user_food_preference, insert new records in user_food_preference
- if there are existing records in user_food_preference, update the status
sample request body
{
"userId": "11111111-1111-1111-1111-111111111111",
"foodId": "f9116a0d-f96e-4d92-96af-deb139fbb99d",
"status": true
}
No response body: 204 NO CONTENT
This endpoint will be called when user goes to the Favourites Tab
food preference logic (user_food_preference)
- find by userId where status=true
sample response body: 200 OK
[
{
id: f9116a0d-f96e-4d92-96af-deb139fbb99d
name: "Pho Bo"
price: 12.99
restaurantName: "Saigon Noodle"
rating: 4.7
cuisine: Vietnamese
description: "Traditional Vietnamese beef noodle soup with a rich, aromatic broth simmered for 12 hours."
imageKey:
}
]
This endpoint will be called when user goes to Profile Tab
User profile logic (users)
- find by userId
- retrieves name, city
Food preference logic (user_food_preference)
- find by userId
- retrieves count where status=true
Cuisine preference logic (user_cuisine_preference)
- find by userId
- join with cuisine table
- retrieves cuisine name
Budget preference logic (user_budget_preference)
- find by userId
- retrieves budget
No request body response body: 200 OK
{
name: "Alice Tan"
budget: "High"
city: "Singapore"
favouritesCount: 8
cuisine: ["Chinese","Western"]
}
This endpoint will be called at the end when the user clicks continue at What’s your budget screen). Form values to be managed at the frontend
Cuisine preference logic (user_cuisine_preference)
- Frontend: If user did not select any cuisine, default to all cuisines
- If the user has no records in user_cuisine_preference, insert new records into user_cuisine_preference for each cuisine selected by the user.
- If the user already has records in user_cuisine_preference, delete all existing records for that user from user_cuisine_preference then insert new records for only the cuisines included in the request
Budget preference logic (user_budget_preference)
- If the user has no record in user_budget_preference, insert a new record into user_budget_preference with the selected budget.
- If the user already has a record in user_budget_preference, update the existing record in user_budget_preference to the newly selected budget.
Dietary preference logic (KIV)
sample request body
{
"cuisines": ["chinese", "thai"],
"budget": "mid"
}
sample response body
{
"userId": "42c9f0c1-8c44-4f0d-bd7f-7d5b62aaf231",
"cuisines": ["chinese", "thai"],
"budget": "mid",
"updatedAt": "2026-02-08T15:42:11Z"
}
Local Machine
↓
localhost:5432
↓
SSM Port Forwarding
↓
Bastion EC2 (inside VPC)
↓
RDS (private)
brew install awscli
aws --version
brew install session-manager-plugin
session-manager-plugin
aws configure
AWS Access Key ID: <aws-access-key>
AWS Secret Access Key: <aws-secret-key>
Default region: ap-southeast-1
Default output format: json
aws sts get-caller-identity
"Arn": "arn:aws:iam::<account-id>:user/SWE5006"
Keep this terminal open. It maintains the tunnel.
aws ssm start-session \
--target i-0da472ade527adada \
--document-name AWS-StartPortForwardingSessionToRemoteHost \
--parameters '{"host":["swe5006-nus-g3-pg-dev.clee6i664xzo.ap-southeast-1.rds.amazonaws.com"],"portNumber":["5432"],"localPortNumber":["5432"]}'
Starting session with SessionId: ...
Port 5432 opened...
To access the database
- install pgAdmin
- hostname: localhost
- port: 5432
- username: nusissuser
- password: v9710KYF54Kkv7vv4sVxy
- schema: appdb
- Table: users
CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY,
name VARCHAR(255) NOT NULL,
city VARCHAR(255) NOT NULL
);
- Table: food
CREATE TABLE IF NOT EXISTS food (
id UUID PRIMARY KEY,
name VARCHAR(255) NOT NULL,
price NUMERIC NOT NULL,
restaurant_name VARCHAR(255) NOT NULL,
rating NUMERIC,
cuisine VARCHAR(255) NOT NULL,
description TEXT,
image_key VARCHAR(255),
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP
);
- Table: user_food_preference
CREATE TABLE IF NOT EXISTS user_food_preference (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
food_id UUID NOT NULL,
status BOOLEAN NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP,
CONSTRAINT fk_ufp_user FOREIGN KEY (user_id) REFERENCES users(id),
CONSTRAINT fk_ufp_food FOREIGN KEY (food_id) REFERENCES food(id),
CONSTRAINT uq_user_food UNIQUE (user_id, food_id)
);
- Table: cuisine
CREATE TABLE IF NOT EXISTS cuisine (
id UUID PRIMARY KEY,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL
);
- Table: user_cuisine_preference
CREATE TABLE IF NOT EXISTS user_cuisine_preference (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
cuisine_id UUID NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP,
CONSTRAINT fk_ucp_user FOREIGN KEY (user_id) REFERENCES users(id),
CONSTRAINT fk_ucp_cuisine FOREIGN KEY (cuisine_id) REFERENCES cuisine(id),
CONSTRAINT uq_user_cuisine UNIQUE (user_id, cuisine_id)
);
- Table: user_budget_preference
CREATE TABLE IF NOT EXISTS user_budget_preference (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
budget VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP,
CONSTRAINT fk_ubp_user FOREIGN KEY (user_id) REFERENCES users(id),
);