# kethan1712/lexassist-ai architecture

> Architecture diagram of the GitHub repository kethan1712/lexassist-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kethan1712/lexassist-ai
- Repository: https://github.com/kethan1712/lexassist-ai

## Overview

LexAssist is a legal-information retrieval application: users submit natural-language queries and receive ranked statute results; its documented broader workflow routes questions to local, uploaded-document, or external evidence before generating grounded answers. The tree and excerpts show the statute-search UI and document-processing/search utilities, but not the README-named chat modules. Those documented capabilities are included with null paths; links to them rely on the README rather than sampled implementation.

Main entry points: [`app.py`](https://github.com/kethan1712/lexassist-ai/blob/main/app.py) (Flask search), [`data/document_chunks.json`](https://github.com/kethan1712/lexassist-ai/blob/main/data/document_chunks.json) (Document chunks), [`templates/index.html`](https://github.com/kethan1712/lexassist-ai/blob/main/templates/index.html) (Search page), [`document_preprocessor.py`](https://github.com/kethan1712/lexassist-ai/blob/main/document_preprocessor.py) (Text preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_web["Search page<br/>[index.html]"]
  node_flask["Flask search<br/>[app.py]"]
  node_ranked["Ranked provisions<br/>[app.py]"]
end

subgraph group_retrieval["Legal retrieval"]
  node_embed["Query embeddings<br/>[app.py]"]
  node_statute_index[("Statute vectors<br/>[statutes.faiss]")]
  node_statute_meta[("Statute metadata")]
  node_case_data[("Case results<br/>[case_results.json]")]
end

subgraph group_documents["Document evidence"]
  node_raw_docs["Legal PDFs"]
  node_preprocess["Text preprocessing"]
  node_chunks["Chunk generation"]
  node_chunk_data[("Document chunks")]
  node_statute_doc_search["Document statute search"]
  node_precedent_doc_search["Document precedent search"]
  node_summary["Document summaries"]
end

subgraph group_conversation["Conversational research"]
  node_router["Chatbot router"]
  node_local_evidence["Local evidence"]
  node_uploaded_evidence["Uploaded evidence"]
  node_external_research["External research"]
  node_answer["Answer generation"]
  node_history[("Conversation history")]
end

node_user(("User"))
node_india_code{{"India Code API"}}
node_gemini{{"Gemini"}}

node_user -->|"submits query"| node_web
node_web -->|"posts form"| node_flask
node_flask -->|"encodes query"| node_embed
node_flask -->|"searches vectors"| node_statute_index
node_flask -->|"resolves results"| node_statute_meta
node_flask -->|"loads cases"| node_case_data
node_flask -->|"renders results"| node_ranked
node_raw_docs -.->|"processes text"| node_preprocess
node_preprocess -.->|"prepares pages"| node_chunks
node_chunks -->|"writes chunks"| node_chunk_data
node_chunk_data -->|"supplies chunks"| node_statute_doc_search
node_chunk_data -->|"supplies chunks"| node_precedent_doc_search
node_chunk_data -->|"supplies chunks"| node_summary
node_user -->|"asks question"| node_router
node_history -->|"provides context"| node_router
node_router -->|"routes local search"| node_local_evidence
node_router -->|"routes document search"| node_uploaded_evidence
node_router -->|"routes external search"| node_external_research
node_external_research -->|"queries API"| node_india_code
node_local_evidence -->|"supplies evidence"| node_answer
node_uploaded_evidence -->|"supplies evidence"| node_answer
node_external_research -->|"supplies evidence"| node_answer
node_answer -->|"generates response"| node_gemini
node_answer -->|"returns answer"| node_user

click node_web "https://github.com/kethan1712/lexassist-ai/blob/main/templates/index.html"
click node_flask "https://github.com/kethan1712/lexassist-ai/blob/main/app.py"
click node_embed "https://github.com/kethan1712/lexassist-ai/blob/main/app.py"
click node_statute_index "https://github.com/kethan1712/lexassist-ai/blob/main/data/statutes.faiss"
click node_statute_meta "https://github.com/kethan1712/lexassist-ai/blob/main/data/statutes_metadata.json"
click node_case_data "https://github.com/kethan1712/lexassist-ai/blob/main/data/case_results.json"
click node_ranked "https://github.com/kethan1712/lexassist-ai/blob/main/app.py"
click node_raw_docs "https://github.com/kethan1712/lexassist-ai/tree/main/documents/raw"
click node_preprocess "https://github.com/kethan1712/lexassist-ai/blob/main/document_preprocessor.py"
click node_chunks "https://github.com/kethan1712/lexassist-ai/blob/main/document_chunker.py"
click node_chunk_data "https://github.com/kethan1712/lexassist-ai/blob/main/data/document_chunks.json"
click node_statute_doc_search "https://github.com/kethan1712/lexassist-ai/blob/main/document_statute_search.py"
click node_precedent_doc_search "https://github.com/kethan1712/lexassist-ai/blob/main/document_precedent_search.py"
click node_summary "https://github.com/kethan1712/lexassist-ai/blob/main/document_summarizer.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_web,node_flask,node_ranked,node_user toneBlue
class node_embed,node_statute_index,node_statute_meta,node_case_data toneAmber
class node_raw_docs,node_preprocess,node_chunks,node_chunk_data,node_statute_doc_search,node_precedent_doc_search,node_summary,node_india_code toneMint
class node_router,node_local_evidence,node_uploaded_evidence,node_external_research,node_answer,node_history toneRose
class node_gemini toneIndigo
```

## Components

### User interface

- [Search page](https://github.com/kethan1712/lexassist-ai/blob/main/templates/index.html): `templates/index.html`
- [Flask search](https://github.com/kethan1712/lexassist-ai/blob/main/app.py): `app.py`
- [Ranked provisions](https://github.com/kethan1712/lexassist-ai/blob/main/app.py): `app.py`

### Legal retrieval

- [Query embeddings](https://github.com/kethan1712/lexassist-ai/blob/main/app.py): `app.py`
- [Statute vectors](https://github.com/kethan1712/lexassist-ai/blob/main/data/statutes.faiss): `data/statutes.faiss`
- [Statute metadata](https://github.com/kethan1712/lexassist-ai/blob/main/data/statutes_metadata.json): `data/statutes_metadata.json`
- [Case results](https://github.com/kethan1712/lexassist-ai/blob/main/data/case_results.json): `data/case_results.json`

### Document evidence

- [Legal PDFs](https://github.com/kethan1712/lexassist-ai/tree/main/documents/raw): `documents/raw`
- [Text preprocessing](https://github.com/kethan1712/lexassist-ai/blob/main/document_preprocessor.py): `document_preprocessor.py`
- [Chunk generation](https://github.com/kethan1712/lexassist-ai/blob/main/document_chunker.py): `document_chunker.py`
- [Document chunks](https://github.com/kethan1712/lexassist-ai/blob/main/data/document_chunks.json): `data/document_chunks.json`
- [Document statute search](https://github.com/kethan1712/lexassist-ai/blob/main/document_statute_search.py): `document_statute_search.py`
- [Document precedent search](https://github.com/kethan1712/lexassist-ai/blob/main/document_precedent_search.py): `document_precedent_search.py`
- [Document summaries](https://github.com/kethan1712/lexassist-ai/blob/main/document_summarizer.py): `document_summarizer.py`

### Conversational research

- **Chatbot router**
- **Local evidence**
- **Uploaded evidence**
- **External research**
- **Answer generation**
- **Conversation history**

### Other components

- **User**
- **India Code API**
- **Gemini**

## Connections

- User → Search page: submits query (evidence: `README.md`)
- Search page → Flask search: posts form (evidence: `app.py`)
- Flask search → Query embeddings: encodes query (evidence: `app.py`)
- Flask search → Statute vectors: searches vectors (evidence: `app.py`)
- Flask search → Statute metadata: resolves results (evidence: `app.py`)
- Flask search → Case results: loads cases (evidence: `app.py`)
- Flask search → Ranked provisions: renders results (evidence: `app.py`)
- Legal PDFs → Text preprocessing: processes text
- Text preprocessing → Chunk generation: prepares pages
- Chunk generation → Document chunks: writes chunks (evidence: `document_chunker.py`)
- Document chunks → Document statute search: supplies chunks (evidence: `document_statute_search.py`)
- Document chunks → Document precedent search: supplies chunks (evidence: `document_precedent_search.py`)
- Document chunks → Document summaries: supplies chunks (evidence: `document_summarizer.py`)
- User → Chatbot router: asks question (evidence: `README.md`)
- Conversation history → Chatbot router: provides context (evidence: `README.md`)
- Chatbot router → Local evidence: routes local search (evidence: `README.md`)
- Chatbot router → Uploaded evidence: routes document search (evidence: `README.md`)
- Chatbot router → External research: routes external search (evidence: `README.md`)
- External research → India Code API: queries API (evidence: `README.md`)
- Local evidence → Answer generation: supplies evidence (evidence: `README.md`)
- Uploaded evidence → Answer generation: supplies evidence (evidence: `README.md`)
- External research → Answer generation: supplies evidence (evidence: `README.md`)
- Answer generation → Gemini: generates response (evidence: `README.md`)
- Answer generation → User: returns answer (evidence: `README.md`)
