How jayanthmb14/forthepeople works
Purpose and Runtime
ForThePeople.in is a district-level Indian civic-transparency platform: public government data is normalized into citizen dashboards, national modules, tender views, and community/support features. It runs as a TypeScript Next.js App Router application, with Prisma-backed PostgreSQL, Redis caching, and a separate scraper runtime/container.
• src/app/page.tsx
• src/app/[locale]/[state]/[district]/page.tsx
• Dockerfile.scraper
Public Routing and Presentation
The principal public entry is locale-aware routing, followed by state/district/taluk/village drill-down. A district layout establishes shared navigation/context while module pages render domain dashboards. The national “India” area is a parallel module hierarchy rather than a district module.
• src/app/[locale]/[state]/[district]/layout.tsx
• src/app/[locale]/[state]/[district]/[taluk]/page.tsx
• src/app/[locale]/india/[moduleSlug]/page.tsx
Data Model and Geographic Foundation
Prisma is the system-of-record boundary for 45+ domain models: district hierarchy, dashboard data, content, subscriptions, tenders, audit/admin state, and generated insights. Seeds bootstrap and expand district/national records. Static GeoJSON supplies client map boundaries, separate from operational data in PostgreSQL.
• prisma/schema.prisma
• prisma/seed.ts
• public/geo/india-states.json
Read APIs, Caching, and Client Consumption
Server route handlers expose module-oriented data APIs to dashboard components and hooks. The generic module endpoint is the primary abstraction for district data retrieval, with dedicated endpoints for cross-cutting computed views such as health, freshness, insights, and public district data. Redis provides the cache boundary; database access is centralized in the DB library.
• src/app/api/data/[module]/route.ts
• src/hooks/useDistrictData.ts
• src/lib/db.ts
• src/lib/redis.ts
Ingestion, Scheduling, and AI Enrichment
A scraper subsystem runs scheduled jobs for government/RSS-derived datasets and writes normalized records. Tender ingestion is a specialized orchestration pipeline over portal-specific engines, PDF parsing, red-flag computation, alerts, and AI enrichment. Next cron routes expose scheduled triggers for scraping, news intelligence, and insight generation; the scraper runtime is intended for Railway.
• src/scraper/scheduler.ts
• src/scraper/tender-orchestrator.ts
• src/scraper/engines/nicgep-engine.ts
• src/app/api/cron/news-intelligence/route.ts
Administration, Trust, and Operations
An authenticated admin surface controls content, review, data verification, operational health, AI settings, feedback, supporters, vault access, and scraper actions. Security includes admin authentication, TOTP/2FA API flows, encrypted vault data, session controls, audit logging, and rate limiting. Sentry and Plausible are integrated for errors and analytics; Resend supports alerts.
• src/app/[locale]/admin/page.tsx
• src/app/api/admin/verify-data/route.ts
• src/lib/admin-auth.ts
• src/lib/audit-log.ts
Contributions and External Services
Supporter checkout creates and verifies Razorpay orders/subscriptions; Razorpay webhooks reconcile payment events into persisted supporter/subscription state. AI uses an OpenRouter-oriented provider abstraction with fallback support for classification and generated analyses. Production infrastructure targets Vercel for the web/API runtime, Neon PostgreSQL, Upstash Redis, Railway scraping, Razorpay, Sentry, Plausible, and Resend.
• src/app/api/payment/create-order/route.ts
• src/app/api/webhooks/razorpay/route.ts
• src/lib/razorpay.ts
• src/lib/ai-provider.ts
Main entry points: schema.prisma PostgreSQL system of record · page.tsx District drill-down · route.ts Module data API · scheduler.ts Scraper scheduler
Components 25
Public experience
- Public entry
src/app/page.tsx - District drill-down · Locale, state, district, taluk, and village navigation.
src/app/[locale]/[state]/[district]/page.tsx - District shared layout
src/app/[locale]/[state]/[district]/layout.tsx - India modules · Parallel national dashboard hierarchy.
src/app/[locale]/india/[moduleSlug]/page.tsx - Dashboard data hook
src/hooks/useDistrictData.ts
Data foundation
- Module data API · Primary district module retrieval abstraction.
src/app/api/data/[module]/route.ts - Database access · Centralized application database access.
src/lib/db.ts - PostgreSQL system of record · District hierarchy, dashboards, content, tenders, subscriptions, audit state, and insights.
prisma/schema.prisma - Data bootstrap seeds
prisma/seed.ts - Redis cache
src/lib/redis.ts - India map boundaries · Client map geometry is separate from operational records.
public/geo/india-states.json
Ingestion & intelligence
- Scraper scheduler · Scheduled government and RSS dataset ingestion.
src/scraper/scheduler.ts - Tender orchestration · Portal engines, PDF parsing, red flags, alerts, and AI enrichment.
src/scraper/tender-orchestrator.ts - NICGeP tender engine
src/scraper/engines/nicgep-engine.ts - News intelligence cron
src/app/api/cron/news-intelligence/route.ts - AI provider abstraction · Classification and generated analysis with fallback support.
src/lib/ai-provider.ts - Railway scraper container · Separate scraper deployment runtime.
Dockerfile.scraper
Administration & trust
- Admin operations · Content, review, verification, health, feedback, supporters, vault, and scraper controls.
src/app/[locale]/admin/page.tsx - Data verification API
src/app/api/admin/verify-data/route.ts - Admin authentication · Admin sessions and TOTP/2FA controls.
src/lib/admin-auth.ts - Audit logging
src/lib/audit-log.ts
Production services
- Supporter checkout · Creates Razorpay orders and subscriptions.
src/app/api/payment/create-order/route.ts - Razorpay reconciliation · Persists reconciled payment events.
src/app/api/webhooks/razorpay/route.ts - Razorpay client
src/lib/razorpay.ts - Razorpay
Connections 26
- Public entry → District drill-down: enters locality
- District drill-down → District shared layout: shares context
- District drill-down → Dashboard data hook: renders dashboards
- India modules → Dashboard data hook: loads module data
- Dashboard data hook → Module data API: fetches
- Module data API → Redis cache: reads/writes cache
- Module data API → Database access: queries
- Database access → PostgreSQL system of record: persists
- Data bootstrap seeds → PostgreSQL system of record: bootstraps
- District drill-down → India map boundaries: map boundaries
- Railway scraper container → Scraper scheduler: runs
- Scraper scheduler → Tender orchestration: schedules
- Tender orchestration → NICGeP tender engine: uses portal engine
- Tender orchestration → AI provider abstraction: enriches
- Scraper scheduler → PostgreSQL system of record: writes normalized records
- News intelligence cron → AI provider abstraction: generates intelligence
- News intelligence cron → PostgreSQL system of record: stores insights
- Admin operations → Admin authentication: authenticates
- Admin operations → Data verification API: verifies data
- Data verification API → Database access: updates records
- Data verification API → Audit logging: records action
- Audit logging → PostgreSQL system of record: persists
- Supporter checkout → Razorpay client: creates order
- Razorpay client → Razorpay: calls
- Razorpay → Razorpay reconciliation: payment event
- Razorpay reconciliation → PostgreSQL system of record: reconciles state