CSC AI Copilot is a pre‑submission validation system that helps CSC operators fill government service applications before submitting to the Chhattisgarh eDistrict portal. It provides dynamic schema‑driven forms, document checks, OCR extraction, validation, risk features, and an operator‑focused workflow. The system also supports a WhatsApp pre‑check flow with Reference IDs.
- Dynamic forms generated from JSON schemas
- Validation engine with field rules, required docs, and OCR mismatch checks
- Document pipeline with OCR (image + scanned PDF)
- Risk feature extraction + ML integration
- WhatsApp pre‑check Reference ID lookup + PDF report support
- React + Vite frontend in Digital Seva theme
/Users/gaurav/csc
├─ apps/
│ ├─ api/ Express API (backend)
│ └─ operator-ui/ React + Vite (frontend)
├─ data/ Schemas, services, rules, samples
├─ db/ SQLite migrations
├─ prisma/ Prisma schema
└─ docs/ Project notes
The system supports 40 services (including the original six):
- income_certificate
- domicile_certificate
- sc_st_certificate
- obc_certificate
- land_use_information
- birth_certificate_correction
- plus additional eDistrict services loaded from
data/services/services.json
Location: /Users/gaurav/csc/apps/operator-ui
cd /Users/gaurav/csc/apps/operator-ui
npm install
npm run dev
npm run build
- Login page (Digital Seva themed)
- Service dashboard with search and pinned top six services
- Intro page per service (bilingual; Hindi uses translated intro where available)
- Dynamic form rendering from schema
- Aadhaar/PAN upload with OCR prefill + preview
- Real‑time field validation (red inputs)
- Auto‑validation on each change (debounced)
- AI Review Panel (missing fields, missing docs, OCR mismatches, risk)
- WhatsApp pre‑check lookup (Reference ID + PDF download)
- Chat widget (Gemini‑powered, Hindi/English/Hinglish)
Location: /Users/gaurav/csc/apps/api
cd /Users/gaurav/csc/apps/api
npm install
npm run dev
API default: http://localhost:4000
Backend reads env from:
/Users/gaurav/csc/apps/api/.env
Key settings:
STORAGE_MODE=sqlite|json
DATABASE_URL=file:/Users/gaurav/csc/prisma/app.db
PORT=4000
# OCR
OCR_MODE=live
OCR_PDF_MAX_PAGES=3
OCR_LANGUAGES=eng+hin
# Gemini
GEMINI_API_KEY=...
GEMINI_MODEL=gemini-2.5-flash
# WhatsApp external bot
BOT_API_BASE_URL=...
BOT_API_TOKEN=...
GET /servicesGET /services/:serviceTypePOST /applications(draft)POST /applications/:applicationId/documentsPOST /validate-applicationPOST /predict-riskPOST /applications/:applicationId/submit
GET /public/whatsapp-launch-configGET /citizen-report/:referenceIdPOST /citizen-report/lookupGET /precheck/:id/pdf
POST /whatsapp/webhook
tesseract.jsfor image OCRpdf-parsefor text‑based PDFspdfjs-dist+@napi-rs/canvasfor scanned PDFs- OCR fields feed document mismatch checks (Aadhaar/PAN/DOB/name)
- Schema validation: required fields, formats, constraints
- Document validation: required docs + accepted groups
- OCR mismatch: compares document fields vs form data
- Risk features: missing docs/fields, mismatch count, quality score
- Citizen starts WhatsApp from website
- Bot returns Reference ID + PDF report
- Operator enters Reference ID in form
- System fetches citizen data + PDF and pre-fills fields
- Prisma schema:
/Users/gaurav/csc/prisma/schema.prisma - Migrations:
/Users/gaurav/csc/db/migrations
Apply migrations:
sqlite3 /Users/gaurav/csc/prisma/app.db < /Users/gaurav/csc/db/migrations/001_init.sql
sqlite3 /Users/gaurav/csc/prisma/app.db < /Users/gaurav/csc/db/migrations/002_whatsapp_prechecks.sql
Seed precheck record (Reference ID):
PC-DEMO01
- ERR_CONNECTION_REFUSED: API not running or wrong
VITE_API_BASE_URL - WhatsApp lookup 404: API not restarted after route changes
- OCR not working: check
OCR_MODE=liveand OCR deps installed - Gemini errors: verify
GEMINI_API_KEY
- LLM explanation is currently disabled by default (see
/apps/api/src/modules/llm/explain.js). - Auto‑validation runs on every change (debounced). If you want manual‑only, adjust in
ApplicationForm.tsx.