Django + Django REST Framework backend for Thrivemind.
- Python 3.11+
- Django 4.0.6
- Django REST Framework
- JWT auth (
djangorestframework-simplejwt) - PostgreSQL in deployed environments
- Create and activate a virtual environment.
- Install dependencies:
python3 -m pip install -r requirements.txt- Create a
.envfile (or export env vars) with at least:
DJANGO_SECRET_KEY=your-secret
OPENAI_API_SECRET_KEY=your-openai-key
APNS_KEY_ID=your-apns-key-id
APNS_TEAM_ID=your-apns-team-id
APNS_BUNDLE_ID=your-apns-bundle-id
APNS_P8_SECRET=your-apns-p8-content
DATABASE_URL=postgres://... # or sqlite:////tmp/thrivemind_local.sqlite3- Run migrations:
python3 manage.py migrate- Start the API:
python3 manage.py runserverUse sqlite for local test isolation:
DATABASE_URL=sqlite:////tmp/thrivemind_pytest.sqlite3 \
python3 -m pytest -qRun a single pytest module:
DATABASE_URL=sqlite:////tmp/thrivemind_pytest.sqlite3 \
python3 -m pytest tests/api/test_auth_and_ownership.py -qRun existing Django tests directly:
DATABASE_URL=sqlite:////tmp/thrivemind_test.sqlite3 \
python3 manage.py test -v 2Run contract-focused compatibility checks (frontend-critical endpoints/DTO keys):
DATABASE_URL=sqlite:////tmp/thrivemind_pytest.sqlite3 \
python3 -m pytest tests/api/test_frontend_contract_compat.py -q- Open a PR into
main; Heroku CI runs contract tests + full pytest suite. - Merge only after required checks pass.
mainauto-deploys to staging (with "wait for CI" enabled in Heroku pipeline).- Promote staging to production after smoke checks pass.
- Release phase runs
python manage.py migrate --noinput(committed migrations only).
- Global DRF default permission is
IsAuthenticated. - Auth routes are under
/auth/. - Core API viewsets are registered in
thrivemindbackend/urls.py. - Additional testing notes are in
TESTING.md.