Running the project manually
Prerequisites
Before you start, you need to have the following tools installed on your machine:
- Java JDK (version 17 or higher)
- Maven
- Node.js (version 18 or higher)
- Python (version 3.12 or higher)
- PostgreSQL
Note
Follow the installation guide for your machine included in this documentation: Windows, Ubuntu or MacOS
Installing PostgreSQL
Windows
Via Chocolatey
- Open the terminal as Administrator.
- Run the following command:
choco install postgresql
Via MSI
- Access the PostgreSQL downloads page.
- Download the MSI installer.
- Follow the wizard's instructions to complete the installation.
Linux
Via APT (Debian/Ubuntu)
- Open the terminal.
- Update the package index:
sudo apt update - Install PostgreSQL:
sudo apt install postgresql postgresql-contrib
macOS
Via Homebrew
- Open the terminal.
- Install PostgreSQL using Homebrew:
brew install postgresql - Start the PostgreSQL service:
brew services start postgresql
Docker
- Open the bash terminal (WSL on Windows).
- Run the command that executes postgres:
docker run -d --name pgfeedback -e POSTGRES_PASSWORD=root -e POSTGRES_DB=feedback -p 5432:5432 postgres - This command is only for the first time you run the container. For subsequent times, use the command:
docker start pgfeedback
If you install PostgreSQL outside of a Docker environment, you will need to use a database management tool like dbeaver to set up the initial feedback database.
Running the Project Manually
1. Configure the Database
Make sure PostgreSQL is running. You can start the service as per the instructions above, depending on your operating system.
2. Configure Environment Variables
Set the following environment variables:
-
Linux and Mac OS
export DB_HOST=localhost export DB_PORT=5432 export DB_USER=postgres export DB_PASS=root export JWT_SECRET_KEY=4Z^XrroxR@dWxqf$!@#qGr4P export JWT_ISSUER=user-api export DATABASE_URL=postgresql://postgres:root@localhost:5432/feedback -
Windows
$env:DB_HOST="localhost" $env:DB_PORT="5432" $env:DB_USER="postgres" $env:DB_PASS="root" $env:JWT_SECRET_KEY="4Z^XrroxR@dWxqf$!@#qGr4P" $env:JWT_ISSUER="user-api" $env:DATABASE_URL="postgresql://postgres:root@localhost:5432/feedback"
3. Run the Java Microservices
Access the directory of each microservice, build, and start the services:
Enter the JAVA projects folder
cd java_backend
Build the projects
mvn clean install -DskipTests
mvn -pl microservices/usermanagement spring-boot:run
Run feedbackrequest
mvn -pl microservices/feedbackrequest spring-boot:run
Run feedbackresponse
mvn -pl microservices/feedbackresponse spring-boot:run
4. Run the Python Microservice
Enter the project folder
# Run feedbackresponseview
cd python_backend/feedbackresponseview
Install the dependencies
poetry install
Running the project
poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
5. Run the API Gateway (Node.js)
cd node_backend/api_gateway
npm install
npm run start
6. Run Nginx
Ubuntu
-
Prerequisites
Make sure Nginx is installed on Ubuntu. If not, install it with:
sudo apt update sudo apt install nginx -
Copy the Configuration File
Assuming the local configuration file is in agatewayfolder and is namednginx.conf, copy it to the Nginx configuration directory:sudo cp gateway/nginx.conf /etc/nginx/sites-enabled/default -
Change the Configuration with sed
If you need to replace values (e.g., change the host tolocalhostin a configuration line), use:Command explanation:sudo sed -Ei 's/(server\s+)[^:]+(:[0-9]+;)/\1localhost\2/g' /etc/nginx/sites-enabled/default sed -Eienables in-place editing mode with extended regular expressions.-
The command looks for a line containing
serverfollowed by some space and then any value until it finds a port number (e.g.,:80;) and replaces that value withlocalhostwhile keeping the port. -
Restart Nginx
After making changes, restart the service for the changes to take effect:sudo service nginx restart
macOS
On macOS, there are some considerations, mainly that sed may have differences (macOS uses BSD sed). Also, Nginx can be installed via Homebrew.
-
Install Nginx
Use Homebrew to install Nginx (if it's not already installed):The default Nginx configuration file on macOS (via Homebrew) is usually found atbrew install nginx/usr/local/etc/nginx/nginx.conf. If you are using a sites file, you may need to adapt the path, for example:/usr/local/etc/nginx/servers/default.conf -
Copy the Configuration File
Assuming you want to replace a site's configuration file:sudo cp gateway/nginx.conf /usr/local/etc/nginx/servers/default.conf -
Change the Configuration with sed
Due to the differences in BSD sed, the syntax may require the-Eflag and the use of a backup extension (e.g.,.bak). An example:This command creates a backup of the original file with thesudo sed -i.bak -E 's/(server\s+)[^:]+(:[0-9]+;)/\1localhost\2/g' /usr/local/etc/nginx/servers/default.conf.bakextension. You can remove this backup later if you prefer. -
Restart Nginx
If Nginx was installed via Homebrew, restart it with:brew services restart nginx
Windows
On Windows, there are two approaches you can take to perform these tasks:
Using Chocolatey
Chocolatey is a package manager for Windows. You can use it to install Nginx and run scripts in PowerShell.
Steps:
-
Install Nginx via Chocolatey
Open PowerShell with administrator privileges and run:Generally, Nginx installed via Chocolatey will be at:choco install nginx -y
C:\tools\nginx\conf\nginx.confor a similar path. Check the package documentation. -
Copy the Configuration File
If your local file is, for example, atC:\projects\gateway\nginx.conf, run:Copy-Item -Path "C:\projects\gateway\nginx.conf" -Destination "C:\tools\nginx\conf\nginx.conf" -Force -
Change the Configuration
To change the file using a tool similar to sed on Windows, you can use PowerShell with regular expressions. For example:(Get-Content "C:\tools\nginx\conf\nginx.conf") -replace '(server\s+)[^:]+(:[0-9]+;)', '$1localhost$2' | Set-Content "C:\tools\nginx\conf\nginx.conf" -
Restart Nginx
This depends on how Nginx was configured to run. If it's running as a service, restart it. If not, close and start it again using Nginx's own shortcut or script, for example:# Assuming you have a script to stop and start: Stop-Process -Name nginx -Force Start-Process "C:\tools\nginx\nginx.exe"
WSL (Windows Subsystem for Linux)
Follow the instructions for Ubuntu.
7. Access the Application
Depending on the ports where you configured the services, you will have to access them through the chosen ports. Be careful when running multiple Spring applications, as they might end up starting on the same port. Modify the application properties to change the desired port for each one.