This project is separated in two parts UI and API for development ease. These are:
- FastAPI backend serves the HTTP endpoints.
- React UI which communicates with the FastAPI endpoints.
Current implemented functionalities of the API's and UI can be seen by running the project with docker following the steps in the production or development.
Implementation reference: https://www.16personalities.com/
-
navbar,
-
Home
-
Survey
- Edit/create/delete - for teachers
- Once created can't be modified
- Take survey - with link provided by teachers
-
Courses - only for teachers
- Questions
-
Result - view only for teachers and students
- there are only 3 results for now
This project is set up to run in production using docker, which will handle restarts when the host machine reboots or the containers crashes in case of errors.
Requirements:
- A VPS with Linux OS
- Docker daemon and cli installed on the
Info: In the production nginx handle all the incoming requests and forwards any request going to
/api/*or/docs/*or/openapi.jsonto the FastAPI backend. And other requests are assumed to be for the static files which nginx serves from the artifacts ofnpm run buildcommand. If the resource for those request not found nginx will simply reply with HTTP 404 status code to indicate file not found error.
Steps to run the server:
- Transfer all the files of the directory where
README.mdfile is or clone the repository to the Linux Server via any means(eg. SSH, FTP, etc.) - Before running the following steps the
working directoryorpwdshould be as instructed in previous step or where the the contents of the project were copied docker compose up -dthis will build the images and run the two containers- Now, you can visit
http://{server_ip}:80to see the UI and interact with it using any web browser. - Logs can be seen using docker command.
- Nginx specific logs like error/access logs can be seen via connecting shell to the nginx container using docker.
Note: System admin should take measure and set up firewall rules after setting up the server. This is out of the scope of this Project so I am not going to discuss about security here.
Before running these commands Go to the directory where your project is for me it's C:\Users\iftak\Desktop\jamk\2025 Spring\00-self-evaluation-tool\. You can use docker desktop for easy log checking and other stats.
docker compose -f docker-compose.dev.yml up --build # If any dockerfile is changed and required for the first time
docker compose -f docker-compose.dev.yml up -d # after first build
docker compose -f docker-compose.dev.yml down # teardown
docker compose -f docker-compose.dev.yml down -fv # teardown and clean up volumesdocker compose -f docker-compose.test.yml up -d --build # Check docker desktop container logs
docker compose -f docker-compose.test.yml down -fv # teardowndocker compose up -d --build # Check docker desktop container logs
docker compose down # teardown but keeps the volumes- Install anaconda/pyenv/venv to manage python environment
conda create -n env_api python=3.13.3creates conda environment for the projectconda activate env_apiactivates the created environment- Before running the following steps the
working directoryorpwdshould be./api. pip install -r requirements.txtinstals the required packages for the projectfastapi devruns the API and reloads the server when files changes in the app directory- Now, you can visit
http://localhost:8000to see the API endpoints and try out the endpoints - To run tests for api endpoints. Run
pytestorpytest -n autoorpytest -n 0from./apidirectory. Note: parallel tests are very fragile keeps throwing errors.
- Before running the following steps the
working directoryorpwdshould be./ui - Note: During the development the
node:22version was used, so keeping the same version will avoid unexpected errors npm installwill install the node packagesnpm run devwill run the vite server for the UI with HMR- Since the FastAPI is being ran on port
8000you will have to update theBASE_URLin./ui/src/services/api.tsfile accordingly. - Now, you can visit
http://localhost:5173to see the UI and interact with it.