- Preface
- Design patterns
- Database ER diagram
- Requirements
- Production
- Development
- API Documentation
- Whats missing
Regarding the main assignment:
-
The assignment specifies
N
subjects andN
careers, meaning students or 'leads' are taking the same amount of classes as careers they are pursuing. I'll assumeNs (N of subjects) != Nc (N of careers)
as it wouldn't make much sense otherwise. -
It also defines N as:
[0, N] ^ [N, X]
butX
is not defined. I'll assumeX = inf
.
Regarding the installation:
This guide assumes you are using a debian based distribution
A simple controller -> repository pattern is used. The service layer (the layer that manages the bussiness logic of the application) was omitted as there was no bussiness logic at all to implement.
DTOs are a great way to decouple the data access layer from the rest of the application, as it provides an intermediate format to transfer queried data, and to also validate new objects that may or may not comply with the validation rules of the application. This also allows us to hide certain fields that we may not want users to see and avoid circular references (i.e. related entities that contain each other).
- Create a .env file in the root directory with the following parameters:
POSTGRES_PASSWORD={YOUR_POSTGRES_PASSWORD}
PG_HOST=database
-
Install python 3.10.12
-
Create a virtual environment running
python3 -m venv venv
-
Activate virtual environment running
source venv/bin/activate
-
Install requirements with
pip install -r requirements.txt
-
Create a .env file in the backend folder containing the following parameters:
- environment=test
-
Run application with
uvicorn app:app --forwarded-allow-ips='*' --host 0.0.0.0 --workers 3 --reload --env-file .env
(remember tocd
in thebackend
directory)
For an interactive API documentation you can go to localhost:8000/docs
(replace localhost for the URL of the server in case you are running it somewhere else)
- Unit testing for repositories
- Bussiness logic layer between the Controller and Repository layers if needed