# greeshmakurivella29/nyayaroute architecture

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

- Interactive diagram: https://gitdiagram.com/greeshmakurivella29/nyayaroute
- Repository: https://github.com/greeshmakurivella29/nyayaroute

## Overview

NyayaRoute is a Streamlit workspace for evidence-constrained Indian legal research. A user asks a question; the research engine assesses and rewrites it when needed, routes retrieval, reranks evidence, checks sufficiency, then answers with citations or returns a no-answer outcome. The workspace also supports source filtering, source-library URL ingestion, PDF ingestion, audit details, authority cards, and Markdown memo export. The graph combines README-documented stages with relationships visible in excerpts and the source index; unsampled implementation details are not inferred.

Main entry points: [`rag_engine.py`](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py) (Research orchestration), [`pdf_ingestor.py`](https://github.com/greeshmakurivella29/nyayaroute/blob/main/pdf_ingestor.py) (PDF ingestion), [`app.py`](https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py) (Research UI), [`vector_store.py`](https://github.com/greeshmakurivella29/nyayaroute/blob/main/vector_store.py) (Vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Research workspace"]
  node_streamlit_ui["Research UI<br/>[app.py]"]
  node_memo["Memo export<br/>[app.py]"]
  node_audit_cards["Audit and authority cards<br/>[app.py]"]
end

subgraph group_research["Research pipeline"]
  node_engine["Research orchestration<br/>[rag_engine.py]"]
  node_quality["Query quality<br/>[rag_engine.py]"]
  node_rewrite_route["Rewrite and routing<br/>[rag_engine.py]"]
  node_retriever["BM25, vector, hybrid<br/>[rag_engine.py]"]
  node_live_search["Indian Kanoon search"]
  node_reranker["Cross-encoder reranking<br/>[rag_engine.py]"]
  node_evidence_gate["Evidence decision<br/>[rag_engine.py]"]
  node_answer_generation["Grounded answer<br/>[rag_engine.py]"]
end

subgraph group_sources["Source ingestion"]
  node_source_library["Source library<br/>[app.py]"]
  node_trusted_ingestion["Trusted URL ingestion<br/>[trusted_sources.py]"]
  node_pdf_upload["PDF ingestion<br/>[pdf_ingestor.py]"]
  node_pdf_parse["PDF parsing<br/>[pdf_parser.py]"]
  node_legal_chunking["Legal chunking<br/>[chunker.py]"]
  node_pdf_metadata["Document metadata<br/>[metadata.py]"]
end

subgraph group_index["Search index"]
  node_corpus[("Legal corpus")]
  node_vector_store[("Vector store<br/>[vector_store.py]")]
  node_embeddings["Text embeddings<br/>[embedding.py]"]
  node_faiss[("FAISS index<br/>[faiss_store.py]")]
  node_metadata_store[("Index metadata<br/>[metadata_store.py]")]
end

node_researcher(("Researcher"))
node_groq["Groq model service"]

node_researcher -->|"asks question"| node_streamlit_ui
node_streamlit_ui -->|"submits query"| node_engine
node_engine -->|"checks quality"| node_quality
node_engine -->|"rewrites and routes"| node_rewrite_route
node_engine -->|"retrieves candidates"| node_retriever
node_retriever -.->|"searches live"| node_live_search
node_retriever -->|"searches vectors"| node_vector_store
node_engine -->|"reranks candidates"| node_reranker
node_engine -->|"checks evidence"| node_evidence_gate
node_engine -->|"generates answer"| node_answer_generation
node_answer_generation -->|"requests completion"| node_groq
node_engine -->|"returns outcome"| node_streamlit_ui
node_streamlit_ui -->|"displays evidence audit"| node_audit_cards
node_streamlit_ui -->|"exports memo"| node_memo
node_researcher -->|"adds trusted source"| node_source_library
node_source_library -->|"ingests URL"| node_trusted_ingestion
node_trusted_ingestion -->|"appends chunks"| node_corpus
node_researcher -->|"uploads PDF"| node_pdf_upload
node_pdf_upload -->|"parses document"| node_pdf_parse
node_pdf_upload -->|"chunks text"| node_legal_chunking
node_pdf_upload -->|"classifies chunks"| node_pdf_metadata
node_pdf_upload -->|"appends records"| node_corpus
node_pdf_upload -->|"adds records"| node_vector_store
node_corpus -->|"loads corpus"| node_engine
node_vector_store -->|"embeds records"| node_embeddings
node_vector_store -->|"stores vectors"| node_faiss
node_vector_store -->|"stores record metadata"| node_metadata_store

click node_streamlit_ui "https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py"
click node_memo "https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py"
click node_audit_cards "https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py"
click node_engine "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_quality "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_rewrite_route "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_retriever "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_live_search "https://github.com/greeshmakurivella29/nyayaroute/blob/main/live_web_searcher.py"
click node_reranker "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_evidence_gate "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_answer_generation "https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py"
click node_source_library "https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py"
click node_trusted_ingestion "https://github.com/greeshmakurivella29/nyayaroute/blob/main/trusted_sources.py"
click node_pdf_upload "https://github.com/greeshmakurivella29/nyayaroute/blob/main/pdf_ingestor.py"
click node_pdf_parse "https://github.com/greeshmakurivella29/nyayaroute/blob/main/pdf_parser.py"
click node_legal_chunking "https://github.com/greeshmakurivella29/nyayaroute/blob/main/chunker.py"
click node_pdf_metadata "https://github.com/greeshmakurivella29/nyayaroute/blob/main/metadata.py"
click node_corpus "https://github.com/greeshmakurivella29/nyayaroute/tree/main/data"
click node_vector_store "https://github.com/greeshmakurivella29/nyayaroute/blob/main/vector_store.py"
click node_embeddings "https://github.com/greeshmakurivella29/nyayaroute/blob/main/embedding.py"
click node_faiss "https://github.com/greeshmakurivella29/nyayaroute/blob/main/faiss_store.py"
click node_metadata_store "https://github.com/greeshmakurivella29/nyayaroute/blob/main/metadata_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_streamlit_ui,node_memo,node_audit_cards toneBlue
class node_engine,node_quality,node_rewrite_route,node_retriever,node_live_search,node_reranker,node_evidence_gate,node_answer_generation toneAmber
class node_source_library,node_trusted_ingestion,node_pdf_upload,node_pdf_parse,node_legal_chunking,node_pdf_metadata toneMint
class node_corpus,node_vector_store,node_embeddings,node_faiss,node_metadata_store toneRose
class node_researcher,node_groq toneIndigo
```

## Components

### Research workspace

- [Research UI](https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py): `app.py`
- [Memo export](https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py): `app.py`
- [Audit and authority cards](https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py): `app.py`

### Research pipeline

- [Research orchestration](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [Query quality](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [Rewrite and routing](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [BM25, vector, hybrid](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [Indian Kanoon search](https://github.com/greeshmakurivella29/nyayaroute/blob/main/live_web_searcher.py): `live_web_searcher.py`
- [Cross-encoder reranking](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [Evidence decision](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`
- [Grounded answer](https://github.com/greeshmakurivella29/nyayaroute/blob/main/rag_engine.py): `rag_engine.py`

### Source ingestion

- [Source library](https://github.com/greeshmakurivella29/nyayaroute/blob/main/app.py): `app.py`
- [Trusted URL ingestion](https://github.com/greeshmakurivella29/nyayaroute/blob/main/trusted_sources.py): `trusted_sources.py`
- [PDF ingestion](https://github.com/greeshmakurivella29/nyayaroute/blob/main/pdf_ingestor.py): `pdf_ingestor.py`
- [PDF parsing](https://github.com/greeshmakurivella29/nyayaroute/blob/main/pdf_parser.py): `pdf_parser.py`
- [Legal chunking](https://github.com/greeshmakurivella29/nyayaroute/blob/main/chunker.py): `chunker.py`
- [Document metadata](https://github.com/greeshmakurivella29/nyayaroute/blob/main/metadata.py): `metadata.py`

### Search index

- [Legal corpus](https://github.com/greeshmakurivella29/nyayaroute/tree/main/data): `data`
- [Vector store](https://github.com/greeshmakurivella29/nyayaroute/blob/main/vector_store.py): `vector_store.py`
- [Text embeddings](https://github.com/greeshmakurivella29/nyayaroute/blob/main/embedding.py): `embedding.py`
- [FAISS index](https://github.com/greeshmakurivella29/nyayaroute/blob/main/faiss_store.py): `faiss_store.py`
- [Index metadata](https://github.com/greeshmakurivella29/nyayaroute/blob/main/metadata_store.py): `metadata_store.py`

### Other components

- **Researcher**
- **Groq model service**

## Connections

- Researcher → Research UI: asks question (evidence: `README.md`)
- Research UI → Research orchestration: submits query (evidence: `README.md`)
- Research orchestration → Query quality: checks quality (evidence: `README.md`)
- Research orchestration → Rewrite and routing: rewrites and routes (evidence: `README.md`)
- Research orchestration → BM25, vector, hybrid: retrieves candidates (evidence: `README.md`)
- BM25, vector, hybrid → Indian Kanoon search: searches live (evidence: `rag_engine.py`)
- BM25, vector, hybrid → Vector store: searches vectors (evidence: `vector_store.py`)
- Research orchestration → Cross-encoder reranking: reranks candidates (evidence: `README.md`)
- Research orchestration → Evidence decision: checks evidence (evidence: `README.md`)
- Research orchestration → Grounded answer: generates answer (evidence: `README.md`)
- Grounded answer → Groq model service: requests completion (evidence: `rag_engine.py`)
- Research orchestration → Research UI: returns outcome (evidence: `README.md`)
- Research UI → Audit and authority cards: displays evidence audit (evidence: `README.md`)
- Research UI → Memo export: exports memo (evidence: `README.md`)
- Researcher → Source library: adds trusted source (evidence: `README.md`)
- Source library → Trusted URL ingestion: ingests URL (evidence: `app.py`)
- Trusted URL ingestion → Legal corpus: appends chunks (evidence: `trusted_sources.py`)
- Researcher → PDF ingestion: uploads PDF
- PDF ingestion → PDF parsing: parses document (evidence: `pdf_ingestor.py`)
- PDF ingestion → Legal chunking: chunks text (evidence: `pdf_ingestor.py`)
- PDF ingestion → Document metadata: classifies chunks (evidence: `pdf_ingestor.py`)
- PDF ingestion → Legal corpus: appends records (evidence: `pdf_ingestor.py`)
- PDF ingestion → Vector store: adds records (evidence: `pdf_ingestor.py`)
- Legal corpus → Research orchestration: loads corpus (evidence: `README.md`)
- Vector store → Text embeddings: embeds records (evidence: `vector_store.py`)
- Vector store → FAISS index: stores vectors (evidence: `vector_store.py`)
- Vector store → Index metadata: stores record metadata (evidence: `vector_store.py`)
