Escalation chain
Station-level cases escalate to L3 after 48 h, and L3 to L4 after a further 48 h. L4 has no deadline.
A reporting and case-management backend for police intelligence work, with role-based escalation and per-object access control.
Informant reports arrive unstructured and are easy to lose between police stations and higher offices. The system has to accept reports from registered, device-bound citizens without exposing their identity to every officer who touches the case, and route each case so that only officers in its chain can see it and its media.
It also has to escalate cases nobody acts on within 48 hours, and keep a record of who viewed what, including identity reveals.
Citizens submit reports with photos, video or audio from a Flutter app. Officers triage the reports into cases, investigate them and close them. Sensitive actions are written to an audit log.
JanMitra is a Django REST API with PostgreSQL, Redis and Celery. Officers hold one of five roles, L0 field officer up to L4 top authority. Station-level cases escalate to L3 after 48 hours, and L3 to L4 after a further 48. The escalation runs as a scheduled task that is safe to re-run: escalating resets the deadline, so a case is picked up again only once the next level’s deadline has also expired.
Access control is per object, not just per role. Every endpoint that takes a case, incident or media ID goes through one access module that applies the same visibility rules as the list queryset, so list and detail views cannot drift apart. Device fingerprints are stored hashed, media is encrypted, and audit and identity-reveal logs record sensitive actions.
The API runs under gunicorn behind nginx with Docker Compose, and a Celery worker with an embedded scheduler runs the escalation task. Registration once stored raw device fingerprints, which locked some users out; a migration now hashes the existing rows.
Configuration comes from the environment: the secret key, allowed hosts (never a wildcard) and the demo seed password. The seed command refuses to fall back to a built-in password when debug is off. Uploads have explicit size limits, and the deployment script generates a production environment file with random secrets on its first run. The backend is covered by 113 tests that run on in-memory SQLite, with no Postgres or Redis needed.
Every figure links to the file it was drawn from.
Station-level cases escalate to L3 after 48 h, and L3 to L4 after a further 48 h. L4 has no deadline.
Authentication and device binding, case visibility and media access, escalation, audit logging and notifications.
113
Per-object access control: every endpoint that takes a case, incident or media id applies the same visibility rules as the list queryset.
The Flutter app is not in this repository; its source is referenced by git pointers only. The demo deployment runs over plain HTTP with cross-origin requests allowed from anywhere, and both need tightening before real use.
The Django REST API, Docker setup and deployment scripts are on GitHub.