Dhruvin Dave

JanMitra

A reporting and case-management backend for police intelligence work, with role-based escalation and per-object access control.

Problem

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.

Approach

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.

Results

Every figure links to the file it was drawn from.

Escalation chain

Station-level cases escalate to L3 after 48 h, and L3 to L4 after a further 48 h. L4 has no deadline.

Escalation chain from L0 to L4A ladder of five levels, L0 field officer at the bottom, then L1 station officer, L2 inspector, L3 higher authority after 48 hours, and L4 top authority after a further 48 hours. A dot climbs the ladder.L4 top authorityafter a further 48 hL3 higher authorityafter 48 hL2 inspectorL1 station officerL0 field officer

Source

113 tests

Authentication and device binding, case visibility and media access, escalation, audit logging and notifications.

113

  • authentication
  • reports
  • media_storage
  • audit
  • notifications
  • core

Per-object access control: every endpoint that takes a case, incident or media id applies the same visibility rules as the list queryset.

Source

Limits

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.

Code

The Django REST API, Docker setup and deployment scripts are on GitHub.