# harsh8968/legal-scan architecture

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

- Interactive diagram: https://gitdiagram.com/harsh8968/legal-scan
- Repository: https://github.com/harsh8968/legal-scan

## Overview

Legal-Scan is a Flask-based Indian legal-aid app. Users can register, describe an incident for IPC matches, explore legal guidance, ask AI questions, and draft FIR documents; signed-in users can also review prediction history and dashboard statistics. The main request handling and integrations are in app.py. The excerpts show those responsibilities but omit some route bodies, so uncertain internal call links are left out.

Main entry points: [`app.py`](https://github.com/harsh8968/legal-scan/blob/main/app.py) (Flask routes), [`templates/login.html`](https://github.com/harsh8968/legal-scan/blob/main/templates/login.html) (Account pages), [`templates/register.html`](https://github.com/harsh8968/legal-scan/blob/main/templates/register.html) (Registration page), [`templates/dashboard.html`](https://github.com/harsh8968/legal-scan/blob/main/templates/dashboard.html) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and accounts"]
  node_authui["Account pages<br/>[login.html]"]
  node_registerui["Registration page<br/>[register.html]"]
  node_dashboardui["Dashboard<br/>[dashboard.html]"]
  node_historyui["Prediction history<br/>[history.html]"]
end

subgraph group_guidance["Legal guidance"]
  node_issueui["Issue description"]
  node_matchesui["IPC matches<br/>[issue_results.html]"]
  node_ipcui["IPC details<br/>[ipc_details.html]"]
  node_ipcdata["IPC reference data<br/>[ipc_data.py]"]
  node_predictui["Crime prediction<br/>[predict.html]"]
  node_model["Crime model<br/>[crime_model.pkl]"]
  node_adviceui["AI advice<br/>[ai_advice.html]"]
end

subgraph group_documents["Document drafting"]
  node_firui["FIR document form"]
  node_pdf["FIR PDF output<br/>[app.py]"]
end

subgraph group_platform["Application and data"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_store[("SQLite data")]
end

node_visitor(("User"))
node_gemini["Gemini API"]

node_visitor -->|"submits requests"| node_webapp
node_webapp -->|"renders"| node_authui
node_webapp -->|"renders"| node_registerui
node_webapp -->|"renders"| node_dashboardui
node_webapp -->|"renders"| node_historyui
node_webapp -->|"reads and writes"| node_store
node_webapp -->|"renders"| node_issueui
node_webapp -->|"matches sections"| node_ipcdata
node_webapp -->|"renders results"| node_matchesui
node_webapp -->|"renders details"| node_ipcui
node_webapp -->|"loads for prediction"| node_model
node_webapp -->|"renders"| node_predictui
node_webapp -->|"renders"| node_adviceui
node_webapp -->|"requests guidance"| node_gemini
node_webapp -->|"renders"| node_firui
node_webapp -->|"requests FIR draft"| node_gemini
node_webapp -->|"generates PDF"| node_pdf

click node_webapp "https://github.com/harsh8968/legal-scan/blob/main/app.py"
click node_authui "https://github.com/harsh8968/legal-scan/blob/main/templates/login.html"
click node_registerui "https://github.com/harsh8968/legal-scan/blob/main/templates/register.html"
click node_dashboardui "https://github.com/harsh8968/legal-scan/blob/main/templates/dashboard.html"
click node_historyui "https://github.com/harsh8968/legal-scan/blob/main/templates/history.html"
click node_issueui "https://github.com/harsh8968/legal-scan/blob/main/templates/describe_issue.html"
click node_matchesui "https://github.com/harsh8968/legal-scan/blob/main/templates/issue_results.html"
click node_ipcui "https://github.com/harsh8968/legal-scan/blob/main/templates/ipc_details.html"
click node_ipcdata "https://github.com/harsh8968/legal-scan/blob/main/ipc_data.py"
click node_predictui "https://github.com/harsh8968/legal-scan/blob/main/templates/predict.html"
click node_model "https://github.com/harsh8968/legal-scan/blob/main/crime_model.pkl"
click node_adviceui "https://github.com/harsh8968/legal-scan/blob/main/templates/ai_advice.html"
click node_firui "https://github.com/harsh8968/legal-scan/blob/main/templates/generate_document.html"
click node_pdf "https://github.com/harsh8968/legal-scan/blob/main/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_authui,node_registerui,node_dashboardui,node_historyui,node_visitor toneBlue
class node_issueui,node_matchesui,node_ipcui,node_ipcdata,node_predictui,node_model,node_adviceui toneAmber
class node_firui,node_pdf,node_gemini toneMint
class node_webapp,node_store toneRose
```

## Components

### Access and accounts

- [Account pages](https://github.com/harsh8968/legal-scan/blob/main/templates/login.html): `templates/login.html`
- [Registration page](https://github.com/harsh8968/legal-scan/blob/main/templates/register.html): `templates/register.html`
- [Dashboard](https://github.com/harsh8968/legal-scan/blob/main/templates/dashboard.html): `templates/dashboard.html`
- [Prediction history](https://github.com/harsh8968/legal-scan/blob/main/templates/history.html): `templates/history.html`

### Legal guidance

- [Issue description](https://github.com/harsh8968/legal-scan/blob/main/templates/describe_issue.html): `templates/describe_issue.html`
- [IPC matches](https://github.com/harsh8968/legal-scan/blob/main/templates/issue_results.html): `templates/issue_results.html`
- [IPC details](https://github.com/harsh8968/legal-scan/blob/main/templates/ipc_details.html): `templates/ipc_details.html`
- [IPC reference data](https://github.com/harsh8968/legal-scan/blob/main/ipc_data.py): `ipc_data.py`
- [Crime prediction](https://github.com/harsh8968/legal-scan/blob/main/templates/predict.html): `templates/predict.html`
- [Crime model](https://github.com/harsh8968/legal-scan/blob/main/crime_model.pkl): `crime_model.pkl`
- [AI advice](https://github.com/harsh8968/legal-scan/blob/main/templates/ai_advice.html): `templates/ai_advice.html`

### Document drafting

- [FIR document form](https://github.com/harsh8968/legal-scan/blob/main/templates/generate_document.html): `templates/generate_document.html`
- [FIR PDF output](https://github.com/harsh8968/legal-scan/blob/main/app.py): `app.py`

### Application and data

- [Flask routes](https://github.com/harsh8968/legal-scan/blob/main/app.py): `app.py`
- **SQLite data**

### Other components

- **User**
- **Gemini API**

## Connections

- User → Flask routes: submits requests
- Flask routes → Account pages: renders
- Flask routes → Registration page: renders
- Flask routes → Dashboard: renders
- Flask routes → Prediction history: renders
- Flask routes → SQLite data: reads and writes
- Flask routes → Issue description: renders
- Flask routes → IPC reference data: matches sections
- Flask routes → IPC matches: renders results
- Flask routes → IPC details: renders details
- Flask routes → Crime model: loads for prediction
- Flask routes → Crime prediction: renders
- Flask routes → AI advice: renders
- Flask routes → Gemini API: requests guidance
- Flask routes → FIR document form: renders
- Flask routes → Gemini API: requests FIR draft
- Flask routes → FIR PDF output: generates PDF
