Skip to content

This is the web backend and API source code for Hera Digital Health

Notifications You must be signed in to change notification settings

muathkhatib/HERA-WEB-BACKEND-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hera Admin Panel and Web Service

Getting up and running

Get API Secrets from another dev

hera-api $ touch web/hera/secrets.py
# paste the secrets you get into this file

Create Volume for Temporary Database

hera-api $ docker volume create heradb-vol

Run local server

hera-api $ docker compose up --build

Browsable API docs is now available at your localhost http://127.0.0.1:8000/api_docs/redoc/. You can also play around with the APIs, for example by visiting User Profiles API.

Run database migration

hera-api $ docker compose run web python manage.py migrate

(Optional) Connect to your database

If you are using TablePlus app, go to Connection > New > Import from URL and paste the following:

postgresql://herauser:[email protected]/heradb?statusColor=F8F8F8&enviroment=local&name=Docker%20PG&tLSMode=0&usePrivateKey=false&safeModeLevel=0&advancedSafeModeLevel=0

(Optional) Open browsable API documentation

Run Django administration commands

Prefix docker compose run web to your usual Django commands.

# django-admin example
docker compose run web django-admin startapp api

# manage.py example to create superuser to login to admin panel
docker compose run web python manage.py createsuperuser

Python Development Routines

Pip

Adding dependencies

hera-api $ cd web
hera-api/web $ pipenv install your-new-library;
hera-api/web $ pipenv lock --requirements > requirements.txt
hera-api/web $ docker compose up --build; # make sure to add --build flag to update docker image

Testing

Running unit tests

# You need docker compose up to get PostgreSQL running as it's used for test database 
hera-api $ docker compose up [--build] # --build only if you have modified requirements.txt

# Run tests as many times as you like:
hera-api $ docker compose run web python manage.py test

Deleting all data

hera-api $ docker compose run web python manage.py flush

i18n

Generating strings file

Run in your local computer with GNU Gettext installed:

docker-compose run web django-admin makemessages -l tr -l ar

This will generate the the django.po files. Translate them and do test the compilation with

docker-compose run web django-admin compilemessages

However, by default, .mo (compiled messages) files are ignored by .gitignore. Therefore, for the deployment, we have to run copilot svc exec, then ``django-admin compilemessages`.

Code Style

For code style guidelines, please read CONTRIBUTING.md.

Database Schema

This is the database schema

Django Two-Factor Authentication

It is required to run migration for 2FA to work.

docker compose run web python manage.py migrate

To enable 2FA for admin,

  1. Visit account/login/
  2. Login admin, then will lead to account/two_factor/
  3. Enable the 2FA and setup the authenticator such as Authy
  4. Then can visit the admin page at admin/

Deploying

  1. Run copilot deploy

About

This is the web backend and API source code for Hera Digital Health

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages