Back end
This page shall provide more in-depth information on the structure of the back end and it's most important files.
Structure
The back end is structured in a way, that distinguishes between a local development environment and a production environment.
Therefore some files such as the Dockerfile (see Installation) are available twice. Depending on the environment, the respective files should either be used or are used automatically.
Files marked with the word base such as config/settings/base.py
- as the name suggests - serve as a base for both,
the local and the production environment.
.
├── .envs # environment variables, e.g. secret information
├── compose # contains the Dockerfiles
│ ├── local # - files for local development
│ └── production # - files for production
├── config # back end configuration
│ └── settings # django settings, grouped by local and production
├── dashboard
│ ├── contrib # by cookiecutter
│ ├── patients # app directory containing the model and API
│ ├── static # containing the static files from the front end
│ ├── templates # html templates to render static files, 404 templates etc.
│ ├── users # app directory containing user model (by cookiecutter)
│ ├── utils # by cookiecutter
│ └── webpack_bundle #
├── docs # sphinx documentation (deprecated due to this one)
│ ├── _build
│ └── _source
├── locale #output folder for translations
├── requirements #requirements grouped by local and production
Getting started
The most important folders, to get started with the back end are the following:
- config : The settings for the project are to be found in the config folder.
- dashboard/patients : This is the main app of the back end. It inherits the model definitions as well as the API's and the views.
- dashboard/patients/migrations : Migrations made for the patients model can be found in this folder. Migrations to other apps/models live in their respective folders.
- dashboard/static/vue : Just for information purposes: The static (HTML, CSS, JS..) files that are generated by the front end, will be transfered into this folder.
- dashboard/templates : Just for information purposes: Here lives the
home.html
which is the root of the app that is being served in the browser. - requirements : All the requirements (dependencies) that are needed for development and/or production purposes.
In the following, each of the different sections of the back end will be explained in more detail.
env files
Environment files are mainly used to store sensitive data such as passwords or secret keys that may cause vulnerabilities if exposed in the code.
In local environments some things may be hardcoded, when they are depending on environment variables in production. This is an intended behaviour and should not be changed.
See the config
section and information about the settings. Most of the settings that require environment variables are defined there.
.envs
├── .local
│ ├── .django
│ └── .postgres
└── .production
├── .django
└── .postgres
compose
Except for the .yml
files, all of the docker configuration is to be found in this directory. As usual, the configurations are separated by environments.
.
├── local
│ ├── django
│ │ ├── Dockerfile
│ │ └── start
│ └── docs
│ └── Dockerfile
└── production
├── django
│ ├── Dockerfile
│ ├── entrypoint
│ └── start
├── postgres
│ ├── Dockerfile
│ └── maintenance
│ ├── _sourced
│ ├── backup
│ ├── backups
│ └── restore
└── traefik
├── Dockerfile
└── traefik.yml
config
The main settings of the software are to be found in the config folder. Whats normally the settings.py
file, lives in the settings
folder and is separated by environment.
Because there are settings, that local and production environments have in common, there is also a base.py
, that serves as the base. In a local environment, the settings of both the base.py
and the local.py
will be considered.
├── __init__.py
├── api_router.py
├── asgi.py
├── middleware.py
├── settings
│ ├── __init__.py
│ ├── base.py
│ ├── local.py
│ ├── production.py
│ └── test.py
├── urls.py
└── wsgi.py
dashboard
.
├── contrib
│ └── sites
│ └── migrations
├── patients
│ ├── api
│ └── migrations
├── static
│ ├── css
│ ├── fonts
│ ├── images
│ │ └── favicons
│ ├── js
│ ├── sass
│ └── vue
│ ├── css
│ ├── fonts
│ ├── img
│ └── js
├── templates
│ ├── account
│ ├── pages
│ ├── users
│ └── webpack_bundle
├── users
│ ├── api
│ ├── migrations
│ └── tests
├── utils
└── webpack_bundle
└── templatetags
requirements
The requirements follow the logic that was presented in the settings. base.txt
is serving as a base for both local and production environments. Depending on the environment, the respective requirements will be installed additionally.
The base.txt
should only include what's needed in both environments.
.
├── base.txt
├── local.txt
└── production.txt