An online tutoring platform exclusively for THU students from THU students.
Before running the application, ensure you have the following installed:
- Docker Engine: Make sure Docker is installed and running on your machine.
- Docker Compose: Docker Compose is also required. It typically comes with Docker Desktop, but you can install it separately if needed.
To run both the backend and frontend applications using Docker Compose, follow these steps:
-
Navigate to the root directory of the project:
cd ~/path/to/Online_Tutoring_Platform
-
Run the Compose command:
docker-compose up --build --detach
-
Running only the Backend (will start the database and webrtc server as dependencies):
docker-compose up --build --detach backend
-
Running only the Frontend:
docker-compose up --build --detach frontend
-
Running only the Database:
docker-compose up --build --detach database
-
Running only the webrtc server:
docker-compose up --build --detach webrtc-server
-
Stopping all containers:
docker-compose down
-
Stopping only the Backend:
docker-compose stop backend
-
Stopping only the Frontend:
docker-compose stop frontend
-
Stopping only the Database:
docker-compose stop database
-
Stopping only the webrtc server:
docker-compose stop webrtc-server
.env
file: An.env
file, required for creating the database and backend container, is included in the repository as an example.- Running Backend Locally: If you run the backend from an IDE, ensure the database is started first (!!IMPORTANT!!), ideally from the docker container. Identical environment variables should be set in the IDE to match those in Docker. In the intellij IDE, these can be set in the 'Edit Configurations' section.
- Local Database URL: If the backend runs outside a Docker container, make sure the
databaseUrl
points to your local database (e.g.,localhost
). - JWT_SECRET_KEY:The secret key must be an HMAC hash string of 256 bits; otherwise, the token generation will throw an error.
- The database used in this application is configured to be persistent by utilizing Docker volumes.
- In the
docker-compose.yml
file, a named volume (postgres_data
) is created and mapped to the PostgreSQL container’s data directory (/var/lib/postgresql/data
) - Additionally, the data is stored in a folder named
database
in the repository. - This setup ensures that all database data remains intact even when the container is stopped or removed, allowing for seamless data management across container lifecycles.
- Backend: Available at http://localhost:8080
- Frontend: Available at http://localhost on port 80 (served by Nginx, not React's development server).
- Database: Available at http://localhost:5431 (Ensure match with parameters in .env file)
- Webrtc server: Available at http://localhost:5000