Skip to content

A Chatbot for help of rural An AI-powered rural governance assistant that provides Panchayats with scheme information, village-level deficit analysis, and data-driven development suggestions using FastAPI, Qdrant semantic search, CSV-based rural indicators, and LLM reasoning.people

Notifications You must be signed in to change notification settings

Deepak-J0shi/Panchayat-Sahayika

Β 
Β 

Repository files navigation

Panchayat-Sahayika (AI-Powered Rural Governance Assistant)

A multilingual (Hindi + English) AI assistant designed for rural development governance, enabling Gram Panchayats to access scheme information, analyze village deficits, retrieve government documents, and generate actionable development insights using FastAPI, Qdrant Vector DB, Neo4j Knowledge Graph, LLMs, and a modern React + Tailwind frontend.

Demo Video: https://youtu.be/SvaaQusU9nU?si=S9WfEV2PBO07HTdO

image

Table of Contents

  1. Overview
  2. Features
  3. Folder Structure
  4. How to Run Locally
  5. Architecture & Design Decisions
  6. Data Sources & Preprocessing
  7. RAG + Knowledge Graph Pipeline
  8. LLM Reasoning Flow
  9. Challenges & Trade-Offs

Overview

Panchayat-Sahayika is an AI-powered digital assistant designed specifically for rural governance in India, helping Gram Panchayat officials, government workers, and citizens to:

  • Understand development deficits
  • Discover government schemes
  • Ask questions about rural indicators
  • Receive data-driven recommendations
  • Access extended insights using RAG + LLM reasoning

The system integrates:

  • FastAPI backend
  • Qdrant vector embeddings for semantic search
  • LLMs (Groq / OpenAI) for query interpretation
  • CSV datasets of Uttarakhand village-level deficits
  • React + Tailwind frontend for clean interaction

Real-world application: We tested the prototype in Pawo Malla village (Uttarakhand) with the Gram Pradhan, gathering real on-ground feedback about water issues, connectivity problems, and village priorities.


Features

πŸ”Ή Multilingual Query Support

Ask in Hindi or English β†’ system automatically interprets meaning.

πŸ”Ή Data-Driven Rural Insights

System analyzes infrastructure deficits (roads, water, health, education).

πŸ”Ή Government Scheme Retrieval

Users can ask:

β€œHamare gaon ke liye paani yojana kaun si hai?”

πŸ”Ή Qdrant-Powered Semantic Search

Retrieves relevant paragraphs, government documents, schemes, and datasets.

πŸ”Ή Knowledge Graph Reasoning

Graph nodes:

  • Development Themes
  • Government Schemes
  • Panchayat Needs
  • Infrastructure deficits

Relationships enrich LLM outputs.

πŸ”Ή Real-Time AI Responses

LLM synthesizes scheme suggestions, cluster insights, and action strategies.

πŸ”Ή Frontend With Clean UI

Built with React + Tailwind for lightweight rural-friendly UX.


Folder Structure

Panchayat-Sahayika/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ data/                     # Scheme texts, rural indicators, reference docs
β”‚   β”œβ”€β”€ qdrant_data/              # Preprocessed embeddings or vector payloads
β”‚   β”œβ”€β”€ services/                 # RAG, embeddings, KG, query handlers
β”‚   β”œβ”€β”€ utils/                    # Helper functions, preprocessors
β”‚   β”œβ”€β”€ FinderScreen.py           # Infra deficit inference logic
β”‚   β”œβ”€β”€ gram.py                   # Panchayat-specific retrieval logic
β”‚   β”œβ”€β”€ app.py                    # FastAPI entry
β”‚   β”œβ”€β”€ main.py                   # API routing + server startup
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── uttarakhand_infra_deficits.csv
β”‚
β”œβ”€β”€ public/
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/               # Chat UI, cards, loaders
β”‚   β”œβ”€β”€ pages/                    # Main dashboard, chat page
β”‚   β”œβ”€β”€ styles/                   # Tailwind configs
β”‚   └── utils/                    # Frontend helpers
β”‚
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ tailwind.config.js
└── README.md

How to Run Locally


1️⃣ Backend Setup

Install dependencies

cd backend
pip install -r requirements.txt

Environment Variables

Create .env:

# --- Qdrant Vector DB ---
QDRANT_URL=your_qdrant_url
QDRANT_API_KEY=your_qdrant_key
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2

# --- LLM Keys ---
GROQ_API_KEY=your_groq_api
OPENAI_API_KEY=your_openai_api

# --- (Optional) Model Settings ---
MODEL_NAME=llama-3-8b
TEMPERATURE=0.2

Run Backend

uvicorn main:app --reload

2️⃣ Frontend Setup

cd frontend
npm install
npm run dev

Set .env:

VITE_API_URL=http://127.0.0.1:8000

App opens at:

http://localhost:5173

Architecture & Design Decisions

βœ” FastAPI

Lightweight, modular, async-ready.

βœ” Qdrant Vector Search

To store embeddings for:

  • schemes
  • documents
  • development indicators

βœ” Neo4j Knowledge Graph

Captures structured relationships between:

  • Themes
  • Schemes
  • Infrastructure deficits
  • Gram Panchayat needs

βœ” CSV Data Integration

Uses uttarakhand_infra_deficits.csv to compute village-level gaps.

βœ” LLM Reasoning Layer

Groq β†’ Fast inference OpenAI β†’ fallback + improved quality


πŸ”· Mermaid System Diagram

flowchart TD

A[User Query<br>Hindi/English] --> B[Frontend Chat UI]

B --> C[FastAPI Backend]

C --> D[Preprocessing<br>Language Detection, Normalization]

D --> E[Qdrant Semantic Search]
D --> F[Neo4j Knowledge Graph]
D --> G[Uttarakhand Infra Deficit CSV]

E --> H[RAG Context Builder]
F --> H
G --> H

H --> I[LLM Reasoning Layer<br>Groq / OpenAI]

I --> B
Loading

Data Sources & Preprocessing

1. Rural Infrastructure Dataset

File: uttarakhand_infra_deficits.csv Contains metrics like:

  • Water supply status
  • Road access
  • Healthcare centers
  • Digital connectivity
  • Education infrastructure

2. Government Schemes Dataset

Stored in /backend/data/.

3. Preprocessing Steps

  • Text cleaning
  • Stopword handling
  • Semantic chunking
  • Embedding generation
  • KG node + edge creation

RAG Pipeline

1. Query Understanding

  • Detect language (Hindi/English)
  • Identify keywords (water, roads, health)

2. Semantic Retrieval (Qdrant)

Returns top N relevant chunks.

3. Infer Village-specific Deficits

Via FinderScreen.py.

4. LLM Synthesis

LLM merges:

  • semantic context
  • graph knowledge
  • village deficit data

To generate a final actionable recommendation.


LLM Reasoning Flow

User Query β†’ Parse Intent β†’ Retrieve Relevant Schemes β†’ Fetch Village Deficits 
β†’ Expand using Knowledge Graph β†’ LLM synthesis β†’ Final Recommendation

Example:

β€œHamare gaon me paani ki dikkat hai. Kya sujhav hai?”

LLM Output includes:

  • identified deficits from CSV
  • related schemes like Jal Jeevan Mission
  • local insights
  • actionable steps

Challenges & Trade-Offs

1. Limited rural datasets available

Solution: Hand-curated CSV for Uttarakhand.

2. Qdrant memory constraints

Trade-off: Store compact MiniLM embeddings.

3. Neo4j sync delays

Trade-off: Skip KG rebuild on every startup to save memory.

4. Hindi queries vary widely

Trade-off: Simple rules + embeddings instead of a dedicated NLU model.

5. Edge cases in village names

Solution: fuzzy matching + manual correction list.


About

A Chatbot for help of rural An AI-powered rural governance assistant that provides Panchayats with scheme information, village-level deficit analysis, and data-driven development suggestions using FastAPI, Qdrant semantic search, CSV-based rural indicators, and LLM reasoning.people

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 52.2%
  • JavaScript 47.4%
  • Other 0.4%