# parmesh214/verdictai architecture

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

- Interactive diagram: https://gitdiagram.com/parmesh214/verdictai
- Repository: https://github.com/parmesh214/verdictai

## Overview

VerdictAI is a web-based Indian legal research and advisory platform. Its principal workflow takes a user query through the frontend and API, searches legal acts, judgments, and reports, then uses retrieved context to generate a response with sources. A separate ingestion branch prepares those legal collections for search. The README documents the broad workflow and capabilities; sampled excerpts confirm selected route, search, RAG, ingestion, and storage relationships. Some unsampled integrations and frontend wiring are therefore left unconnected.

Main entry points: [`backend/app/db/vector_store.py`](https://github.com/parmesh214/verdictai/blob/main/backend/app/db/vector_store.py) (HNSW vector store), [`backend/app/api/routes.py`](https://github.com/parmesh214/verdictai/blob/main/backend/app/api/routes.py) (API query handler), [`backend/app/ingestion/acts_ingest.py`](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/acts_ingest.py) (Acts ingestion), [`backend/app/services/enhanced_legal_search.py`](https://github.com/parmesh214/verdictai/blob/main/backend/app/services/enhanced_legal_search.py) (Cross-source search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_web["Web interface"]
  node_legacy_ui["Web entry page<br/>[index.tsx]"]
end

subgraph group_api["Query API"]
  node_api_route["Enhanced query routes<br/>[enhanced_query.py]"]
  node_nlp_route["NLP query routes<br/>[nlp_query.py]"]
  node_query_route["Query routes<br/>[query.py]"]
  node_basic_api["API query handler<br/>[routes.py]"]
end

subgraph group_research["Legal research"]
  node_pipeline["RAG pipeline"]
  node_search["Cross-source search"]
  node_conversation["Conversational responses"]
  node_llm["LLM service<br/>[llm_service.py]"]
end

subgraph group_corpus["Legal corpus"]
  node_acts_ingest["Acts ingestion<br/>[acts_ingest.py]"]
  node_judgments_ingest["Judgment ingestion"]
  node_reports_ingest["Reports ingestion<br/>[reports_ingest.py]"]
  node_unified_ingest["Unified ingestion"]
  node_ingest_common["Document processing<br/>[common.py]"]
  node_acts_catalog["Acts catalog<br/>[acts_collection.py]"]
  node_report_sources["Legal datasets"]
end

subgraph group_storage["Data and models"]
  node_vector_store[("HNSW vector store<br/>[vector_store.py]")]
  node_postgres[("PostgreSQL")]
end

node_user(("Legal researcher"))
node_legal_docs["Legal documents"]

node_user -->|"submits query"| node_web
node_web -->|"sends query"| node_api_route
node_api_route -->|"searches sources"| node_search
node_api_route -->|"requests response"| node_conversation
node_pipeline -->|"runs search"| node_search
node_pipeline -->|"generates answer"| node_conversation
node_search -->|"queries indexes"| node_vector_store
node_basic_api -->|"retrieves matches"| node_vector_store
node_basic_api -->|"stores query data"| node_postgres
node_basic_api -->|"stores response data"| node_basic_api
node_acts_ingest -->|"processes documents"| node_ingest_common
node_acts_ingest -->|"reads catalog"| node_acts_catalog
node_acts_ingest -->|"writes chunks"| node_vector_store
node_judgments_ingest -->|"processes judgments"| node_ingest_common
node_judgments_ingest -->|"writes chunks"| node_vector_store
node_reports_ingest -->|"processes reports"| node_ingest_common
node_reports_ingest -->|"writes chunks"| node_vector_store
node_unified_ingest -->|"dispatches ingestion"| node_acts_ingest
node_unified_ingest -->|"dispatches ingestion"| node_reports_ingest
node_unified_ingest -->|"loads datasets"| node_report_sources
node_vector_store -.->|"indexes documents"| node_legal_docs
node_nlp_route -->|"invokes pipeline"| node_pipeline
node_query_route -->|"uses search"| node_search
node_query_route -->|"uses responses"| node_conversation

click node_web "https://github.com/parmesh214/verdictai/tree/main/frontend/app"
click node_legacy_ui "https://github.com/parmesh214/verdictai/blob/main/frontend/pages/index.tsx"
click node_api_route "https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/enhanced_query.py"
click node_nlp_route "https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/nlp_query.py"
click node_query_route "https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/query.py"
click node_basic_api "https://github.com/parmesh214/verdictai/blob/main/backend/app/api/routes.py"
click node_pipeline "https://github.com/parmesh214/verdictai/blob/main/backend/app/services/enhanced_rag_pipeline.py"
click node_search "https://github.com/parmesh214/verdictai/blob/main/backend/app/services/enhanced_legal_search.py"
click node_conversation "https://github.com/parmesh214/verdictai/blob/main/backend/app/services/conversational_layer.py"
click node_llm "https://github.com/parmesh214/verdictai/blob/main/backend/app/services/llm_service.py"
click node_acts_ingest "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/acts_ingest.py"
click node_judgments_ingest "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/judgments_ingest.py"
click node_reports_ingest "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/reports_ingest.py"
click node_unified_ingest "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/unified_legal_ingest.py"
click node_ingest_common "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/common.py"
click node_acts_catalog "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/acts_collection.py"
click node_report_sources "https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/legal_datasets_loader.py"
click node_vector_store "https://github.com/parmesh214/verdictai/blob/main/backend/app/db/vector_store.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_legacy_ui toneBlue
class node_api_route,node_nlp_route,node_query_route,node_basic_api toneAmber
class node_pipeline,node_search,node_conversation,node_llm toneMint
class node_acts_ingest,node_judgments_ingest,node_reports_ingest,node_unified_ingest,node_ingest_common,node_acts_catalog,node_report_sources toneRose
class node_vector_store,node_postgres,node_user,node_legal_docs toneIndigo
```

## Components

### User experience

- [Web interface](https://github.com/parmesh214/verdictai/tree/main/frontend/app): `frontend/app`
- [Web entry page](https://github.com/parmesh214/verdictai/blob/main/frontend/pages/index.tsx): `frontend/pages/index.tsx`

### Query API

- [Enhanced query routes](https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/enhanced_query.py): `backend/app/routes/enhanced_query.py`
- [NLP query routes](https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/nlp_query.py): `backend/app/routes/nlp_query.py`
- [Query routes](https://github.com/parmesh214/verdictai/blob/main/backend/app/routes/query.py): `backend/app/routes/query.py`
- [API query handler](https://github.com/parmesh214/verdictai/blob/main/backend/app/api/routes.py): `backend/app/api/routes.py`

### Legal research

- [RAG pipeline](https://github.com/parmesh214/verdictai/blob/main/backend/app/services/enhanced_rag_pipeline.py): `backend/app/services/enhanced_rag_pipeline.py`
- [Cross-source search](https://github.com/parmesh214/verdictai/blob/main/backend/app/services/enhanced_legal_search.py): `backend/app/services/enhanced_legal_search.py`
- [Conversational responses](https://github.com/parmesh214/verdictai/blob/main/backend/app/services/conversational_layer.py): `backend/app/services/conversational_layer.py`
- [LLM service](https://github.com/parmesh214/verdictai/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`

### Legal corpus

- [Acts ingestion](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/acts_ingest.py): `backend/app/ingestion/acts_ingest.py`
- [Judgment ingestion](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/judgments_ingest.py): `backend/app/ingestion/judgments_ingest.py`
- [Reports ingestion](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/reports_ingest.py): `backend/app/ingestion/reports_ingest.py`
- [Unified ingestion](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/unified_legal_ingest.py): `backend/app/ingestion/unified_legal_ingest.py`
- [Document processing](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/common.py): `backend/app/ingestion/common.py`
- [Acts catalog](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/acts_collection.py): `backend/app/ingestion/acts_collection.py`
- [Legal datasets](https://github.com/parmesh214/verdictai/blob/main/backend/app/ingestion/legal_datasets_loader.py): `backend/app/ingestion/legal_datasets_loader.py`

### Data and models

- [HNSW vector store](https://github.com/parmesh214/verdictai/blob/main/backend/app/db/vector_store.py): `backend/app/db/vector_store.py`
- **PostgreSQL**

### Other components

- **Legal researcher**
- **Legal documents**

## Connections

- Legal researcher → Web interface: submits query (evidence: `README.md`)
- Web interface → Enhanced query routes: sends query (evidence: `README.md`)
- Enhanced query routes → Cross-source search: searches sources (evidence: `backend/app/routes/enhanced_query.py`)
- Enhanced query routes → Conversational responses: requests response (evidence: `backend/app/routes/enhanced_query.py`)
- RAG pipeline → Cross-source search: runs search (evidence: `backend/app/services/enhanced_rag_pipeline.py`)
- RAG pipeline → Conversational responses: generates answer (evidence: `backend/app/services/enhanced_rag_pipeline.py`)
- Cross-source search → HNSW vector store: queries indexes (evidence: `backend/app/services/enhanced_legal_search.py`)
- API query handler → HNSW vector store: retrieves matches (evidence: `backend/app/api/routes.py`)
- API query handler → PostgreSQL: stores query data (evidence: `backend/app/api/routes.py`)
- API query handler → API query handler: stores response data (evidence: `backend/app/api/routes.py`)
- Acts ingestion → Document processing: processes documents (evidence: `backend/app/ingestion/acts_ingest.py`)
- Acts ingestion → Acts catalog: reads catalog (evidence: `backend/app/ingestion/acts_ingest.py`)
- Acts ingestion → HNSW vector store: writes chunks (evidence: `backend/app/ingestion/acts_ingest.py`)
- Judgment ingestion → Document processing: processes judgments (evidence: `backend/app/ingestion/judgments_ingest.py`)
- Judgment ingestion → HNSW vector store: writes chunks (evidence: `backend/app/ingestion/judgments_ingest.py`)
- Reports ingestion → Document processing: processes reports (evidence: `backend/app/ingestion/reports_ingest.py`)
- Reports ingestion → HNSW vector store: writes chunks (evidence: `backend/app/ingestion/reports_ingest.py`)
- Unified ingestion → Acts ingestion: dispatches ingestion (evidence: `backend/app/ingestion/unified_legal_ingest.py`)
- Unified ingestion → Reports ingestion: dispatches ingestion (evidence: `backend/app/ingestion/unified_legal_ingest.py`)
- Unified ingestion → Legal datasets: loads datasets (evidence: `backend/app/ingestion/unified_legal_ingest.py`)
- HNSW vector store → Legal documents: indexes documents (evidence: `README.md`)
- NLP query routes → RAG pipeline: invokes pipeline (evidence: `backend/app/routes/nlp_query.py`)
- Query routes → Cross-source search: uses search (evidence: `backend/app/routes/query.py`)
- Query routes → Conversational responses: uses responses (evidence: `backend/app/routes/query.py`)
