# nani381c/crime-prediction-using-machine-learning architecture

> Architecture diagram of the GitHub repository nani381c/crime-prediction-using-machine-learning, 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/nani381c/crime-prediction-using-machine-learning
- Repository: https://github.com/nani381c/crime-prediction-using-machine-learning

## Overview

This is a Streamlit dashboard for analyzing crime data in India, forecasting city-level crime, and visualizing hotspots and risk. Users upload a dataset or request NCRB data, then explore forecasts, classification, maps, and comparisons. The graph separates ingestion, modeling, spatial visualization, and dashboard responsibilities. The excerpts show the main preprocessing, forecasting, and classifier calls; some other dashboard integrations are supported by the SOURCE INDEX and README rather than full call-site excerpts.

Main entry points: [`streamlit_app.py`](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py) (Streamlit dashboard), [`data_prep.py`](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/data_prep.py) (Dataset ingestion), [`model_lstm.py`](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/model_lstm.py) (Crime forecasting), [`classifier_model.py`](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/classifier_model.py) (Crime classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_app["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_analytics["State analytics<br/>[streamlit_app.py]"]
  node_compare["City comparison<br/>[streamlit_app.py]"]
  node_riskmap["Live risk mapping<br/>[streamlit_app.py]"]
  node_animated["Animated crime map<br/>[streamlit_app.py]"]
end

subgraph group_data["Data preparation"]
  node_ingest["Dataset ingestion<br/>[data_prep.py]"]
end

subgraph group_models["Analysis models"]
  node_forecast["Crime forecasting<br/>[model_lstm.py]"]
  node_classifier["Crime classifier"]
  node_explain["Forecast explanations<br/>[shap_explainer.py]"]
end

subgraph group_maps["Spatial visualization"]
  node_hotspots["Hotspot and risk maps<br/>[hotspot_cluster.py]"]
  node_geo["City geodata builder<br/>[visuals_map.py]"]
end

node_user(("Dashboard user"))
node_ncrb["NCRB data portal"]

node_user -->|"uses"| node_app
node_ncrb -->|"provides data"| node_app
node_app -->|"preprocesses uploads"| node_ingest
node_app -->|"trains forecast"| node_forecast
node_app -->|"trains classifier"| node_classifier
node_app -->|"generates hotspots"| node_hotspots
node_app -->|"builds map data"| node_geo
node_app -->|"requests explanations"| node_explain
node_app -->|"presents analytics"| node_analytics
node_app -->|"compares cities"| node_compare
node_app -->|"renders risk map"| node_riskmap
node_app -->|"renders animation"| node_animated

click node_app "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py"
click node_ingest "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/data_prep.py"
click node_forecast "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/model_lstm.py"
click node_classifier "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/classifier_model.py"
click node_explain "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/shap_explainer.py"
click node_hotspots "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/hotspot_cluster.py"
click node_geo "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/visuals_map.py"
click node_analytics "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py"
click node_compare "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py"
click node_riskmap "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py"
click node_animated "https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.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_app,node_analytics,node_compare,node_riskmap,node_animated,node_user toneBlue
class node_ingest toneAmber
class node_forecast,node_classifier,node_explain toneMint
class node_hotspots,node_geo toneRose
class node_ncrb toneIndigo
```

## Components

### Dashboard

- [Streamlit dashboard](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py): `streamlit_app.py`
- [State analytics](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py): `streamlit_app.py`
- [City comparison](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py): `streamlit_app.py`
- [Live risk mapping](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py): `streamlit_app.py`
- [Animated crime map](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/streamlit_app.py): `streamlit_app.py`

### Data preparation

- [Dataset ingestion](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/data_prep.py): `data_prep.py`

### Analysis models

- [Crime forecasting](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/model_lstm.py): `model_lstm.py`
- [Crime classifier](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/classifier_model.py): `classifier_model.py`
- [Forecast explanations](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/shap_explainer.py): `shap_explainer.py`

### Spatial visualization

- [Hotspot and risk maps](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/hotspot_cluster.py): `hotspot_cluster.py`
- [City geodata builder](https://github.com/nani381c/crime-prediction-using-machine-learning/blob/main/visuals_map.py): `visuals_map.py`

### Other components

- **Dashboard user**
- **NCRB data portal**

## Connections

- Dashboard user → Streamlit dashboard: uses (evidence: `README.md`)
- NCRB data portal → Streamlit dashboard: provides data (evidence: `README.md`)
- Streamlit dashboard → Dataset ingestion: preprocesses uploads (evidence: `streamlit_app.py`)
- Streamlit dashboard → Crime forecasting: trains forecast (evidence: `streamlit_app.py`)
- Streamlit dashboard → Crime classifier: trains classifier (evidence: `streamlit_app.py`)
- Streamlit dashboard → Hotspot and risk maps: generates hotspots (evidence: `streamlit_app.py`)
- Streamlit dashboard → City geodata builder: builds map data (evidence: `streamlit_app.py`)
- Streamlit dashboard → Forecast explanations: requests explanations (evidence: `streamlit_app.py`)
- Streamlit dashboard → State analytics: presents analytics (evidence: `README.md`)
- Streamlit dashboard → City comparison: compares cities (evidence: `streamlit_app.py`)
- Streamlit dashboard → Live risk mapping: renders risk map (evidence: `README.md`)
- Streamlit dashboard → Animated crime map: renders animation (evidence: `streamlit_app.py`)
