Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HERA Backend — Admin Panel & Web Service

Django + Django REST Framework API and admin panel for HERA. Runs locally with Docker Compose (PostgreSQL + the web service). The HERA mobile app talks to this API.


Run locally

Prerequisites

  • Docker Desktop (with the WSL2 backend on Windows). Verify with docker run hello-world.

1. Create web/hera/secrets.py

The secrets file is not in the repo (gitignored). Django imports it at startup (from .secrets import ...), so without it the server won't boot. Create web/hera/secrets.py:

GOOGLE_MAPS_KEY = ""
SENTRY_SDK_DSN = ""
STATIC_TOKEN = ""
GLOBAL_OTP_AUTH = "000000"   # local OTP bypass — see "Sign in locally" below
CLOUDFLARE_TURNSTILE_SECRET = ""
CLOUDFLARE_BYPASS_TOKEN = ""
TWILIO_ACCOUNT_SID = "AC00000000000000000000000000000000"   # format-valid dummy
TWILIO_AUTH_TOKEN = "00000000000000000000000000000000"
TWILIO_MESSAGING_SERVICE_SID = ""
ONESIGNAL_ID = "00000000-0000-0000-0000-000000000000"
ONESIGNAL_KEY = ""
MESSAGEBIRD_API_KEY = ""
OPENAI_API_KEY = ""
DO_BYPASS = ""

Empty / dummy values let the server boot and serve the core API locally. The third-party integrations (SMS via Twilio/MessageBird, Cloudflare captcha, OneSignal push, OpenAI, Google Maps/Translate, Sentry) stay inert until you add real keys. (Twilio's client needs a non-empty AC…-prefixed SID or its constructor fails — hence the dummy above.)

2. Remove the missing hotline_ai_chatbot references

⚠️ Known repo issue: web/hera/settings.py lists "hotline_ai_chatbot" in INSTALLED_APPS and web/hera/urls.py includes hotline_ai_chatbot.urls, but that app's source was never committed to the public repo. Django fails to boot with ModuleNotFoundError: No module named 'hotline_ai_chatbot'. Until it is open-sourced, remove both references:

  • web/hera/settings.py → delete "hotline_ai_chatbot", from INSTALLED_APPS.
  • web/hera/urls.py → delete the line path('', include('hotline_ai_chatbot.urls')),.

3. Start the services

docker compose up --build

Builds the web image (Python 3.10 + dependencies) and starts PostgreSQL 13 (db) and the web service on http://127.0.0.1:8000. The first build pulls images and installs dependencies (~5 min).

4. Run database migrations

docker compose run --rm web python manage.py migrate

5. Verify

Open http://127.0.0.1:8000/api_docs/redoc/ — the browsable API docs (HERA v2). Endpoints such as http://127.0.0.1:8000/user_profiles/ return 401 without authentication (expected).

The database connection is injected by docker-compose.yml via HERA_DB_SECRET + HERA_DJANGO_SECRET_KEY (Postgres DB hr, user us, password pwd, host db inside the compose network).


Sign in locally (OTP bypass)

The mobile app signs in via Auth0 passwordless SMS by default, which cannot deliver codes locally. For local testing, set GLOBAL_OTP_AUTH in web/hera/secrets.py to a fixed code (e.g. "000000"); the /otp_auth/attempt_challenge/ endpoint accepts it as a universal master OTP for any valid phone number. After changing secrets.py, restart the web service:

docker compose restart web

Day-to-day commands

docker compose logs -f web                                # live web logs
docker compose down                                       # stop everything
docker compose up -d                                      # start (no rebuild)
docker compose run --rm web python manage.py <command>    # any Django command
docker compose run --rm web python manage.py createsuperuser

Testing

docker compose run --rm web python manage.py test
docker compose run --rm web python manage.py flush        # wipe all data

(Optional) Connect to the database

The Postgres container exposes port 5432 (DB hr, user us, password pwd):

postgresql://us:pwd@127.0.0.1:5432/hr

Django admin & 2FA

After migrating, create a superuser (docker compose run --rm web python manage.py createsuperuser), then visit account/login/ → enable 2FA → admin/.

Database schema

Database schema

Deploying

  1. Install Docker Desktop (required for AWS Copilot builds).
  2. Install the AWS Copilot CLI.
  3. Run copilot deploy (choose test vs production-turkey). Make sure you are on the right git branch with the correct settings.py / secrets.py values.

Releases

Packages

Contributors

Languages