Table of Contents
The project is based on Poetry. Here you can find how to install and configure your local environment with poetry:
- poetry
curl -sSL https://install.python-poetry.org | python3 -
The service is already exported in Dockerfile and can easly be built through docker-compose. It will be setup with all their dependecies
docker compose up --build
for convenience, if you want to run natively the service and their dependencies dockerized you need to update your hosts file with
127.0.0.1 mongodb
Swagger page is accessible at http://localhost:8080
src/
├─ core/
├─ models/
│ ├─ domain/
│ ├─ orm/
│ ├─ schemas/
├─ routers/
│ ├─ v1/
├─ services/
├─ utilities/
tests/
├─ unit/
├─ integration/
The application is strongly based on Dependency injection. All the dependency are then declared and instantiated inside the container.py. It means that dependencies are never instantiated directly, but they are passed into the constructor or the method signature by the framework
The folder structure follow the following logic:
- Routers: definition of all the endpoints of the application, they can also be versioned and stored in different paths.
- they can call only services
- they can return only schema object
- they do not execute any sort of business logic
- they only validate input coming though the endpoint and then return the related schema response (after calling the underlying layer)
- Services: definition of the business logic of the application
- they can call only repositories and utility classes
- a service cannot reference another service
- a service works and returns a domain object
- Repository: Abstraction layer for the database framework
- they can only manipulate orm objects
- the orm object must be mapped to a domain object before returning anything
- it is the only layers allowed to manipulate data on database
- a repository cannot reference another repository
routers (domain) -> service (domain) -> repository (orm)
routers (schema) <- service (domain) <- repository (domain)
Project use:
You can run formatting though pre-commit before commiting code to the remote
pre-commit run
run the tests with
pytest
- Andrea Aramini - [email protected]