HKUgram is a COMP3278 course project built for Scenario 2, a social media application backed by a relational database. The system lets users register accounts, publish image posts, browse a feed, like and comment on posts, follow creators, review browsing history, and explore basic analytics such as popular posts and active users.
The project is designed to satisfy the course requirements across database design, query capability, UI, and deployment. It uses FastAPI and SQLAlchemy on the backend, MySQL as the core relational database, and React + Vite on the frontend with an Art Deco visual direction. In addition to the social feed workflow, HKUgram includes a read-only SQL and Text-to-SQL query feature for demoing database access and visualization on top of the same dataset.
- Frontend:
http://127.0.0.1:5173 - Backend API:
http://127.0.0.1:8000 - MySQL:
127.0.0.1:3307 - Database visualizer (Adminer):
http://127.0.0.1:8080
Adminer login values:
- System:
MySQL - Server:
dbwhen using Docker Compose network, orhost.docker.internalif needed from another container setup - Username:
hkugram - Password:
hkugram - Database:
hkugram
- From the repository root, run
docker compose up --build. - Open
http://127.0.0.1:5173for the frontend. - Backend API is available at
http://127.0.0.1:8000. - MySQL is exposed on
127.0.0.1:3306.
This project publishes two separate container images instead of one combined image.
- Backend image:
ghcr.io/bylinmou/hkugram-backend:latestRuns the FastAPI application and backend bootstrap logic. - Frontend image:
ghcr.io/bylinmou/hkugram-frontend:latestServes the built Vite frontend with Nginx.
The images are separated on purpose:
- backend and frontend use different runtimes
- they can be rebuilt and redeployed independently
- CI/CD is simpler
- production deployments are easier to scale and maintain
This is the current development setup in this repository.
- Clone the repository.
- From the repository root, run:
docker compose up --build- Open:
- Frontend:
http://127.0.0.1:5173 - Backend API:
http://127.0.0.1:8000 - MySQL:
127.0.0.1:3306
This mode is for development because:
- backend is built locally from
backend/Dockerfile - frontend runs the Vite dev server instead of the production frontend image
Use this when deploying on a Linux server with prebuilt images. You do not need to clone the full repository on the server.
- Install Docker Engine and Docker Compose plugin on the server.
- Create a deployment directory, for example
/opt/hkugram. - Copy these files into that directory:
docker-compose.prod.yml.env.example
- Create
.envfrom the example file:
cd /opt/hkugram
cp .env.example .env- Edit
.envand fill in the real values you need. At minimum, check:
AI_API_KEYAI_BASE_URLAI_MODELAI_TIMEOUT_SECONDSCORS_ORIGINS
- Start the production stack:
cd /opt/hkugram
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d --remove-orphans
docker compose -f docker-compose.prod.yml ps- Open the deployed services:
- Frontend:
http://<server-ip>/ - Backend API:
http://<server-ip>:8000 - Adminer:
http://<server-ip>:8070
For later updates, replace docker-compose.prod.yml if needed, update .env if needed, then run the same Docker Compose command block again.
You can also run the images without Compose, but Compose is the simpler option because this project also needs MySQL.
In practice, the recommended deployment path for this repo is:
- MySQL container
- backend image
- frontend image
- The backend image expects a working MySQL database through
DATABASE_URL. - The backend runs bootstrap on startup, so schema creation and seed logic happen there.
- The frontend image is static and does not contain the backend.
- Because the frontend and backend are separate images, redeploying the UI does not require rebuilding the API image.
-
.github/workflows/ci.ymlRuns backend compile checks and frontend production build on push and pull request. -
.github/workflows/release.ymlReads the project version fromVERSION, creates av<version>Git tag and GitHub Release when that tag does not already exist, then builds and publishes backend/frontend Docker images to GHCR:ghcr.io/<owner>/hkugram-backend:<version>ghcr.io/<owner>/hkugram-frontend:<version>The workflow can run on every push tomain, but it only publishes a new release when the currentVERSIONdoes not already have a matching git tag.
-
.github/workflows/deploy.ymlDeploys the Docker Compose stack to the remote server over SSH. Configure the required repository or environment secrets before use, includingDEPLOY_HOST,DEPLOY_USER,DEPLOY_SSH_PRIVATE_KEY, andDEPLOY_PROJECT_PATH.
Use .env.example as the template for the server-side .env file.