Copyright © 2026 Md. Mehadi Hasan.
CGCP is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-only), with additional attribution and naming terms under Section 7 of the AGPL-3.0. See the NOTICE.md file for details.
Created by Md. Mehadi Hasan.
CGCP enables citizens to report local issues directly to authorities with full transparency. Every report is AI-verified, publicly tracked, and resolved through a structured workflow — turning governance into a data-driven, citizen-focused system.
Each file below explains one flow: what it does, how the code works, and things worth knowing (security notes, quirks, inconsistencies found while reading the code). Written to be read alongside the actual source files, not as a replacement for them.
- LOGIN.md — email/password + Google login, rate limiting, role-based dashboard redirect
- REGISTER.md — signup, disposable email blocking, email verification
- RESET_PASSWORD.md — forgot/reset password flow + shared OAuth callback route
- NEWREPORT.md — the core feature: report submission + full AI verification pipeline (category detection, text/image verification, duplicate detection, auto department assignment)
- DASHBOARD.md — dashboard, report history, report detail (upvotes, reopen, timeline)
- PROFILE.md — mandatory profile completion (NID) + later profile editing
- NOTIFICATIONS.md — in-app notifications, mark-all-read
- SERVICES.md — complaints against departments, market price watch, emergency contacts, hospital finder
- ADMIN.md — dashboard stats, reports, complaints, department CRUD + staffing, user management, analytics. Includes a note on where role-checking actually happens (middleware, not the layout).
- DEPARTMENT.md — how department staff (police/urban_local/fire_service/health/education) receive and manage reports assigned to them, update statuses, manage their team
- WEATHER.md —
⚠️ a fully-built OpenWeatherMap widget (current/hourly/daily/AQI + Bengali localization) that isn't mounted to any route yet; documented as a known gap, not a working feature
- PROXY.md — the middleware: auth gating, role-based route protection, redirect logic for every request
- CHATBOT.md — AI chatbot with legal RAG (Groq + pgvector); also documents voice input/output, including the
/api/ttsroute - CHAT.md — direct 1-to-1 real-time messaging between a citizen and a department's staff (separate system from the AI chatbot above)
- PUSH_NOTIFICATIONS.md — browser web-push (VAPID/service-worker), currently triggered only on report lifecycle events
- PUBLIC_STATS.md — public no-auth statistics dashboard
- MAP.md — interactive map: search, routing, nearby reports, POI layers, crime heatmap (implemented — despite an earlier note in this README calling it a placeholder)
- REPORT_PDF.md — single-report PDF export via server-side Puppeteer, with embedded Bengali font support
/services/exam-results— a route referenced inapp/services/layout.tsx's header config, but no page exists behind it yet (see SERVICES.md)- Weather widget — built, not routed (see WEATHER.md)
Some smaller/UI-only pieces weren't given their own doc since they don't carry independent flow logic worth a separate file (e.g. individual UI components, the types/database.types.ts generated types, lib/schemas/ validation schemas — these are referenced inside the docs above where relevant instead).
- Register & login with Email or Google OAuth
- Complete profile with NID verification
- Submit reports with photo/video evidence
- AI verification via Google Gemini (image authenticity check)
- Real-time report status tracking
- Upvote community reports
- Anonymous reporting option
- Emergency report flagging
- Voice support for uneducated/illiterate users (Web Speech API)
- Topics: National Laws, Health, Farming, Education
- Powered by Groq AI (fast inference)
- Law data from minlaw.gov.bd stored in Supabase via pgvector (RAG)
- Context-aware multi-turn conversations
- Role-based access: Admin, Police, Urban Local, Fire Service, Health, Education
- Assign reports to departments
- Update report status with notes
- Analytics & resolution rate tracking
- Department-wise performance metrics
- Live stats: total reports, resolution rate, active issues
- Category-wise breakdown
- District-wise heatmap
- No login required to view public stats
- Real-time notifications on report updates
- Status change alerts
- Complaint submission against departments
- Crime rate analysis by area
- Exam result checker
- Hospital finder with emergency contacts
| Layer | Technology |
|---|---|
| Frontend | Next.js 15 (App Router), TypeScript |
| Styling | Tailwind CSS, shadcn/ui |
| Auth | Supabase Auth (Email + Google OAuth) |
| Database | Supabase (PostgreSQL + pgvector) |
| AI Image Verify | Google Gemini API |
| AI Chatbot | Groq AI (llama3) |
| Vector Search | pgvector + Supabase |
| Maps | Leaflet.js + React-Leaflet |
| Rate Limiting | Upstash Redis (sliding window) |
| Forms | React Hook Form + Zod |
| Notifications | Sonner |
| Deployment | Vercel |
- Node.js 18+
- Supabase account
- Google Cloud Console account (OAuth + Gemini)
- Groq API account
- Upstash Redis account
- Vercel account (for deployment)
git clone https://github.com/MehadiWritesCode/cgcp
cd cgcp
npm installCreate .env.local:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# Site URL
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# Groq AI
GROQ_API_KEY=your_groq_api_key
# Google Gemini
GEMINI_API_KEY=your_gemini_api_key
# Upstash Redis
UPSTASH_REDIS_REST_URL=your_upstash_url
UPSTASH_REDIS_REST_TOKEN=your_upstash_tokennpm run dev- Checks if uploaded image matches the reported category
- Returns confidence score
- Flags suspicious or irrelevant media
- Laws scraped from minlaw.gov.bd
- Stored as vector embeddings in Supabase
- Groq llama3 generates answers with legal context
- Voice input/output for accessibility
{
"dependencies": {
"next": "16.2.6",
"react": "19.2.4",
"supabase": "^2.106.1",
"groq-sdk": "^1.2.0",
"leaflet": "^1.9.4",
"zod": "3.25.76",
"shadcn": "^4.8.0"
}
}View the full package.json file in the repository
| Role | Access |
|---|---|
citizen |
Submit reports, view own reports, chatbot |
admin |
Full access, manage all reports & users |
police |
View & update crime-related reports |
urban_local |
View & update urban infrastructure reports |
fire_service |
View & update emergency reports |
health |
View & update health-related reports |
education |
View & update education-related reports |
- Push to GitHub
- Import project in Vercel
- Add all environment variables
- Deploy
- Update
NEXT_PUBLIC_SITE_URLin Vercel env - Add production URL to Supabase redirect URLs
- Add production URL to Google OAuth authorized origins
- Add
/auth/callbackto Google OAuth redirect URIs
- Server-side validation with Zod on all actions
- Rate limiting via Upstash (5 attempts / 15 min on login)
- RLS policies on all Supabase tables
- No sensitive data exposed to client
- Credential enumeration protection on auth endpoints
- NID overwrite prevention
Md. Mehadi Hasan 📧 mehadi.hasan.engr@gmail.com
Made with ❤️ by Md. Mehadi Hasan for a better Bangladesh 🇧🇩