Skip to content
Dimitri Bigler edited this page Jan 25, 2024 · 5 revisions

HASKI Backend Documentation

This is the documentation of the HASKI Backend. The HASKI Backend consists of a web app created via Flask and provides the data and algorithms for the HASKI project. Please read the Readme for further details about requirements and installation.


Setup

  • Install Python
  • For library management within Python:
    • Use Anaconda:
      • Install Anaconda
      • To create an environment with the needed libraries, run conda create --name HASKI-Backend --file requirements.txt
      • To activate the conda environment, run conda activate HASKI-Backend
    • Use Python Virtual Environment:
  • For the Database, the project uses PostgreSQL
    • For local installation, follow this page and connect to it via PgAdmin
    • For usage as a docker container, please follow this tutorial
  • For setting up the DB tables, please refer to the scripts section
  • Create an .env file in the HASKI Backend with the .env_template file for connecting your HASKI system and the DB
  • Enable Web-Services and REST Protocol in Moodle and generate a token for an admin user.

Scripts

Within the source files, there are scripts provided, that will help you to manage the system. These are:

  • .env_template: This provides the structure for the .env file needed for the system
  • db_clean_up.py: A python script, that will delete all entries from the DB tables and leaves you with an empty DB
  • db_setup.py: A python script, that will create the DB and its tables for you. You need to change the settings within both connect statements
  • validate_script.py: A python script,that will run pytest and pycodestyle for you to check locally if all criteria are accepted
  • setup/Table_Setup.sql: In here you can find the SQL Statements to create the DB tables

Development Guidelines

We will follow some Gudielines for the Development. These are:

• We will use Python 3.10 for our development.

• We will follow the Zen of Python.

• We will write idiomatic python code and follow the PEP8 style guide.

• For better code, we will use the library pycodestyle for linting.

• We will use Flask for the overall creation of the backend.

• We will create RESTful-APIs and document them with OAS 3.0.

• We will use the pytest library for our TDD.

• We will use TDD for all parts. No tests, no merge.

• The used libraries will be saved in a requirements.txt file, so that everyone will be able to directly install the necessary parts.

• Uses as many comments as necessary, as few as possible.

• The naming (of variables, functions, classes, etc.) should be self-explaining.

Clone this wiki locally