Skip to content
prtspndyPublic

Latest commit

Β 

History

11 Commits

Folders and files

Repository files navigation

GovTrack β€” Government Document Request & Status Tracking System

LINK πŸ”— : https://govtrack-government-document-request.ai.studio/

Built for Citizen Transparency Status Stack

Notice: Demo / Prototype β€” Not an Official Government Website. Built to demonstrate full end-to-end digitisation of citizen certificate issuance, multi-department verification, and real-time status tracking.


1. Executive Summary & Problem Statement

The Problem

In conventional public administration, citizens submit requests for statutory certificates (Income, Domicile, Caste, Birth, Senior Citizen cards) and subsequently must physically visit the revenue or municipal office multiple times just to know whether their file is pending, under desk scrutiny, awaiting field verification, approved, or ready for collection. This causes congestion at public offices, delays, lack of accountability, and citizen frustration.

The Solution: GovTrack

GovTrack digitizes the complete lifecycle:

  1. Citizens submit structured applications online with supporting document uploads (Aadhaar, utility bills, salary proofs).
  2. System auto-assigns an immutable tracking number (e.g. GOV-2026-000001) and calculates statutory SLA dates.
  3. Departmental Officers inspect proofs, approve or reject individual documents with remarks, request supplementary files, and transition status along a strictly audited workflow pipeline.
  4. Citizens & Public track real-time progress via a vertical status stepper and audit log, eliminating redundant physical visits.
  5. Final certified documents are cryptographically generated, digitally stored, and securely downloadable.

2. System Architecture & Tech Stack

                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚    GovTrack React Frontend (Vite)      β”‚
                   β”‚  - Tailwind CSS  - Lucide Icons        β”‚
                   β”‚  - Recharts Dashboard - Auth Context   β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚ HTTP / JSON / FormData
                                      β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚   Express.js Backend API Server        β”‚
                   β”‚  - JWT Authentication  - RBAC          β”‚
                   β”‚  - Multer Secure Uploads               β”‚
                   β”‚  - Status Workflow Validator           β”‚
                   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                          β”‚                          β”‚
                          β–Ό                          β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚   Persistence Document Store  β”‚  β”‚ Government Integration Gateway    β”‚
       β”‚  - MongoDB (Mongoose Schema)  β”‚  β”‚ (DigiLocker / e-District / SMS)   β”‚
       β”‚  - Zero-Config Embedded Store β”‚  β”‚ GovernmentDocumentService.ts      β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Frontend: React 19, Vite, React Router DOM, Tailwind CSS, Lucide React, Recharts.
  • Backend: Node.js, Express.js, TypeScript, Multer, JWT, Bcryptjs, Cors.
  • Database / Storage: Dual-mode MongoDB/Mongoose connection manager with embedded disk-backed JSON persistence fallback (data/govtrack_db.json) for seamless zero-setup execution.

3. Project Directory Structure

govtrack/
β”œβ”€β”€ data/                             # Persistent database store
β”‚   └── govtrack_db.json
β”œβ”€β”€ uploads/                          # Secure document storage
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.ts                     # MongoDB & persistence connection manager
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ adminController.ts        # Admin analytics, processing, verification
β”‚   β”‚   β”œβ”€β”€ authController.ts         # Register, login, profile, me
β”‚   β”‚   β”œβ”€β”€ documentTypeController.ts # Master document catalog
β”‚   β”‚   β”œβ”€β”€ notificationController.ts # Citizen notification system
β”‚   β”‚   β”œβ”€β”€ publicController.ts       # Public status tracking & catalog
β”‚   β”‚   └── requestController.ts      # Application filing, cancellation, downloads
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.ts                   # JWT authentication token verification
β”‚   β”‚   β”œβ”€β”€ role.ts                   # Role-Based Access Control (RBAC)
β”‚   β”‚   β”œβ”€β”€ upload.ts                 # Multer MIME & size validation (5MB max)
β”‚   β”‚   └── errorHandler.ts           # Centralized exception formatter
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── index.ts                  # User, DocumentType, Request, History, Notification, AuditLog
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ adminRoutes.ts
β”‚   β”‚   β”œβ”€β”€ authRoutes.ts
β”‚   β”‚   β”œβ”€β”€ documentTypeRoutes.ts
β”‚   β”‚   β”œβ”€β”€ notificationRoutes.ts
β”‚   β”‚   β”œβ”€β”€ publicRoutes.ts
β”‚   β”‚   └── requestRoutes.ts
β”‚   β”œβ”€β”€ seed/
β”‚   β”‚   └── seedData.ts               # Demo users, 10 document types, sample applications
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ statusWorkflow.ts         # State transition rules engine
β”‚   β”‚   └── government/
β”‚   β”‚       └── GovernmentDocumentService.ts # External API integration adapter
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── api.test.ts               # Automated RBAC, IDOR, transition test suite
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ jwt.ts
β”‚   β”‚   β”œβ”€β”€ password.ts
β”‚   β”‚   └── requestNumber.ts          # Auto-generates GOV-YYYY-XXXXXX
β”‚   └── app.ts                        # Express application configuration
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx
β”‚   β”‚   β”œβ”€β”€ Pagination.tsx
β”‚   β”‚   β”œβ”€β”€ StatusBadge.tsx
β”‚   β”‚   └── TimelineView.tsx          # Vertical progress stepper & history log
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── AuthContext.tsx           # User session, login, quick demo switchers
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminAuditLogsPage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.tsx    # Recharts analytics & live queue
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDocumentTypesPage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminProcessRequestPage.tsx # Split-screen review workstation
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminProfilePage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminRequestsPage.tsx # Search, filter, pagination
β”‚   β”‚   β”‚   └── AdminUsersPage.tsx
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginPage.tsx
β”‚   β”‚   β”‚   └── RegisterPage.tsx
β”‚   β”‚   β”œβ”€β”€ citizen/
β”‚   β”‚   β”‚   β”œβ”€β”€ ApplyDocumentPage.tsx # 4-step dynamic application wizard
β”‚   β”‚   β”‚   β”œβ”€β”€ CitizenDashboard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CitizenProfilePage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MyRequestsPage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ NotificationsPage.tsx
β”‚   β”‚   β”‚   └── RequestDetailsPage.tsx
β”‚   β”‚   └── public/
β”‚   β”‚       β”œβ”€β”€ LandingPage.tsx
β”‚   β”‚       β”œβ”€β”€ ServicesPage.tsx
β”‚   β”‚       └── TrackRequestPage.tsx  # Public tracking by reference number
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── AppRoutes.tsx             # ProtectedRoute & RoleProtectedRoute
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ adminService.ts
β”‚   β”‚   β”œβ”€β”€ api.ts
β”‚   β”‚   β”œβ”€β”€ authService.ts
β”‚   β”‚   β”œβ”€β”€ documentTypeService.ts
β”‚   β”‚   β”œβ”€β”€ notificationService.ts
β”‚   β”‚   β”œβ”€β”€ publicService.ts
β”‚   β”‚   └── requestService.ts
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ App.tsx
β”‚   └── main.tsx
β”œβ”€β”€ .env.example
β”œβ”€β”€ package.json
β”œβ”€β”€ server.ts                         # Full-stack entry point (Express + Vite)
β”œβ”€β”€ tsconfig.json
└── vite.config.ts

4. Request Status Workflow & State Machine

Status transitions are enforced by server/services/statusWorkflow.ts:

               [ SUBMITTED ]
                     β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό                           β–Ό
[ CANCELLED ]                [ UNDER_REVIEW ]
(by citizen)                       β”‚
                                   β–Ό
                      [ DOCUMENT_VERIFICATION ]
                                   β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                    β–Ό                    β–Ό
     [ REJECTED ]    [ ADDITIONAL_DOCUMENT_REQUIRED ] [ PROCESSING ]
     (with reason)                 β”‚                    β”‚
                                   β”‚ (after upload)     β–Ό
                                   └───────────────> [ APPROVED ]
                                                        β”‚
                                                        β–Ό
                                             [ READY_FOR_DOWNLOAD ]
                                                        β”‚
                                                        β–Ό
                                                  [ COMPLETED ]

Every status update:

  • Validates that the transition is legal.
  • Updates the Request record.
  • Appends to RequestStatusHistory with the actor, timestamp, and official remarks.
  • Dispatches an in-portal Notification to the citizen.
  • Records an entry in the immutable AuditLog.

5. Pre-Seeded Demo Accounts

The application is pre-seeded with realistic demonstration data for immediate review.

Role Name Email Password Pre-Seeded Requests
Officer (Admin) Vikram Sharma admin@govtrack.demo Admin@123456 Full administrative oversight
Citizen (Rahul) Rahul Patel citizen@govtrack.demo Citizen@123456 GOV-2026-000001 (Ready), GOV-2026-000002 (Verification), GOV-2026-000005 (Submitted), GOV-2026-000006 (Rejected)
Citizen (Priya) Priya Deshmukh priya.deshmukh@govtrack.demo Citizen@123456 GOV-2026-000003 (Doc Needed), GOV-2026-000004 (Completed)

Tip: You can use the 1-Click "Demo Switcher" buttons located in the top navigation bar to test both citizen and officer roles without typing passwords.


6. Local Setup & Running Instructions

Prerequisites

  • Node.js $\ge 18.0.0$
  • npm $\ge 9.0.0$

1. Installation

git clone <repo-url>
cd govtrack
npm install

2. Environment Configuration

Copy .env.example to .env:

cp .env.example .env

Default .env configuration:

PORT=3000
MONGO_URI=mongodb://localhost:27017/govtrack
JWT_SECRET=super_secret_jwt_key_govtrack_2026
JWT_EXPIRES_IN=7d
REFRESH_TOKEN_SECRET=super_refresh_jwt_key_govtrack_2026
CLIENT_URL=http://localhost:3000
UPLOAD_DIR=./uploads
GOVERNMENT_API_BASE_URL=https://api.digitallocker.gov.in/v1
GOVERNMENT_API_KEY=sample_gov_api_key_demo
VITE_API_URL=/api

(Note: If a local MongoDB instance is not running, GovTrack automatically falls back to its built-in persistent document store in data/govtrack_db.json. No external database setup is required to evaluate the portal!)

3. Run Development Server

npm run dev

Navigate to http://localhost:3000.

4. Run Automated Test Suite

GovTrack includes automated tests verifying RBAC, IDOR prevention, and workflow transitions:

npm test

5. Production Build

npm run build
npm start

7. REST API Documentation Overview

Authentication

  • POST /api/auth/register β€” Register new citizen account.
  • POST /api/auth/login β€” Sign in and receive JWT token.
  • GET /api/auth/me β€” Retrieve current authenticated user profile.
  • PATCH /api/auth/profile β€” Update contact & address information.
  • POST /api/auth/logout β€” End user session.

Document Types Catalog

  • GET /api/document-types β€” List all active statutory certificates.
  • GET /api/document-types/:id β€” Get document type with required proofs list.
  • POST /api/document-types β€” Create document type (Admin).
  • PUT /api/document-types/:id β€” Update document type (Admin).
  • PATCH /api/document-types/:id/status β€” Toggle active status (Admin).

Citizen Request Operations

  • POST /api/requests β€” Submit application with multipart proofs.
  • GET /api/requests/my β€” List citizen's applications with pagination.
  • GET /api/requests/:id β€” View application details (Enforces IDOR ownership check).
  • PATCH /api/requests/:id/cancel β€” Cancel request (Permitted only at SUBMITTED stage).
  • POST /api/requests/:id/documents β€” Upload additional document requested by officer.
  • GET /api/requests/:id/documents/:docId/download β€” Secure authenticated file download.
  • GET /api/requests/:id/final-document/download β€” Download issued digital certificate.

Administrative Console

  • GET /api/admin/dashboard β€” Live counts, status breakdown, Recharts series.
  • GET /api/admin/requests β€” Filterable, sortable, paginated request queue.
  • GET /api/admin/requests/:id β€” Full dossier for processing.
  • PATCH /api/admin/requests/:id/status β€” Update stage with remarks.
  • PATCH /api/admin/requests/:id/documents/:docId/verify β€” Verify or reject proof.
  • POST /api/admin/requests/:id/additional-document β€” Request additional proof.
  • POST /api/admin/requests/:id/final-document β€” Issue and attach signed certificate.
  • GET /api/admin/users β€” Manage citizen and officer accounts.
  • PATCH /api/admin/users/:id/status β€” Deactivate / activate user.
  • GET /api/admin/audit-logs β€” Immutable audit ledger.

Public Self-Service

  • GET /api/public/track/:requestNumber β€” Public status tracking and milestone timeline (applicant name masked for privacy).
  • GET /api/public/document-types β€” Public certificate catalog.

8. Security Hardening & Controls

  • IDOR Protection: Citizens can only query their own applications (request.citizen === req.user._id). Attempting to manipulate IDs returns 403 Forbidden.
  • Role-Based Access Control (RBAC): All administrative endpoints are guarded by authorizeRoles('admin').
  • Private File Storage: Uploaded proofs are stored outside public web roots and accessed exclusively via authenticated streaming endpoints.
  • Input Sanitization: File uploads are restricted to .pdf, .jpg, .jpeg, and .png with strict 5MB size limits.
  • Workflow Integrity: Status transitions cannot skip required phases; direct jumps are rejected by the workflow state machine.

9. Future Government API Integration Guide

The codebase is engineered with clear enterprise extension points:

File: server/services/government/GovernmentDocumentService.ts

  1. DigiLocker Integration: Connects to the National DigiLocker API to automatically pull Aadhaar XML or secondary school certificates rather than asking citizens to manually scan documents.
  2. e-Pramaan / National Single Sign-On (NSSO): OAuth2 endpoints in server/routes/authRoutes.ts can be wired directly to state identity gateways.
  3. SMS / WhatsApp Gateway: In server/controllers/adminController.ts, notifications can trigger an SMS payload via CDAC Mobile Seva or Twilio.
  4. Digital Signature (e-Sign): uploadFinalDocument can route through Aadhaar-based e-Sign (C-DAC / NSDL) to embed cryptographic digital signature certificates directly into the generated PDF.

10. Development Notes & Project Quality

Source layout

The repository keeps browser code and API code separate while grouping each by responsibility:

  • src/pages/ contains route-level screens, grouped by public, citizen, administrator, and authentication flows.
  • src/components/ contains shared UI; src/context/ owns cross-page session state.
  • src/services/ is the frontend API boundary, and src/types/ holds shared client-side types.
  • server/routes/ maps HTTP endpoints, server/controllers/ handles requests, and server/services/ contains reusable workflow and integration logic.
  • server/models/ provides the persistence boundary, with database setup in server/config/; middleware and small utilities remain separately scoped.
  • server/tests/ contains API-level regression coverage. Keep new tests close to their existing server or client feature area.

Prefer extending these boundaries over moving files or duplicating request logic. Keep route/controller changes paired with the corresponding frontend service and API test when behavior changes.

Environment and local data

The server and API test entry point load .env automatically. Copy .env.example to .env for local configuration; set JWT_SECRET to a private value of at least 32 characters before production use. Do not use the publicly visible demo secret shown in the earlier setup example. Development runs without a configured secret use a temporary random key, so existing login tokens become invalid after a server restart.

UPLOAD_DIR controls where private uploaded files are stored and defaults to ./uploads; this runtime directory is excluded from Git. VITE_API_URL controls the frontend API base and defaults to /api. The JSON data file under data/ is demonstration/runtime state, not a production database or a safe location for real citizen information.

Dependency and change workflow

bun.lock is the checked-in dependency lockfile. Use Bun for reproducible dependency resolution, and avoid committing a second package-manager lockfile. The equivalent locked setup and checks are:

bun install --frozen-lockfile
bun run lint
bun run test
bun run build

The npm scripts listed in the setup section remain available when using npm. For API changes, include regression coverage for authorization, ownership, validation, and status transitions as applicable. Keep credentials, real personal information, uploaded documents, and generated runtime data out of commits. This prototype is not approved for processing real government applications or sensitive citizen information.

Releases

Packages

Contributors

Languages