Architecture

Composition

Bireli strongly stands on Project composer to structure its main parts (settings, urls and requirements). You will need to properly understand Project composer before to properly work on a project.

The Workflow document from Project composer documentation contains a diagram exemple of resumed workflow for a Django project.

Details

The composer configuration lives in the pyproject.toml file in sections named tool.project_composer[.**]. Commonly you will only have to care about the option collection where is enabled all compose applications.

Note

Sections tool.project_composer[.**] assemble many options which assemble the composer configuration and that is called the Manifest.

The collection is a list of module directory names from composition_repository/.

You rarely have to edit the environment settings from project/settings because their purpose is only to override base settings for very specific environment needs.

All the Django builtins settings are located in the compose application django_builtins. And in the same idea, each project application settings will be in their compose application.

Structure

Here below we will explain the default project structure, there is many more files and directories but for a better explanation we will only focus on important parts.

.
├── composition_repository/
│   ├── django_builtins/
│   └── sample_app/
├── django-apps/
│   ├── project_utils/
│   └── sample_app/
├── frontend/
│   ├── js/
│   ├── scss/
│   ├── package.json
│   └── webpack.config.js
├── Makefile
├── project/
│   ├── settings/
│   ├── static-sources/
│   ├── templates/
│   └── urls.py
├── pyproject.toml
├── requirements/
└── tests/
composition_repository/

This is the directory which holds the applications configurations that will compose the project. These applications are enabled or not from the collection list from pyproject.toml.

django-apps/

This is the directory which hold the applications code (models, view urls, views, etc..).

frontend/

Everything related to frontend assets is defined and built from there.

  • Javascript sources are in js/;

  • Sass sources are in scss/;

  • Frontend requirements are defined in package.json;

  • Asset management is configured in webpack.config.js;

project/

This holds the Django project configuration and built assets.

  • settings/ store all the environment settings;

  • static-sources will contains all built static to serve. It is not to mistake with static that is virtual directory that is only used in production so don’t put anything there.

  • templates/ store all the project and applications templates;

  • urls.py mount all the applications urls modules;

requirements/

This holds all Environment Requirements.

tests/

This is where to write all backend tests including project tests and all applications tests. No test in the applications directories is allowed because we want to store them in the same place.

pyproject.toml

The project backend manifest contains the Project composer manifest, versionning and many development tool configurations.