The project uses a Python 3.12 runtime environment and Flask REST-plus framework for the API.
The application uses SQLAlchemy as our ORM to interact with the database.
For the application directory structure, see flask-RESTplus quickstart guide.
The application directory is structured as follows:
|-- app
|-- docman
|-- models
|-- resources
|-- utils (Contains utility shared across modules)
|-- tests (Unit/Integration tests for the application)
|-- app.sh (Shell script used by the python OpenShift s2i image to run the application)
|-- Dockerfile (Dockerfile for running the application locally using Docker)
|-- requirements.txt (Libraries required by the project)
The application assumes you already have a working postgres DB with the required schema and tables and have the connection details in the .env file.
Follow the .env-example
template to create an .env
file with valid values before running the application.
A. OS Level Installation
- Create a virtual environment with python 3.12 and activate it
virtualenv -p python3.12 .venv
source .venv/bin/activate
- Install the requirements
pip install -r requirements.txt
- Run flask migrations in the project
flask db upgrade
- Run the application
flask run
B. Using a docker container
- Switch current directory to the project root
cd ../
- Issue the makefile command that runs the backend
make be
Flask supports click commands which lets you run one-off commands from the command line without having to run the complete app.
To see the list of all click commands, checkout register_commands
method under the __init__.py
file.
The application uses pytest
to run the tests and coverage
to output the results. The testing structure is based around flask testing documentation.
To run tests, use the following command:
coverage run --branch --source=app -m pytest