Skip to content

Latest commit

 

History

History
92 lines (60 loc) · 2.43 KB

README.md

File metadata and controls

92 lines (60 loc) · 2.43 KB

Document Manager API

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.

Directory/Naming convention

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)

Pre-requisites and Installation

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

  1. Create a virtual environment with python 3.12 and activate it
virtualenv -p python3.12 .venv
source .venv/bin/activate
  1. Install the requirements
pip install -r requirements.txt
  1. Run flask migrations in the project
flask db upgrade
  1. Run the application
flask run

B. Using a docker container

  1. Switch current directory to the project root
cd ../
  1. Issue the makefile command that runs the backend
make be

Flask Click commands

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.

Testing

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