BOB Docs
APIDesign

Project structure

Order is essential, especially in IT projects. Therefore, we have introduced few rules to help maintain it and developed with clear guidelines:

  1. Resources not directly related to the application code are stored in folders with an underscore prefix, e.g., _volume, _docker.
  2. We created a main application (core) responsible for launching and configuring the solution in different environments.
  3. Each application has its own structure, consistent with the principles adopted in the solution.

Application Structure

Every application in BOB has the same structure, which saves time and prepares the project for future changes. To illustrate why this approach is beneficial, we created the _template application. It is an example that explains why this application structure supports growth, saves time, and allows for easy division into microservices.

__init__.py
admin.py
apps.py
interactor.py

api

Contains elements related to input and output handling, such as requests and responses. We encourage separating input and output models into separate files as DTO (Data Transfer Objects).

management

A space for commands used by the application, such as seeding or starting cyclic tasks. Examples include monitoring changes in the system. Django allows running the entire application context as a separate task without starting the HTTP server. Details can be found here: Custom Management Commands.

migrations

A folder containing all migrations for the application.

models

Contains models that represent database tables. In this solution, each model inherits from the Base class included in bop_tools.

repository

Repositories enabling access to and management of data. This design pattern was introduced to separate reading and writing, making it easier to create tests and maintain order in the code.

Each repository in the system should inherit from AsyncBaseRepository, a class implementing basic methods using Django ORM.

signals

A folder designated for Django signals. More details can be found here: Django Signals.

services

Contains all business services of the application. In BOB, business logic is based on the collaboration between services.

interactor

A class responsible for managing the interaction between the api and services. This is where the business logic handling processes in the system should be placed.

On this page