# mubeen-zaki/crime_analysis architecture

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

- Interactive diagram: https://gitdiagram.com/mubeen-zaki/crime_analysis
- Repository: https://github.com/mubeen-zaki/crime_analysis

## Overview

Crime Analysis is a Flask application for exploring Indian crime data, identifying district hotspots, predicting future risk and crime counts, and viewing forecasts and visualizations. Users submit forms or choose dashboard views; Flask routes select data and prediction logic and return rendered pages. A separate news workflow scrapes crime headlines, geocodes mentioned cities, and generates a heatmap. The README documents additional forecasting and visualization capabilities; some implementation details were not sampled, so those links are cited to the README rather than treated as inspected source.

Main entry points: [`routes.py`](https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py) (Request routes), [`README.md`](https://github.com/mubeen-zaki/crime_analysis/blob/main/README.md) (District hotspots), [`folium-map/index.py`](https://github.com/mubeen-zaki/crime_analysis/blob/main/folium-map/index.py) (Location heatmap), [`Datasets`](https://github.com/mubeen-zaki/crime_analysis/tree/main/Datasets) (Crime datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask app<br/>[app.py]"]
  node_routes["Request routes<br/>[routes.py]"]
  node_pages["Web pages"]
  node_client["Dashboard scripts"]
end

subgraph group_analysis["Crime analysis"]
  node_hotspots["District hotspots<br/>[README.md]"]
  node_risk["Future zone risk<br/>[routes.py]"]
  node_state_prediction["State IPC prediction<br/>[routes.py]"]
  node_forecasts["Crime forecasts"]
  node_visualizations["Crime dashboards"]
  node_tables["Data tables<br/>[table.js]"]
end

subgraph group_data["Data and models"]
  node_crime_data[("Crime datasets")]
  node_models[("Prediction models")]
end

subgraph group_news["News heatmap"]
  node_scraper["Headline scraper<br/>[scrapper4.py]"]
  node_heatmap["Location heatmap<br/>[index.py]"]
  node_heatmap_page["Heatmap page<br/>[final.html]"]
end

node_visitor(("Dashboard user"))
node_geocoder(("Geocoding service"))

node_visitor -->|"uses"| node_flask
node_flask -->|"registers routes"| node_routes
node_routes -->|"renders"| node_pages
node_routes -->|"reads"| node_crime_data
node_routes -->|"loads models"| node_models
node_routes -->|"classifies risk"| node_risk
node_routes -->|"predicts IPC"| node_state_prediction
node_visitor -->|"requests hotspots"| node_hotspots
node_hotspots -.->|"clusters districts"| node_models
node_hotspots -.->|"uses past data"| node_crime_data
node_visitor -->|"views forecasts"| node_forecasts
node_forecasts -.->|"forecasts from data"| node_crime_data
node_visitor -->|"views charts"| node_visualizations
node_visitor -->|"requests tables"| node_tables
node_tables -->|"loads JSON"| node_client
node_scraper -->|"provides headlines"| node_heatmap
node_heatmap -->|"geocodes cities"| node_geocoder
node_heatmap -->|"writes map"| node_heatmap_page

click node_flask "https://github.com/mubeen-zaki/crime_analysis/blob/main/app.py"
click node_routes "https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py"
click node_pages "https://github.com/mubeen-zaki/crime_analysis/tree/main/templates"
click node_client "https://github.com/mubeen-zaki/crime_analysis/tree/main/static/javascript"
click node_crime_data "https://github.com/mubeen-zaki/crime_analysis/tree/main/Datasets"
click node_models "https://github.com/mubeen-zaki/crime_analysis/tree/main/Prediction"
click node_hotspots "https://github.com/mubeen-zaki/crime_analysis/blob/main/README.md"
click node_risk "https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py"
click node_state_prediction "https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py"
click node_forecasts "https://github.com/mubeen-zaki/crime_analysis/tree/main/Prediction"
click node_visualizations "https://github.com/mubeen-zaki/crime_analysis/tree/main/templates/plots"
click node_tables "https://github.com/mubeen-zaki/crime_analysis/blob/main/static/javascript/table.js"
click node_scraper "https://github.com/mubeen-zaki/crime_analysis/blob/main/folium-map/scrapper4.py"
click node_heatmap "https://github.com/mubeen-zaki/crime_analysis/blob/main/folium-map/index.py"
click node_heatmap_page "https://github.com/mubeen-zaki/crime_analysis/blob/main/templates/final.html"

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_pages,node_client,node_visitor toneBlue
class node_hotspots,node_risk,node_state_prediction,node_forecasts,node_visualizations,node_tables toneAmber
class node_crime_data,node_models toneMint
class node_scraper,node_heatmap,node_heatmap_page toneRose
class node_geocoder toneIndigo
```

## Components

### Web application

- [Flask app](https://github.com/mubeen-zaki/crime_analysis/blob/main/app.py): `app.py`
- [Request routes](https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py): `routes.py`
- [Web pages](https://github.com/mubeen-zaki/crime_analysis/tree/main/templates): `templates`
- [Dashboard scripts](https://github.com/mubeen-zaki/crime_analysis/tree/main/static/javascript): `static/javascript`

### Crime analysis

- [District hotspots](https://github.com/mubeen-zaki/crime_analysis/blob/main/README.md): `README.md`
- [Future zone risk](https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py): `routes.py`
- [State IPC prediction](https://github.com/mubeen-zaki/crime_analysis/blob/main/routes.py): `routes.py`
- [Crime forecasts](https://github.com/mubeen-zaki/crime_analysis/tree/main/Prediction): `Prediction`
- [Crime dashboards](https://github.com/mubeen-zaki/crime_analysis/tree/main/templates/plots): `templates/plots`
- [Data tables](https://github.com/mubeen-zaki/crime_analysis/blob/main/static/javascript/table.js): `static/javascript/table.js`

### Data and models

- [Crime datasets](https://github.com/mubeen-zaki/crime_analysis/tree/main/Datasets): `Datasets`
- [Prediction models](https://github.com/mubeen-zaki/crime_analysis/tree/main/Prediction): `Prediction`

### News heatmap

- [Headline scraper](https://github.com/mubeen-zaki/crime_analysis/blob/main/folium-map/scrapper4.py): `folium-map/scrapper4.py`
- [Location heatmap](https://github.com/mubeen-zaki/crime_analysis/blob/main/folium-map/index.py): `folium-map/index.py`
- [Heatmap page](https://github.com/mubeen-zaki/crime_analysis/blob/main/templates/final.html): `templates/final.html`

### Other components

- **Dashboard user**
- **Geocoding service**

## Connections

- Dashboard user → Flask app: uses (evidence: `README.md`)
- Flask app → Request routes: registers routes (evidence: `app.py`)
- Request routes → Web pages: renders (evidence: `routes.py`)
- Request routes → Crime datasets: reads (evidence: `routes.py`)
- Request routes → Prediction models: loads models (evidence: `routes.py`)
- Request routes → Future zone risk: classifies risk (evidence: `routes.py`)
- Request routes → State IPC prediction: predicts IPC (evidence: `routes.py`)
- Dashboard user → District hotspots: requests hotspots (evidence: `README.md`)
- District hotspots → Prediction models: clusters districts (evidence: `README.md`)
- District hotspots → Crime datasets: uses past data (evidence: `README.md`)
- Dashboard user → Crime forecasts: views forecasts (evidence: `README.md`)
- Crime forecasts → Crime datasets: forecasts from data (evidence: `README.md`)
- Dashboard user → Crime dashboards: views charts (evidence: `README.md`)
- Dashboard user → Data tables: requests tables (evidence: `static/javascript/table.js`)
- Data tables → Dashboard scripts: loads JSON (evidence: `static/javascript/table.js`)
- Headline scraper → Location heatmap: provides headlines (evidence: `folium-map/index.py`)
- Location heatmap → Geocoding service: geocodes cities (evidence: `folium-map/index.py`)
- Location heatmap → Heatmap page: writes map (evidence: `folium-map/index.py`)
