# nikhilsai-9/agriseva-ai architecture

> Architecture diagram of the GitHub repository nikhilsai-9/agriseva-ai, 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/nikhilsai-9/agriseva-ai
- Repository: https://github.com/nikhilsai-9/agriseva-ai

## Overview

AgriSeva-AI is a multilingual agricultural question-answering product, with a farmer-facing chat experience and supporting expert-review and farm-information capabilities. Its documented answer path prioritizes verified Golden Dataset results, then Package of Practices guidance, then AI-generated answers; AI answers enter expert review to improve the verified corpus. The graph also shows voice/transcript handling, saved conversations, and market-price ingestion. Several runtime connections are documented only at product level or are unsampled, so those links are marked dashed rather than asserted as inspected calls.

Main entry points: [`ai/agriseva/agents`](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/agents) (AgriSeva agent), [`backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/services/MarketIngestionService.ts) (Price ingestion), [`apis/langgraph-openai-adapter/app.py`](https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/langgraph-openai-adapter/app.py) (Chat adapter), [`apis/acc_api/main.py`](https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/acc_api/main.py) (Voice extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Farmer chat"]
  node_chat_adapter["Chat adapter<br/>[app.py]"]
  node_voice_extract["Voice extraction<br/>[main.py]"]
  node_agent["AgriSeva agent"]
end

subgraph group_answers["Answer sources"]
  node_golden["Golden Dataset search"]
  node_pop["PoP guidance"]
  node_llm["AI answer generation<br/>[llm_client.py]"]
end

subgraph group_review["Review and history"]
  node_reviewer["Expert review"]
  node_saved_chat[("Saved conversations<br/>[memory.py]")]
end

subgraph group_farm["Farm services"]
  node_soil["Soil health"]
  node_schemes["Government schemes"]
  node_weather["Weather information<br/>[weather_agent.py]"]
end

subgraph group_market["Market intelligence"]
  node_market_ingest["Price ingestion"]
  node_agmarknet["Agmarknet client<br/>[agmarknetClient.ts]"]
  node_enam["eNAM client<br/>[enamClient.ts]"]
  node_normaliser["Market normaliser"]
  node_price_store[("Market prices")]
  node_market_service["Market queries"]
end

node_farmer(("Farmer"))

node_farmer -->|"asks question"| node_chat_adapter
node_farmer -->|"speaks question"| node_voice_extract
node_voice_extract -.->|"passes transcript"| node_agent
node_chat_adapter -.->|"forwards chat"| node_agent
node_agent -->|"searches first"| node_golden
node_agent -->|"checks next"| node_pop
node_agent -->|"falls back"| node_llm
node_llm -->|"forwards answer"| node_reviewer
node_reviewer -->|"grows verified set"| node_golden
node_agent -->|"saves conversations"| node_saved_chat
node_agent -.->|"accesses guidance"| node_soil
node_agent -.->|"accesses schemes"| node_schemes
node_agent -.->|"gets weather"| node_weather
node_market_ingest -->|"fetches primary"| node_agmarknet
node_market_ingest -->|"fetches fallback"| node_enam
node_market_ingest -->|"normalises data"| node_normaliser
node_market_ingest -->|"persists prices"| node_price_store
node_market_service -.->|"exposes prices"| node_market_ingest

click node_chat_adapter "https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/langgraph-openai-adapter/app.py"
click node_voice_extract "https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/acc_api/main.py"
click node_agent "https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/agents"
click node_golden "https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/golden"
click node_pop "https://github.com/nikhilsai-9/agriseva-ai/tree/main/apis/ans_gen_pop"
click node_llm "https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/ans_gen_pop/llm_client.py"
click node_reviewer "https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/reviewer"
click node_saved_chat "https://github.com/nikhilsai-9/agriseva-ai/blob/main/ai/agriseva/agents/memory.py"
click node_soil "https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/soil_health"
click node_schemes "https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/govt_schemes"
click node_weather "https://github.com/nikhilsai-9/agriseva-ai/blob/main/ai/agriseva/agents/weather_agent.py"
click node_market_ingest "https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/services/MarketIngestionService.ts"
click node_agmarknet "https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/mcp/agmarknetClient.ts"
click node_enam "https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/mcp/enamClient.ts"
click node_normaliser "https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/services/MarketNormaliser.ts"
click node_price_store "https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/repositories/MarketPriceRepository.ts"
click node_market_service "https://github.com/nikhilsai-9/agriseva-ai/tree/main/backend/src/modules/marketIntelligence"

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_chat_adapter,node_voice_extract,node_agent toneBlue
class node_golden,node_pop,node_llm toneAmber
class node_reviewer,node_saved_chat toneMint
class node_soil,node_schemes,node_weather toneRose
class node_market_ingest,node_agmarknet,node_enam,node_normaliser,node_price_store,node_market_service,node_farmer toneIndigo
```

## Components

### Farmer chat

- [Chat adapter](https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/langgraph-openai-adapter/app.py): `apis/langgraph-openai-adapter/app.py`
- [Voice extraction](https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/acc_api/main.py): `apis/acc_api/main.py`
- [AgriSeva agent](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/agents): `ai/agriseva/agents`

### Answer sources

- [Golden Dataset search](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/golden): `ai/agriseva/tools/golden`
- [PoP guidance](https://github.com/nikhilsai-9/agriseva-ai/tree/main/apis/ans_gen_pop): `apis/ans_gen_pop`
- [AI answer generation](https://github.com/nikhilsai-9/agriseva-ai/blob/main/apis/ans_gen_pop/llm_client.py): `apis/ans_gen_pop/llm_client.py`

### Review and history

- [Expert review](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/reviewer): `ai/agriseva/tools/reviewer`
- [Saved conversations](https://github.com/nikhilsai-9/agriseva-ai/blob/main/ai/agriseva/agents/memory.py): `ai/agriseva/agents/memory.py`

### Farm services

- [Soil health](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/soil_health): `ai/agriseva/tools/soil_health`
- [Government schemes](https://github.com/nikhilsai-9/agriseva-ai/tree/main/ai/agriseva/tools/govt_schemes): `ai/agriseva/tools/govt_schemes`
- [Weather information](https://github.com/nikhilsai-9/agriseva-ai/blob/main/ai/agriseva/agents/weather_agent.py): `ai/agriseva/agents/weather_agent.py`

### Market intelligence

- [Price ingestion](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/services/MarketIngestionService.ts): `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`
- [Agmarknet client](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/mcp/agmarknetClient.ts): `backend/src/modules/marketIntelligence/mcp/agmarknetClient.ts`
- [eNAM client](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/mcp/enamClient.ts): `backend/src/modules/marketIntelligence/mcp/enamClient.ts`
- [Market normaliser](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/services/MarketNormaliser.ts): `backend/src/modules/marketIntelligence/services/MarketNormaliser.ts`
- [Market prices](https://github.com/nikhilsai-9/agriseva-ai/blob/main/backend/src/modules/marketIntelligence/repositories/MarketPriceRepository.ts): `backend/src/modules/marketIntelligence/repositories/MarketPriceRepository.ts`
- [Market queries](https://github.com/nikhilsai-9/agriseva-ai/tree/main/backend/src/modules/marketIntelligence): `backend/src/modules/marketIntelligence`

### Other components

- **Farmer**

## Connections

- Farmer → Chat adapter: asks question
- Farmer → Voice extraction: speaks question
- Voice extraction → AgriSeva agent: passes transcript
- Chat adapter → AgriSeva agent: forwards chat (evidence: `apis/langgraph-openai-adapter/app.py`)
- AgriSeva agent → Golden Dataset search: searches first
- AgriSeva agent → PoP guidance: checks next
- AgriSeva agent → AI answer generation: falls back
- AI answer generation → Expert review: forwards answer
- Expert review → Golden Dataset search: grows verified set
- AgriSeva agent → Saved conversations: saves conversations
- AgriSeva agent → Soil health: accesses guidance
- AgriSeva agent → Government schemes: accesses schemes
- AgriSeva agent → Weather information: gets weather
- Price ingestion → Agmarknet client: fetches primary (evidence: `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`)
- Price ingestion → eNAM client: fetches fallback (evidence: `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`)
- Price ingestion → Market normaliser: normalises data (evidence: `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`)
- Price ingestion → Market prices: persists prices (evidence: `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`)
- Market queries → Price ingestion: exposes prices (evidence: `backend/src/modules/marketIntelligence/services/MarketIngestionService.ts`)
