π File Structure
In this document we will cover the file structure of the Backend for Spotify Electron.
π΄ App
- π Common. Handles common logic for all app.
- π PropertiesManager: loads environment variables and its associated logic and stores global app states.
- π PropertiesMessageManager: loads and store common response messages.
- π Database. Handles database connection.
- π Exceptions. Custom base exceptions for our app.
- π Logging. Configure and provide logging formatting and handling for all app modules.
- π Middleware. Stores the middlewares used in the app and its logic.
- π Patterns. Desing patterns schemas.
- π Resources. Common configuration
.ini
. - π Spotify_electron: main folder for our bussiness logic.
- π Playlist. We will use playlist as an example but this apply to the whole domain model.
- π Controller. Router used by FastAPI, it handles the incoming HTTP Requests. Upon recieving HTTP Request it delegates into the service layer.
- Service. Handles the bussiness logic for our domain model. It communicates with the repository layer for dasta persistence.
- π Repository. Manages the persistence layer and communicates directly with the database.
- πSchema. Stores the entity related model such as classes or exceptions.
- π Providers. Services responsible for loading or supplying services depending and database collections multiple conditions.
- π Validations. Common validations for repository and service layer. This include among others checks for database responses.
- π Utils. Auxiliar functions for common operations such as date formatting, json validation...
- π Playlist. We will use playlist as an example but this apply to the whole domain model.
- π
main
. Entrypoint of the app. Loads middlewares, routers and global configurations.
π³ Docker
Docker folder contains configuration files and scripts for deploying app containers using Docker. You can find more info here.
π§ͺ Tests
Here we can find stuff related to testing our backend:
- π
assets
. Folder that contains assets such as songs or files used in the tests. - π Test files. Test files are grouped by entities such as songs, database, playlist etc. Named with
test__testname
convention. - π
test_API
. Folder that stores shared logic between tests, such as HTTP requests. - π
conftest.py
. File that exposes fixtures to all test files. - β
pytest.ini
. Config file for provided environment values on text execution.
π³ Root Folder
In this folder we can find the Backend global configuration files. It includes:
- βοΈ Ruff linter and formatter configuration file.
- βοΈ Dependencies for base, dev and test mode. This follow the format
requirements-[type].txt
. - ποΈ Deploy configuration files such as Procfile and Dockerfile.
- βοΈ Environment variables files. Production and development environments are provided in
Backend/docker/env
.dev.env
is used as an example, the app will only recognize a.env
file underBackend/
folder. More on environments.
βοΈ .vscode
This folder is used to store the VSCODE related configurations. It contains:
- βοΈ Recommended VSCODE extensions to use in the project
- βοΈ Debug Scripts for launching the app and running the tests
- βοΈ Settings for type checking python code and detecting tests files