This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
CARE is a Digital Public Good building an open source EMR + Hospital Management system. This is the Django backend (Django 6.0 + Python 3.13 + PostgreSQL + Redis).
The local setup uses a Python 3.13 venv with PostgreSQL 16 and Redis running natively.
Start services:
# Ensure PostgreSQL 16 and Redis are running on your system
# Start Django backend on port 9000
DJANGO_SETTINGS_MODULE=config.settings.local DJANGO_READ_DOT_ENV_FILE=true .venv/bin/python manage.py runserver 0.0.0.0:9000Database:
- PostgreSQL on localhost:5432, database
care, userpostgres, passwordpostgres - Config in
.env(gitignored)
cp .env.example .env
make up # Start all services (db, redis, minio, backend, celery)
make load-fixtures # Load test data
make logs # View logs
make down # Stop servicesmake up— Start all servicesmake build— Build Docker imagesmake migrate— Run database migrationsmake makemigrations— Create new migrationsmake load-fixtures— Load test/dummy datamake test path="care.users"— Run specific testsmake test— Run all testsmake ruff-fix-all— Auto-fix linting issues
pipenv run python manage.py migrate
pipenv run python manage.py load_fixtures
pipenv run python manage.py test care.users --keepdb --parallel
pipenv run ruff check --fix .
pipenv run ruff format .- Linter/Formatter: Ruff (replaces black, isort, flake8)
- Python version: 3.13 (strict requirement)
- Package management: Pipenv (
Pipfile+Pipfile.lock)
care/ # Main Django app
├── audit_log/ # Audit logging
├── contrib/ # Contributed modules
├── emr/ # Electronic Medical Records (core domain)
├── facility/ # Facility management
├── users/ # User management & auth
├── security/ # Roles & permissions
└── utils/ # Shared utilities
config/ # Django configuration
├── settings/ # Settings modules (base, local, deployment, test)
├── api_router.py # API URL routing
└── celery_app.py # Celery task queue config
plug_config.py # Plugin system configuration
CARE supports a plugin architecture via plug_config.py and the plugs package. Plugins extend core functionality without modifying the main codebase. Be aware of plugin interfaces when modifying core models or APIs.
- Local dev:
config.settings.local(DEBUG=True, CORS open, email to console) - Tests:
config.settings.test - Production:
config.settings.deployment
- Django REST Framework with
drf-nested-routers - JWT auth via
djangorestframework-simplejwt - API docs via
drf-spectacular(OpenAPI/Swagger) - Routes in
config/api_router.py
Test credentials are available in the fixture data loaded by make load-fixtures or python manage.py load_fixtures.
- Default branch:
develop - Branch naming:
issues/{issue#}/{short-name}
When working autonomously:
- Before coding: Read the relevant model, resource spec, authorization controller, viewset, and test files
- After changes: Run
ruff check --fix .andruff format .to lint and format - Verify: Run related tests:
pipenv run python manage.py test care.module_name --keepdb - Migrations: Run
makemigrationsafter model changes, thenmigrate