This project consists of:
- Frontend: Flutter web application
- Backend: FastAPI Python application
- Database: PostgreSQL
- Backend API and Database Setup
- README.md Documentation for Migration
- README.md Documentation for Testing
- Python 3.8+
- PostgreSQL database
First, set up a Python virtual environment to isolate project dependencies:
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activateYou should see (venv) in your terminal prompt when the environment is active.
With your virtual environment activated:
cd App
pip install -r requirements.txtor alternatively, from the root directory:
pip install -r App/requirements.txtReturn to main directory by running cd ..
Create a .env file based on the template in .env.example.
cp .env.example .envFor security, actual credentials shall be sent separately. After entering the credentials into the created .env file, save the document.
Connecting to Dockerized PostgreSQL
Database Details: Available upon request.
Refer to the link to download Docker Desktop: https://docs.docker.com/desktop/
After downloading Docker Desktop, open Docker Desktop on your device. Then, use the appropriate command for your system:
## Mac / Windows (Docker Desktop)
docker compose -f Infrastructure/docker-compose.yml up -d --build
## Linux (some distributions still use the old binary)
docker-compose -f Infrastructure/docker-compose.yml up -d --buildor alternatively, you can first move into the Infrastructure directory:
# Make sure you are in the main directory, if not, run `cd` ...
cd InfrastructureThen, use the appropriate command for your system:
## Mac / Windows (Docker Desktop)
docker compose up -d
## Linux (some distributions still use the old binary)
docker-compose up -d- Open pgAdmin using either Docker Desktop or your local installation.
- If using Docker Desktop:
- a. Make sure your pgAdmin container is running.
- b. Open Docker Desktop → Click on the Containers tab.
- c. Find the container named
pgadmin. - d. Under Port(s), click the port number (usually 5050). This will open pgAdmin in your browser.
- e. Login using the credentials as defined in
.envfile:- Email Address / Username:
PGADMIN_DEFAULT_EMAIL - Password:
PGADMIN_DEFAULT_PASSWORD
- Email Address / Username:
- f. Click the dropdown next to servers. If the server and database is listed under servers, then you can skip steps 2-6
- If installed locally:
- Simply search for pgAdmin in your system applications and launch it, which will open in your default browser.
- If using Docker Desktop:
- Login using the credentials as defined in
.envfile:- Email Address / Username:
PGADMIN_DEFAULT_EMAIL - Password:
PGADMIN_DEFAULT_PASSWORD
- Email Address / Username:
- Click on: Quick Links - Add New Server.
- . General tab:
- Name:
CITS3200(or any name you like)
- Name:
- Connection tab:
- Host name/address:
postgresif in Docker,localhostif on your local PGAdmin - Port:
5432or5434(if pgAdmin was installed locally) - Maintenance database:
postgres - Username:
Refer to DATABASE_USER as provided - Password:
Refer to DATABASE_PASSWORD as provided
- Host name/address:
- Click Save.
- You should now see the databases
- Perform a right-click on "mydb_verVB"
- Select Query Tool (To create SQL Queries)
- eg. SELECT * from location_type
Alembic is used for managing database schema migrations with SQLAlchemy and PostgreSQL.
In your project root (where your database code lives):
# Make sure you are in the main directory, if not, run `cd` ...
alembic init alembicThis creates an alembic/ directory and an alembic.ini config file.
- Open
alembic.iniand set your database URL If you are using the Docker container, then set the URL as:
# line 66 of file or ~line 87 of the file
sqlalchemy.url = postgresql+psycopg2://<user>:<password>@postgres:5432/<databasename>If you are using the local installation of PGAdmin instead, the set the URL as:
# line 66 of file or ~line 87 of the file
sqlalchemy.url = postgresql+psycopg2://<user>:<password>@localhost:5434/<databasename>- In
alembic/env.py, import your SQLAlchemy models and set metadata:
from App.models import Base
target_metadata = Base.metadata # ~ line 24 of env fileUsing existing database schema (backup.sql), create an initial alembic migration version:
alembic revision -m "Initial migration"Ensure your PostgreSQL database is running and accessible with the credentials specified in your .env file.
API will be available at http://localhost:8000
Once the application is running, you can access:
- Interactive docs:
http://localhost:8000/docs - Alternative API docs:
http://localhost:8000/redoc
To set up Flutter, refer to the official set-up guide: Flutter Installation Guide
To check that Flutter is installed and available on your system, run the following in your Terminal:
flutter doctor -vRun the following command in your Terminal:
flutter config --enable-webRun the following command in your Terminal:
flutter build webRun the following command in your Terminal:
flutter run -d web-server