# akshattp/nyayamitra_sih architecture

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

- Interactive diagram: https://gitdiagram.com/akshattp/nyayamitra_sih
- Repository: https://github.com/akshattp/nyayamitra_sih

## Overview

NyayaMitra AI is a legal-research and judicial-triage copilot with citation verification, alongside government compliance dashboards and a law-firm portal. The main workflow takes a case into the workspace, sends research requests through the API, retrieves and reranks legal material, verifies citations, and presents grounded results; reports can be exported. The tree and README document broader ingestion, governance, and firm-management capabilities. Some backend route-to-agent wiring is not shown in the sampled excerpts, so uncertain links are omitted.

Main entry points: [`backend/app/main.py`](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/rag/retriever.py`](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/retriever.py) (RAG retrieval), [`backend/app/services/law_firm_service.py`](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/law_firm_service.py) (Firm management), [`backend/app/ingestion/orchestrator.py`](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/ingestion/orchestrator.py) (Legal ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client application"]
  node_frontend["Angular app<br/>[main.ts]"]
  node_routes["Route access<br/>[app.routes.ts]"]
  node_auth["User authentication<br/>[auth.service.ts]"]
  node_workspace["Case workspace"]
  node_api_client["API client<br/>[api.service.ts]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_case_routes["Case endpoints<br/>[cases.py]"]
  node_research_routes["Research endpoints<br/>[research.py]"]
  node_citation_routes["Citation endpoints<br/>[citations.py]"]
  node_copilot_routes["Copilot endpoints<br/>[copilot.py]"]
  node_report_routes["Report endpoints<br/>[reports.py]"]
end

subgraph group_research["Legal research"]
  node_agents["Research agents"]
  node_planner["Research planner"]
end

subgraph group_knowledge["Knowledge and verification"]
  node_retrieval["RAG retrieval<br/>[retriever.py]"]
  node_reranker["Result reranker<br/>[reranker.py]"]
  node_faiss[("FAISS index<br/>[faiss_store.py]")]
  node_verify["NyayaGuard<br/>[nyayaguard.py]"]
  node_ingestion["Legal ingestion<br/>[orchestrator.py]"]
  node_connectors["Legal-source connectors"]
end

subgraph group_operations["Operations portals"]
  node_gov_routes["Government dashboards<br/>[gov_routes.py]"]
  node_compliance["Compliance service"]
  node_firm_routes["Law-firm endpoints<br/>[law_firm_routes.py]"]
  node_firm_service["Firm management"]
  node_firebase["Firebase services"]
end

node_user(("Legal user"))
node_legal_sources["External legal sources"]
node_firm_store[("Firestore")]
node_brief["Research brief"]

node_user -->|"uses"| node_frontend
node_frontend -->|"navigates"| node_routes
node_routes -->|"guards"| node_auth
node_user -->|"submits case"| node_workspace
node_workspace -->|"requests research"| node_api_client
node_api_client -->|"sends API requests"| node_fastapi
node_fastapi -->|"dispatches"| node_case_routes
node_fastapi -->|"dispatches"| node_research_routes
node_fastapi -->|"dispatches"| node_citation_routes
node_fastapi -->|"dispatches"| node_copilot_routes
node_fastapi -->|"dispatches"| node_report_routes
node_research_routes -->|"plans research"| node_planner
node_planner -->|"queries precedents"| node_retrieval
node_retrieval -->|"searches index"| node_faiss
node_retrieval -->|"ranks candidates"| node_reranker
node_agents -->|"checks citations"| node_verify
node_citation_routes -->|"verifies citations"| node_verify
node_ingestion -->|"dispatches ingestion"| node_connectors
node_connectors -->|"fetches legal material"| node_legal_sources
node_ingestion -->|"updates index"| node_faiss
node_gov_routes -->|"reads compliance data"| node_compliance
node_compliance -.->|"refreshes from"| node_legal_sources
node_firm_routes -->|"manages firm data"| node_firm_service
node_firm_service -->|"reads and writes"| node_firm_store
node_firm_service -->|"creates accounts"| node_firebase
node_report_routes -->|"exports report"| node_brief

click node_frontend "https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/main.ts"
click node_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/app.routes.ts"
click node_auth "https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/core/auth/auth.service.ts"
click node_workspace "https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/features/case-workspace/case-workspace.component.ts"
click node_api_client "https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/core/services/api.service.ts"
click node_fastapi "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/main.py"
click node_case_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/cases.py"
click node_research_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/research.py"
click node_citation_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/citations.py"
click node_copilot_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/copilot.py"
click node_report_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/reports.py"
click node_agents "https://github.com/akshattp/nyayamitra_sih/tree/main/backend/app/agents"
click node_planner "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/agents/research_planner.py"
click node_retrieval "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/retriever.py"
click node_reranker "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/reranker.py"
click node_faiss "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/faiss_store.py"
click node_verify "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/verification/nyayaguard.py"
click node_ingestion "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/ingestion/orchestrator.py"
click node_connectors "https://github.com/akshattp/nyayamitra_sih/tree/main/backend/app/ingestion/connectors"
click node_gov_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/gov_routes.py"
click node_compliance "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/compliance_service.py"
click node_firm_routes "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/law_firm_routes.py"
click node_firm_service "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/law_firm_service.py"
click node_firebase "https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/firebase_service.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_frontend,node_routes,node_auth,node_workspace,node_api_client,node_user toneBlue
class node_fastapi,node_case_routes,node_research_routes,node_citation_routes,node_copilot_routes,node_report_routes,node_firm_store toneAmber
class node_agents,node_planner toneMint
class node_retrieval,node_reranker,node_faiss,node_verify,node_ingestion,node_connectors toneRose
class node_gov_routes,node_compliance,node_firm_routes,node_firm_service,node_firebase,node_legal_sources,node_brief toneIndigo
```

## Components

### Client application

- [Angular app](https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/main.ts): `angular-frontend/src/main.ts`
- [Route access](https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/app.routes.ts): `angular-frontend/src/app/app.routes.ts`
- [User authentication](https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/core/auth/auth.service.ts): `angular-frontend/src/app/core/auth/auth.service.ts`
- [Case workspace](https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/features/case-workspace/case-workspace.component.ts): `angular-frontend/src/app/features/case-workspace/case-workspace.component.ts`
- [API client](https://github.com/akshattp/nyayamitra_sih/blob/main/angular-frontend/src/app/core/services/api.service.ts): `angular-frontend/src/app/core/services/api.service.ts`

### Backend API

- [FastAPI application](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/main.py): `backend/app/main.py`
- [Case endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/cases.py): `backend/app/api/cases.py`
- [Research endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/research.py): `backend/app/api/research.py`
- [Citation endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/citations.py): `backend/app/api/citations.py`
- [Copilot endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/copilot.py): `backend/app/api/copilot.py`
- [Report endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/reports.py): `backend/app/api/reports.py`

### Legal research

- [Research agents](https://github.com/akshattp/nyayamitra_sih/tree/main/backend/app/agents): `backend/app/agents`
- [Research planner](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/agents/research_planner.py): `backend/app/agents/research_planner.py`

### Knowledge and verification

- [RAG retrieval](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/retriever.py): `backend/app/rag/retriever.py`
- [Result reranker](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/reranker.py): `backend/app/rag/reranker.py`
- [FAISS index](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/rag/faiss_store.py): `backend/app/rag/faiss_store.py`
- [NyayaGuard](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/verification/nyayaguard.py): `backend/app/verification/nyayaguard.py`
- [Legal ingestion](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/ingestion/orchestrator.py): `backend/app/ingestion/orchestrator.py`
- [Legal-source connectors](https://github.com/akshattp/nyayamitra_sih/tree/main/backend/app/ingestion/connectors): `backend/app/ingestion/connectors`

### Operations portals

- [Government dashboards](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/gov_routes.py): `backend/app/api/gov_routes.py`
- [Compliance service](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/compliance_service.py): `backend/app/services/compliance_service.py`
- [Law-firm endpoints](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/api/law_firm_routes.py): `backend/app/api/law_firm_routes.py`
- [Firm management](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/law_firm_service.py): `backend/app/services/law_firm_service.py`
- [Firebase services](https://github.com/akshattp/nyayamitra_sih/blob/main/backend/app/services/firebase_service.py): `backend/app/services/firebase_service.py`

### Other components

- **Legal user**
- **External legal sources**
- **Firestore**
- **Research brief**

## Connections

- Legal user → Angular app: uses
- Angular app → Route access: navigates
- Route access → User authentication: guards
- Legal user → Case workspace: submits case
- Case workspace → API client: requests research
- API client → FastAPI application: sends API requests
- FastAPI application → Case endpoints: dispatches
- FastAPI application → Research endpoints: dispatches
- FastAPI application → Citation endpoints: dispatches
- FastAPI application → Copilot endpoints: dispatches
- FastAPI application → Report endpoints: dispatches
- Research endpoints → Research planner: plans research
- Research planner → RAG retrieval: queries precedents
- RAG retrieval → FAISS index: searches index
- RAG retrieval → Result reranker: ranks candidates
- Research agents → NyayaGuard: checks citations
- Citation endpoints → NyayaGuard: verifies citations
- Legal ingestion → Legal-source connectors: dispatches ingestion
- Legal-source connectors → External legal sources: fetches legal material
- Legal ingestion → FAISS index: updates index
- Government dashboards → Compliance service: reads compliance data
- Compliance service → External legal sources: refreshes from
- Law-firm endpoints → Firm management: manages firm data
- Firm management → Firestore: reads and writes
- Firm management → Firebase services: creates accounts
- Report endpoints → Research brief: exports report
