# kushalkush7/cognitive-crime-analysis001 architecture

> Architecture diagram of the GitHub repository kushalkush7/cognitive-crime-analysis001, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kushalkush7/cognitive-crime-analysis001
- Repository: https://github.com/kushalkush7/cognitive-crime-analysis001

## Overview

Crime Analysis is a Flask application for exploring Indian crime data and producing analytical and operational outputs. Users enter through the web application: routes serve analytics and case workflows, while selected endpoints invoke FIR briefing, modus-operandi search, and beat patrol planning. The README also describes hotspot clustering, district-trend and IPC-crime predictions, national forecasts, interactive visualizations, and a crime-news heatmap. The sampled excerpts establish several newer endpoint calls; some README-described analytics links are shown as unverified because their implementation was not sampled.

Main entry points: [`app.py`](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/app.py) (Flask entry), [`Datasets`](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Datasets) (Crime datasets), [`routes.py`](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/routes.py) (Analytics routes), [`templates`](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/templates) (Interactive visualizations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask entry<br/>[app.py]"]
  node_routes["Analytics routes<br/>[routes.py]"]
  node_views["Web dashboards"]
  node_cdrui["CDR dashboard<br/>[cdr_dashboard.js]"]
end

subgraph group_case["Case intelligence"]
  node_fir["FIR extraction<br/>[case_parser.py]"]
  node_brief["Case briefing"]
  node_cdr["CDR analysis"]
  node_vector["MO vector search"]
  node_vectorstore[("Persistent vector store")]
end

subgraph group_analytics["Crime analytics"]
  node_crime_data[("Crime datasets")]
  node_hotspots["District hotspots"]
  node_cluster_model["K-means clustering"]
  node_trend_model["Cluster trend prediction"]
  node_state_model["State IPC regression"]
  node_forecast["National forecasts"]
  node_visuals["Interactive visualizations"]
end

subgraph group_geo["Spatial intelligence"]
  node_news_scraper["Crime news scraping<br/>[scrapper4.py]"]
  node_heatmap["News heatmap<br/>[index.py]"]
  node_beat["Beat route planning"]
end

node_user(("Analyst or officer"))
node_geocoder["Geocoding service"]

node_user -->|"submits requests"| node_flask
node_flask -->|"uses routes"| node_routes
node_routes -->|"imports parser"| node_fir
node_flask -->|"generates briefs"| node_brief
node_flask -->|"searches cases"| node_vector
node_vector -->|"queries records"| node_vectorstore
node_flask -->|"generates routes"| node_beat
node_routes -.->|"renders dashboards"| node_views
node_user -.->|"submits call data"| node_cdrui
node_cdrui -.->|"requests analysis"| node_routes
node_crime_data -.->|"informs clustering"| node_cluster_model
node_cluster_model -.->|"identifies zones"| node_hotspots
node_crime_data -.->|"provides crime history"| node_trend_model
node_trend_model -.->|"predicts cluster trends"| node_hotspots
node_crime_data -.->|"provides crime history"| node_state_model
node_state_model -.->|"supports state predictions"| node_visuals
node_crime_data -.->|"provides crime history"| node_forecast
node_forecast -.->|"feeds forecasts"| node_visuals
node_visuals -.->|"presents analysis"| node_user
node_news_scraper -->|"supplies headlines"| node_heatmap
node_heatmap -->|"geocodes cities"| node_geocoder

click node_flask "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/app.py"
click node_routes "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/routes.py"
click node_views "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/templates"
click node_fir "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/case_parser.py"
click node_brief "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/case_briefing_copilot.py"
click node_cdr "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/cdr_intelligence.py"
click node_cdrui "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/static/javascript/cdr_dashboard.js"
click node_vector "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/mo_vector_service.py"
click node_crime_data "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Datasets"
click node_hotspots "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction"
click node_cluster_model "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction"
click node_trend_model "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction"
click node_state_model "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction"
click node_forecast "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction"
click node_visuals "https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/templates"
click node_news_scraper "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/folium-map/scrapper4.py"
click node_heatmap "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/folium-map/index.py"
click node_beat "https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/spatial_beat_engine.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_flask,node_routes,node_views,node_cdrui toneBlue
class node_fir,node_brief,node_cdr,node_vector,node_vectorstore toneAmber
class node_crime_data,node_hotspots,node_cluster_model,node_trend_model,node_state_model,node_forecast,node_visuals toneMint
class node_news_scraper,node_heatmap,node_beat toneRose
class node_user,node_geocoder toneIndigo
```

## Components

### Web application

- [Flask entry](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/app.py): `app.py`
- [Analytics routes](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/routes.py): `routes.py`
- [Web dashboards](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/templates): `templates`
- [CDR dashboard](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/static/javascript/cdr_dashboard.js): `static/javascript/cdr_dashboard.js`

### Case intelligence

- [FIR extraction](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/case_parser.py): `case_parser.py`
- [Case briefing](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/case_briefing_copilot.py): `case_briefing_copilot.py`
- [CDR analysis](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/cdr_intelligence.py): `cdr_intelligence.py`
- [MO vector search](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/mo_vector_service.py): `mo_vector_service.py`
- **Persistent vector store**

### Crime analytics

- [Crime datasets](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Datasets): `Datasets`
- [District hotspots](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction): `Prediction`
- [K-means clustering](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction): `Prediction`
- [Cluster trend prediction](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction): `Prediction`
- [State IPC regression](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction): `Prediction`
- [National forecasts](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/Prediction): `Prediction`
- [Interactive visualizations](https://github.com/kushalkush7/cognitive-crime-analysis001/tree/main/templates): `templates`

### Spatial intelligence

- [Crime news scraping](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/folium-map/scrapper4.py): `folium-map/scrapper4.py`
- [News heatmap](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/folium-map/index.py): `folium-map/index.py`
- [Beat route planning](https://github.com/kushalkush7/cognitive-crime-analysis001/blob/main/spatial_beat_engine.py): `spatial_beat_engine.py`

### Other components

- **Analyst or officer**
- **Geocoding service**

## Connections

- Analyst or officer → Flask entry: submits requests (evidence: `app.py`)
- Flask entry → Analytics routes: uses routes (evidence: `app.py`)
- Analytics routes → FIR extraction: imports parser (evidence: `routes.py`)
- Flask entry → Case briefing: generates briefs (evidence: `app.py`)
- Flask entry → MO vector search: searches cases (evidence: `app.py`)
- MO vector search → Persistent vector store: queries records (evidence: `mo_vector_service.py`)
- Flask entry → Beat route planning: generates routes (evidence: `app.py`)
- Analytics routes → Web dashboards: renders dashboards
- Analyst or officer → CDR dashboard: submits call data
- CDR dashboard → Analytics routes: requests analysis
- Crime datasets → K-means clustering: informs clustering (evidence: `README.md`)
- K-means clustering → District hotspots: identifies zones (evidence: `README.md`)
- Crime datasets → Cluster trend prediction: provides crime history (evidence: `README.md`)
- Cluster trend prediction → District hotspots: predicts cluster trends (evidence: `README.md`)
- Crime datasets → State IPC regression: provides crime history (evidence: `README.md`)
- State IPC regression → Interactive visualizations: supports state predictions (evidence: `README.md`)
- Crime datasets → National forecasts: provides crime history (evidence: `README.md`)
- National forecasts → Interactive visualizations: feeds forecasts (evidence: `README.md`)
- Interactive visualizations → Analyst or officer: presents analysis (evidence: `README.md`)
- Crime news scraping → News heatmap: supplies headlines (evidence: `folium-map/index.py`)
- News heatmap → Geocoding service: geocodes cities (evidence: `folium-map/index.py`)
