An online tutoring platform exclusively for THU students from THU students.
- Software development Kit:
- JAVA 17 or higher
- Build Tool:
- MAVEN 3.9 or higher
- Integrated Development Environment:
- IntelliJ IDEA (Recommended)
- Optional:
- API development and testing tool:
- POSTMAN
- API development and testing tool:
- Delete any existing versions of the project
- Clone the Online_Tutoring_platform from the github repository.
- Add the .env file at the root folder with at least(!!) the following parameters:
- DB_NAME
- DB_PASSWORD
- DB_URL
- DB_USER
- JWT_SECRET_KEY
- JWT_DURATION_IN_MILLISECONDS
Contact Nikolai Ivanov or Jossin Antony for the values of the parameters. 4. Pass the correct environment variables to the IDE (IntelliJ IDEA) - Edit configurations -> User Environment variables.
Attention:
- The .env database url contains 'database' and the port address of the docker database container;
- whereas the IDE environment variables contain 'localhost' and the respective port number in the database URL.
-
Install dependencies: From the root folder, access:
- ./backend -> MVN install
- ./frontend -> NPM install
- ./webrtc -> NPM install
-
Proceed with docker configurations.
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
- From the addon database section/icon in the IntelliJ IDE:
- create a new datasource
- select postgresql
- Pass the database credentials for the localhost deployment- Database name, username, password, URL (localhost URL) amnd the respective port number.
- Test connection
- Save connection.