# annampaul27/nyayasetu architecture

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

- Interactive diagram: https://gitdiagram.com/annampaul27/nyayasetu
- Repository: https://github.com/annampaul27/nyayasetu

## Overview

NyayaSetu’s represented product is a legal-query understanding agent: a citizen message is classified, normalized into a legal question and jurisdiction, enriched with domain-specific facts, then assessed for intake readiness and PII safety. The agent returns a structured, traceable result with follow-up or escalation guidance. The README describes this narrow module; source excerpts are partial, so internal stage wiring beyond the documented orchestration is shown only at the agent level.

Main entry points: [`src/query_understanding_agent.py`](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py) (Query Agent), [`src/llm_client.py`](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/llm_client.py) (LLM Client), [`src/models.py`](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/models.py) (Query Result), [`src/query_understanding_prompts.py`](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_prompts.py) (Prompt Suite)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Query Workflow"]
  node_agent["Query Agent"]
  node_domain["Domain Detection"]
  node_question["Question Extraction"]
  node_jurisdiction["Jurisdiction Extraction"]
  node_facts["Fact Extraction"]
  node_readiness["Readiness Check"]
  node_pii["PII Safety Check"]
  node_result["Query Result<br/>[models.py]"]
end

subgraph group_support["Agent Support"]
  node_prompts["Prompt Suite"]
  node_checklists["Domain Checklists"]
  node_redactor["PII Redactor<br/>[pii_redaction.py]"]
end

subgraph group_providers["LLM Provider"]
  node_config["LLM Configuration<br/>[config.py]"]
  node_llm["LLM Client<br/>[llm_client.py]"]
end

node_citizen(("Citizen"))
node_gemini{{"Google Gemini"}}

node_citizen -->|"submits query"| node_agent
node_agent -->|"runs stage"| node_domain
node_agent -->|"runs stage"| node_question
node_agent -->|"runs stage"| node_jurisdiction
node_agent -->|"runs stage"| node_facts
node_agent -->|"runs stage"| node_readiness
node_agent -->|"runs stage"| node_pii
node_agent -->|"uses prompts"| node_prompts
node_agent -->|"checks requirements"| node_checklists
node_agent -->|"constructs result"| node_result
node_domain -->|"requests completion"| node_llm
node_question -->|"requests completion"| node_llm
node_jurisdiction -->|"requests completion"| node_llm
node_facts -->|"requests completion"| node_llm
node_readiness -->|"requests completion"| node_llm
node_pii -->|"requests completion"| node_llm
node_llm -->|"reads settings"| node_config
node_llm -.->|"calls API"| node_gemini

click node_agent "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_domain "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_question "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_jurisdiction "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_facts "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_readiness "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_pii "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py"
click node_result "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/models.py"
click node_prompts "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_prompts.py"
click node_checklists "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/domain_checklists.py"
click node_redactor "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/pii_redaction.py"
click node_config "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/config.py"
click node_llm "https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/llm_client.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_agent,node_domain,node_question,node_jurisdiction,node_facts,node_readiness,node_pii,node_result toneBlue
class node_prompts,node_checklists,node_redactor toneAmber
class node_config,node_llm toneMint
class node_citizen,node_gemini toneIndigo
```

## Components

### Query Workflow

- [Query Agent](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Domain Detection](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Question Extraction](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Jurisdiction Extraction](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Fact Extraction](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Readiness Check](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [PII Safety Check](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_agent.py): `src/query_understanding_agent.py`
- [Query Result](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/models.py): `src/models.py`

### Agent Support

- [Prompt Suite](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/query_understanding_prompts.py): `src/query_understanding_prompts.py`
- [Domain Checklists](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/domain_checklists.py): `src/domain_checklists.py`
- [PII Redactor](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/pii_redaction.py): `src/pii_redaction.py`

### LLM Provider

- [LLM Configuration](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/config.py): `src/config.py`
- [LLM Client](https://github.com/annampaul27/nyayasetu/blob/feature/anna-dev/src/llm_client.py): `src/llm_client.py`

### Other components

- **Citizen**
- **Google Gemini**

## Connections

- Citizen → Query Agent: submits query
- Query Agent → Domain Detection: runs stage
- Query Agent → Question Extraction: runs stage
- Query Agent → Jurisdiction Extraction: runs stage
- Query Agent → Fact Extraction: runs stage
- Query Agent → Readiness Check: runs stage
- Query Agent → PII Safety Check: runs stage
- Query Agent → Prompt Suite: uses prompts
- Query Agent → Domain Checklists: checks requirements
- Query Agent → Query Result: constructs result
- Domain Detection → LLM Client: requests completion
- Question Extraction → LLM Client: requests completion
- Jurisdiction Extraction → LLM Client: requests completion
- Fact Extraction → LLM Client: requests completion
- Readiness Check → LLM Client: requests completion
- PII Safety Check → LLM Client: requests completion
- LLM Client → LLM Configuration: reads settings
- LLM Client → Google Gemini: calls API
