Skip to content

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...
  • πŸ“„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 under Backend/ 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