Skip to content
MehadiWritesCodePublic

About

AI-powered civic platform for Bangladesh — citizens report issues, AI verifies & auto-assigns to departments. Built with Next.js, Supabase, Groq AI & TypeScript.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CGCP — Citizen-Government Connect Platform

📄 License

License: AGPL v3

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.


🌐 Live Demo

cgcp-bd.vercel.app


📌 Project Overview

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.


CGCP — Documentation Index

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.

Auth (Z_DOCS/auth/)

  • 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

Citizen (Z_DOCS/citizen/)

  • 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 (Z_DOCS/admin/)

  • 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 (Z_DOCS/department/)

  • DEPARTMENT.md — how department staff (police/urban_local/fire_service/health/education) receive and manage reports assigned to them, update statuses, manage their team

Services (Z_DOCS/services/)

  • 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

Platform-wide (Z_DOCS/)

  • 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/tts route
  • 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)

Citizen — additional (Z_DOCS/citizen/)

  • REPORT_PDF.md — single-report PDF export via server-side Puppeteer, with embedded Bengali font support

Known gaps / dead code (see linked docs for details)

  • /services/exam-results — a route referenced in app/services/layout.tsx's header config, but no page exists behind it yet (see SERVICES.md)
  • Weather widget — built, not routed (see WEATHER.md)

Not yet documented

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).

✨ Key Features

👤 Citizen

  • 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

🤖 AI Chatbot

  • 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

🏛️ Authority Dashboard

  • 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

📊 Public Transparency

  • Live stats: total reports, resolution rate, active issues
  • Category-wise breakdown
  • District-wise heatmap
  • No login required to view public stats

🔔 Notifications

  • Real-time notifications on report updates
  • Status change alerts

📋 Additional Tools

  • Complaint submission against departments
  • Crime rate analysis by area
  • Exam result checker
  • Hospital finder with emergency contacts

🛠️ Tech Stack

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


🚀 Getting Started

Prerequisites

  • Node.js 18+
  • Supabase account
  • Google Cloud Console account (OAuth + Gemini)
  • Groq API account
  • Upstash Redis account
  • Vercel account (for deployment)

Installation

git clone https://github.com/MehadiWritesCode/cgcp
cd cgcp
npm install

Environment Variables

Create .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_token

Run Development Server

npm run dev

Open http://localhost:3000

🔐 Authentication Flow


🤖 AI Features

Image Verification (Google Gemini)

  • Checks if uploaded image matches the reported category
  • Returns confidence score
  • Flags suspicious or irrelevant media

Law Chatbot (Groq + pgvector RAG)

  • Laws scraped from minlaw.gov.bd
  • Stored as vector embeddings in Supabase
  • Groq llama3 generates answers with legal context
  • Voice input/output for accessibility

📦 Key Packages

{
  "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

👥 User Roles

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

📊 Report Lifecycle


🌍 Deployment

Vercel (Recommended)

  1. Push to GitHub
  2. Import project in Vercel
  3. Add all environment variables
  4. Deploy

Post-Deploy Checklist

  • Update NEXT_PUBLIC_SITE_URL in Vercel env
  • Add production URL to Supabase redirect URLs
  • Add production URL to Google OAuth authorized origins
  • Add /auth/callback to Google OAuth redirect URIs

🔒 Security

  • 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

👨‍💻 Developer

Md. Mehadi Hasan 📧 mehadi.hasan.engr@gmail.com


Made with ❤️ by Md. Mehadi Hasan for a better Bangladesh 🇧🇩

About

AI-powered civic platform for Bangladesh — citizens report issues, AI verifies & auto-assigns to departments. Built with Next.js, Supabase, Groq AI & TypeScript.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages