Important
If you already have PostgreSQL (PostgresSQL.exe) and PgAdmin (PgAdmin4.exe) software installed on your local computer, you have two options:
- Option 1: Keep using your existing installation (credentials like username, password) without using our Docker containers. In this case, you might NEED to change the database connection settings in the
.envfile to match your existing installation if there is any error. You can skip the following steps and go to the next section. - Option 2: Use our Docker containers for PostgreSQL and PgAdmin. In this case, you NEED to stop your existing
PostgreSQL.exeandPgAdmin.exeservices to avoid port conflicts. For example, with the PostgreSQL service, usenet stop postgresql-x64-14for Windows orsudo service postgresql stopfor Linux/Mac. This will prevent the.exeand Docker services from using the same 5432 port, which could lead to unexpected behaviors.
The Postgres database and PgAdmin (to manage the database with GUI) are run in Docker containers. If you only need to run the database services with docker-compose, REMEMBER to comment out the backend and frontend services in the docker-compose.yml file to avoid starting the backend and frontend services.
Then run this command in the root directory of the project to start the Docker containers:
docker-compose up -dThe -d flag is for detached mode, which means the containers will run in the background. If you want to see the logs, you can remove the -d flag.
Wait a few seconds for Docker to initialize everything.
Once Docker has started, you need to run the backend to initialize the database. This will:
-
Connect to the database.
-
Create necessary tables.
-
Seed the database with initial data.
To do this, navigate to the backend directory and run:
cd app/backend
yarn install # to install the dependencies
yarn start # to start the serverWarning
In the development environment, whenever the backend server starts, it will automatically DROP ALL EXISTING TABLES in the database and CREATE NEW TABLES with the initial data. This is useful for development purposes, but be careful not to run this in production as it will delete all existing data.
Once everything is set up, you can log in to PgAdmin to manage the database by accessing the URL http://localhost:5050. You can use PgAdmin to create, modify, and delete tables, as well as run SQL queries against the database.
To log in to PgAdmin, enter credentials based on the fields PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD defined inside .env. After that, set up the server connection to the PostgreSQL database by following these steps:
- On the left panel, right-click on "Servers" and select "Register" -> "Server...".
- Enter the name of the server as you wish:
- Change to the "Connection" tab, and enter the following information:
- Host name/address: postgres (must use the same as the PostgreSQL service name as defined in the
docker-compose.ymlfile) - Port: see the
DB_PORTfield in the.envfile - Username: see the
DB_USERfield in the.envfile - Password: see the
DB_PASSWORDfield in the.envfile
Click "Save" to save the server configuration. After that, you should see your database viewable in the left panel. Click on the database name to see the tables inside.
- To stop the database, run
docker-compose downin the root directory of the project ordocker-compose down -vto remove the volumes as well. The-vflag will remove the database and all data inside it, so be careful with this command.



