India's AI-powered government-services assistant
BharatGov AI is a privacy-conscious assistant for Indian government services. Ask questions in plain language about schemes, documents and official procedures — it answers with citations drawn from a local knowledge base of official government sources, so you know exactly where the information came from. The app is multilingual-ready and works even when paid AI credits run out.
Try it live: https://bharatgov-ai-phi.vercel.app
- Ask about any government service — schemes, eligibility, required documents, application steps, helplines and more.
- Source-aware answers with citations — every answer is grounded in a curated knowledge base of official government documents and returns clickable sources.
- Multi-provider AI with automatic fallback — answers are generated by Gemini, then OpenAI, and finally a live web-search summary — the app never stops working.
- Document and category browser — explore the underlying knowledge base by category (
/categories,/documents). - Account dashboard with chat history — register, log in, and review your past conversations.
- Privacy-conscious by design — chat history is stored per account and the assistant is engineered to avoid collecting unnecessary personal data.
| Layer | Technology |
|---|---|
| Web app | Next.js 15 (App Router), TypeScript, Tailwind CSS |
| API | Python 3.12, FastAPI, SQLAlchemy, Pydantic |
| AI providers | Google Gemini REST, OpenAI Responses API, DuckDuckGo web search (fallback) |
| Storage | SQLite (local / single instance), PostgreSQL + Redis + Qdrant (Docker stack) |
| Auth | Email/password (bcrypt + JWT), optional Google OAuth |
| Deployment | Web on Vercel, API on Railway |
┌──────────────────────────┐ ┌─────────────────────────────┐
│ Next.js web app │ │ FastAPI backend │
│ apps/web │ ───────► │ services/api │
│ - Login / Signup / Chat │ /api/v1 │ - Auth (JWT) │
│ - Dashboard │ │ - /ask, /chat, /documents │
│ - Vercel (vercel.app) │ │ - /categories, /feedback │
└──────────────────────────┘ │ - Railway (railway.app) │
└─────────────┬───────────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Gemini 2.0 OpenAI GPT-4o-mini DuckDuckGo
(primary LLM) (fallback LLM) (last-resort search)
Base URL: https://bharatgov-ai-production.up.railway.app/api/v1 — interactive docs at /docs.
| Endpoint | Method | Description |
|---|---|---|
/auth/register |
POST | Create an account |
/auth/login |
POST | Log in, returns a JWT |
/auth/me |
GET | Current user profile |
/ask |
POST | Ask the assistant (grounded in the knowledge base) |
/chat |
GET / POST | List / create conversations |
/chat/{chat_id} |
GET | Fetch a conversation's messages |
/categories |
GET | Knowledge-base categories |
/documents |
GET | Government source documents |
/feedback |
POST | Submit answer feedback |
# 1. Environment
cp .env.example .env
# 2. API (port 8000)
cd services/api
python3 -m venv .venv && source .venv/bin/activate
pip install -e '.[dev]'
python -m app.db.seed # loads categories + 39 government source documents
uvicorn app.main:app --reload
# 3. Web (port 3000) — in a second terminal
cd apps/web
npm install
npm run devOpen http://localhost:3000. API docs at http://localhost:8000/docs.
cp .env.example .env
docker compose up --buildThe Docker stack uses PostgreSQL, Redis and Qdrant. Run the seed step once against the container DB (docker exec <api-container> python -m app.db.seed).
| Variable | Used by | Required |
|---|---|---|
JWT_SECRET |
API | Yes |
OPENAI_API_KEY |
API (fallback LLM) | No |
GEMINI_API_KEY |
API (primary LLM) | No |
CORS_ORIGINS |
API | Yes (deployed origins) |
NEXT_PUBLIC_API_URL |
Web | No (auto-resolved at runtime) |
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET |
API | Optional |
NEXT_PUBLIC_GOOGLE_CLIENT_ID |
Web | Optional |
- Web: deployed on Vercel at https://bharatgov-ai-phi.vercel.app. The build is framework-native (no Docker needed) —
apps/webrunsnext build. - API: deployed on Railway at https://bharatgov-ai-production.up.railway.app. The API is the single source of truth for auth and answers; the web app points to it via
NEXT_PUBLIC_API_URL. - Every
CORS_ORIGINSentry must list each deployed web origin.
See docs/DEVELOPMENT.md and docs/DEPLOYMENT.md for details.
.
├── apps/
│ └── web/ # Next.js frontend (login, chat, dashboard)
├── services/
│ └── api/ # FastAPI backend
│ ├── app/api/routes/ # auth, chat, resources
│ ├── app/services/ # AI assistant (Gemini → OpenAI → web search)
│ ├── app/db/ # models + seed data
│ └── app/core/ # config, security, settings
├── docs/
├── docker-compose.yml
└── .env.example
MIT