# salmakhalill/secure-report architecture

> Architecture diagram of the GitHub repository salmakhalill/secure-report, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salmakhalill/secure-report
- Repository: https://github.com/salmakhalill/secure-report

## Overview

SecureReport is a Django REST backend for anonymous crime reporting and staff case management. A public reporter submits a report with optional suspect details and attachments, receives a tracking code, and can later retrieve its status; staff authenticate with JWT to review, update, archive, and analyze cases. The graph also preserves account administration, reset emails, the public site statistics endpoint, and the documented severity-classifier integration. Edges reflect shown calls or README descriptions; the classifier is disabled in the sampled view, so its integration is shown as optional.

Main entry points: [`accounts/views.py`](https://github.com/salmakhalill/secure-report/blob/main/accounts/views.py) (Account endpoints), [`reports/views.py`](https://github.com/salmakhalill/secure-report/blob/main/reports/views.py) (Report endpoints), [`reports/models.py`](https://github.com/salmakhalill/secure-report/blob/main/reports/models.py) (Cases and evidence), [`config/urls.py`](https://github.com/salmakhalill/secure-report/blob/main/config/urls.py) (Root API routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reporting["Report lifecycle"]
  node_report_api["Report endpoints<br/>[views.py]"]
  node_report_serializers["Report serialization<br/>[serializers.py]"]
  node_case_records[("Cases and evidence<br/>[models.py]")]
  node_tracking["Tracking lookup<br/>[views.py]"]
  node_archive["Archive cases<br/>[views.py]"]
  node_severity_model["Arabic severity model<br/>[ml_model.py]"]
end

subgraph group_identity["Accounts and access"]
  node_accounts_api["Account endpoints<br/>[views.py]"]
  node_user_records[("User records<br/>[models.py]")]
  node_account_serializers["Account serialization<br/>[serializers.py]"]
  node_access_rules["Role permissions<br/>[permissions.py]"]
  node_reset_tokens["Reset token helpers<br/>[auth_service.py]"]
  node_email_delivery["Email delivery<br/>[email_service.py]"]
end

subgraph group_insights["Analytics"]
  node_analytics_api["Analytics endpoints<br/>[views.py]"]
  node_analytics_processing["KPI and chart processing<br/>[utils.py]"]
end

subgraph group_platform["API and persistence"]
  node_django_routes["Root API routing<br/>[urls.py]"]
  node_django_settings["Application configuration<br/>[settings.py]"]
end

node_public_reporter(("Public reporter"))
node_staff(("Authority staff"))
node_sendgrid["SendGrid"]
node_api_client["React API clients"]

node_public_reporter -->|"submits reports"| node_report_api
node_report_api -->|"serializes requests"| node_report_serializers
node_report_serializers -->|"creates cases"| node_case_records
node_report_api -->|"queries cases"| node_case_records
node_public_reporter -->|"tracks code"| node_tracking
node_tracking -->|"looks up code"| node_case_records
node_staff -->|"manages cases"| node_report_api
node_staff -->|"views archive"| node_archive
node_archive -->|"filters closed cases"| node_case_records
node_report_api -.->|"may classify severity"| node_severity_model
node_api_client -->|"authenticates"| node_accounts_api
node_staff -->|"manages accounts"| node_accounts_api
node_accounts_api -->|"validates account data"| node_account_serializers
node_account_serializers -->|"creates and updates"| node_user_records
node_accounts_api -->|"queries users"| node_user_records
node_accounts_api -->|"checks access"| node_access_rules
node_accounts_api -->|"sends reset email"| node_email_delivery
node_accounts_api -->|"resolves reset user"| node_reset_tokens
node_email_delivery -->|"sends messages"| node_sendgrid
node_api_client -->|"requests dashboards"| node_analytics_api
node_analytics_api -->|"computes dashboard data"| node_analytics_processing
node_analytics_processing -->|"reads report data"| node_case_records
node_api_client -->|"calls REST API"| node_django_routes
node_django_routes -.->|"routes report requests"| node_report_api
node_django_routes -.->|"routes account requests"| node_accounts_api
node_django_routes -.->|"routes analytics requests"| node_analytics_api

click node_report_api "https://github.com/salmakhalill/secure-report/blob/main/reports/views.py"
click node_report_serializers "https://github.com/salmakhalill/secure-report/blob/main/reports/serializers.py"
click node_case_records "https://github.com/salmakhalill/secure-report/blob/main/reports/models.py"
click node_tracking "https://github.com/salmakhalill/secure-report/blob/main/reports/views.py"
click node_archive "https://github.com/salmakhalill/secure-report/blob/main/reports/views.py"
click node_severity_model "https://github.com/salmakhalill/secure-report/blob/main/reports/ml_model.py"
click node_accounts_api "https://github.com/salmakhalill/secure-report/blob/main/accounts/views.py"
click node_user_records "https://github.com/salmakhalill/secure-report/blob/main/accounts/models.py"
click node_account_serializers "https://github.com/salmakhalill/secure-report/blob/main/accounts/serializers.py"
click node_access_rules "https://github.com/salmakhalill/secure-report/blob/main/accounts/permissions.py"
click node_reset_tokens "https://github.com/salmakhalill/secure-report/blob/main/accounts/services/auth_service.py"
click node_email_delivery "https://github.com/salmakhalill/secure-report/blob/main/accounts/services/email_service.py"
click node_analytics_api "https://github.com/salmakhalill/secure-report/blob/main/analytics/views.py"
click node_analytics_processing "https://github.com/salmakhalill/secure-report/blob/main/analytics/utils.py"
click node_django_routes "https://github.com/salmakhalill/secure-report/blob/main/config/urls.py"
click node_django_settings "https://github.com/salmakhalill/secure-report/blob/main/config/settings.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_report_api,node_report_serializers,node_case_records,node_tracking,node_archive,node_severity_model,node_api_client toneBlue
class node_accounts_api,node_user_records,node_account_serializers,node_access_rules,node_reset_tokens,node_email_delivery toneAmber
class node_analytics_api,node_analytics_processing toneMint
class node_django_routes,node_django_settings toneRose
class node_public_reporter,node_staff,node_sendgrid toneIndigo
```

## Components

### Report lifecycle

- [Report endpoints](https://github.com/salmakhalill/secure-report/blob/main/reports/views.py): `reports/views.py`
- [Report serialization](https://github.com/salmakhalill/secure-report/blob/main/reports/serializers.py): `reports/serializers.py`
- [Cases and evidence](https://github.com/salmakhalill/secure-report/blob/main/reports/models.py): `reports/models.py`
- [Tracking lookup](https://github.com/salmakhalill/secure-report/blob/main/reports/views.py): `reports/views.py`
- [Archive cases](https://github.com/salmakhalill/secure-report/blob/main/reports/views.py): `reports/views.py`
- [Arabic severity model](https://github.com/salmakhalill/secure-report/blob/main/reports/ml_model.py): `reports/ml_model.py`

### Accounts and access

- [Account endpoints](https://github.com/salmakhalill/secure-report/blob/main/accounts/views.py): `accounts/views.py`
- [User records](https://github.com/salmakhalill/secure-report/blob/main/accounts/models.py): `accounts/models.py`
- [Account serialization](https://github.com/salmakhalill/secure-report/blob/main/accounts/serializers.py): `accounts/serializers.py`
- [Role permissions](https://github.com/salmakhalill/secure-report/blob/main/accounts/permissions.py): `accounts/permissions.py`
- [Reset token helpers](https://github.com/salmakhalill/secure-report/blob/main/accounts/services/auth_service.py): `accounts/services/auth_service.py`
- [Email delivery](https://github.com/salmakhalill/secure-report/blob/main/accounts/services/email_service.py): `accounts/services/email_service.py`

### Analytics

- [Analytics endpoints](https://github.com/salmakhalill/secure-report/blob/main/analytics/views.py): `analytics/views.py`
- [KPI and chart processing](https://github.com/salmakhalill/secure-report/blob/main/analytics/utils.py): `analytics/utils.py`

### API and persistence

- [Root API routing](https://github.com/salmakhalill/secure-report/blob/main/config/urls.py): `config/urls.py`
- [Application configuration](https://github.com/salmakhalill/secure-report/blob/main/config/settings.py): `config/settings.py`

### Other components

- **Public reporter**
- **Authority staff**
- **SendGrid**
- **React API clients**

## Connections

- Public reporter → Report endpoints: submits reports (evidence: `README.md`)
- Report endpoints → Report serialization: serializes requests (evidence: `reports/views.py`)
- Report serialization → Cases and evidence: creates cases (evidence: `reports/serializers.py`)
- Report endpoints → Cases and evidence: queries cases (evidence: `reports/views.py`)
- Public reporter → Tracking lookup: tracks code (evidence: `README.md`)
- Tracking lookup → Cases and evidence: looks up code (evidence: `reports/views.py`)
- Authority staff → Report endpoints: manages cases (evidence: `README.md`)
- Authority staff → Archive cases: views archive (evidence: `README.md`)
- Archive cases → Cases and evidence: filters closed cases (evidence: `reports/views.py`)
- Report endpoints → Arabic severity model: may classify severity (evidence: `README.md`)
- React API clients → Account endpoints: authenticates (evidence: `README.md`)
- Authority staff → Account endpoints: manages accounts (evidence: `README.md`)
- Account endpoints → Account serialization: validates account data (evidence: `accounts/views.py`)
- Account serialization → User records: creates and updates (evidence: `accounts/serializers.py`)
- Account endpoints → User records: queries users (evidence: `accounts/views.py`)
- Account endpoints → Role permissions: checks access (evidence: `accounts/views.py`)
- Account endpoints → Email delivery: sends reset email (evidence: `accounts/views.py`)
- Account endpoints → Reset token helpers: resolves reset user (evidence: `accounts/views.py`)
- Email delivery → SendGrid: sends messages (evidence: `accounts/services/email_service.py`)
- React API clients → Analytics endpoints: requests dashboards (evidence: `README.md`)
- Analytics endpoints → KPI and chart processing: computes dashboard data (evidence: `analytics/views.py`)
- KPI and chart processing → Cases and evidence: reads report data (evidence: `analytics/utils.py`)
- React API clients → Root API routing: calls REST API (evidence: `README.md`)
- Root API routing → Report endpoints: routes report requests
- Root API routing → Account endpoints: routes account requests
- Root API routing → Analytics endpoints: routes analytics requests
