AI-Powered Civic Issue Reporting & Resolution Platform
Report infrastructure issues Β· AI-verified image analysis Β· Real-time tracking Β· Admin & Worker portals
CivicLens is a full-stack civic issue reporting platform that empowers citizens to report infrastructure problems (potholes, broken streetlights, garbage overflow, drainage issues, etc.) using AI-powered image analysis. The platform features three interconnected applications β a Citizen App, an Admin Panel, and a Worker App β creating a complete end-to-end lifecycle for civic issue management, from submission to resolution.
- π€ AI-Powered: Google Gemini automatically generates titles, descriptions, and categories from uploaded images
- π AI Image Verification: Sightengine detects and blocks AI-generated/fake images to ensure authenticity
- πΊοΈ Interactive Maps: Leaflet-powered map with severity-coded markers and location-based geocoding
- π Real-time Updates: Supabase real-time subscriptions for live status tracking
- π± Mobile-First + Native: Built for mobile web with Capacitor for Android APK builds
- π§ Email Notifications: Automated email alerts when reports are assigned to officers
- π PDF Reports: Client-side A4 PDF generation with embedded images and styled layout
- π Offline Support: SQLite-based caching for offline report browsing on native devices
CivicLens/
βββ src/ # π± Citizen App (Vite + React + TypeScript)
βββ admin/ # π‘οΈ Admin Panel (Vite + React + TypeScript)
βββ worker-app/ # π· Worker App (Vite + React + TypeScript)
βββ backend/ # βοΈ Backend API (Node.js + Express)
βββ android/ # π² Capacitor Android project
βββ supabase/ # ποΈ Supabase migrations & config
βββ *.sql # π Database schema files
| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Vite, TailwindCSS, Shadcn/UI, Radix UI, Framer Motion |
| Backend | Node.js, Express, Multer, Nodemailer, Sharp |
| Database | Supabase (PostgreSQL) with Row-Level Security & Real-time subscriptions |
| AI/ML | Google Gemini 2.5 Flash (vision), Sightengine (AI image detection) |
| Maps | Leaflet + React-Leaflet, Nominatim (geocoding via backend proxy) |
| Auth | Clerk (citizen app), Custom auth (admin & worker) |
| Mobile | Capacitor (Android), SQLite (offline storage) |
| pdf-lib (client-side A4 report generation) | |
| Hosting | Render (backend), Supabase (database), Any static host (frontend) |
flowchart TD
A[π€ Citizen Opens App] --> B[πΈ Uploads Photo of Issue]
B --> C{π AI Image Verification}
C -->|Fake/AI Image| D[β Image Rejected]
C -->|Real Image| E[π€ Gemini AI Analyzes Image]
E --> F[Auto-fills Title, Description & Category]
F --> G[π Citizen Picks Location on Map]
G --> H[ποΈ Issue Preview Screen]
H --> I[β
Submit to Supabase Database]
I --> J[π Admin Dashboard - Real-time]
J --> K[π‘οΈ Admin Reviews & Assigns to Worker]
K --> L[π§ Email Notification Sent to Worker]
L --> M[π· Worker App - Views Assigned Task]
M --> N[π§ Worker Resolves Issue]
N --> O[πΈ Worker Uploads Resolution Proof]
O --> P[β
Admin Marks as Resolved]
P --> Q[π± Citizen Sees Updated Status in Real-time]
Q --> R[π Download PDF Report]
- Citizen submits a report β Takes a photo or uploads from gallery
- AI Image Verification β Sightengine checks if the image is real (β₯85% human probability required)
- Gemini AI Analysis β Automatically generates title, description, and category from the image
- Location Selection β Pick location on an interactive Leaflet map with reverse geocoding
- Preview & Submit β Review all details before submitting to Supabase
- Real-time Sync β Report instantly appears on Admin Dashboard via Supabase real-time
- Admin Action β Admin reviews, assigns to officer/worker, sends email notification
- Worker Resolution β Worker views assigned tasks, resolves, uploads proof
- Status Tracking β Citizen tracks progress (Submitted β Viewed by Admin β Resolved)
- PDF Download β Generate and download a professional A4 PDF report
The main mobile-first web application for citizens to report and track civic issues.
| Feature | Description |
|---|---|
| Onboarding | Splash screen β Guided onboarding β Sign up / Login via Clerk |
| Home Dashboard | Weather widget, report statistics, quick actions, latest pending issues feed |
| Report an Issue | Photo upload β AI verification β Gemini auto-fill β Location picker β Preview β Submit |
| My Reports | View all submitted reports with status filters (Pending/Resolved/Rejected) |
| Report Details | Full issue details, progress timeline, upvote system, admin view status, PDF download |
| Map View | Interactive Leaflet map with severity-coded markers, geolocation, map clustering |
| Nearby Alerts | Location-aware feed of reported issues sorted by proximity |
| Profile | View & edit profile, manage account settings |
| Offline Mode | SQLite-based caching of reports, weather, stats for offline browsing (native) |
| Push Notifications | FCM token registration for push notification support (native) |
Key Pages: Splash β Onboarding β Login / Signup β Home β ReportIssue β ChooseLocation β IssuePreview β MyReports β ReportDetails β MapView β NearbyAlerts β Profile β EditProfile
A desktop-optimized administrative dashboard for municipal authorities.
| Feature | Description |
|---|---|
| Dashboard | Real-time stats (total, pending, resolved, rejected), recent reports table, summary panel |
| Issues Management | Full list of all reports with sorting, filtering, and bulk actions |
| Report Details | Detailed view, assign to officer, update status, add resolution notes |
| Worker Management | Register, edit, and manage field workers/officers |
| Approvals | Review and approve/reject submitted reports |
| Map View | Geo-visualize all reported issues across the city |
| Analytics | Charts and statistics for report trends, category breakdown |
| Profile | Admin profile and account management |
| Email Notifications | Sends styled HTML emails to officers when reports are assigned |
Key Pages: SignIn β Dashboard β Issues β ReportDetails β Workers β Approvals β MapPage β Analytics β Profile
A mobile-first application for field workers to manage assigned tasks.
| Feature | Description |
|---|---|
| Splash & Login | Animated splash screen β Worker credential login |
| Onboarding | Interactive walkthrough for new workers |
| Issues Near You | Browse civic issues nearby with location context |
| My Tasks | View all assigned tasks with status tracking |
| Issue Details | View full issue details, upload resolution proof, mark as resolved |
| Task Review | Review completed tasks and upload verification images |
| Profile | Worker profile and settings management |
| AI Verification | Resolution proof images are verified for authenticity |
Key Pages: SplashScreen β LoginPage β OnboardingPage β IssuesListPage β IssueDetailsPage β TaskReviewPage β ProfilePage
A Node.js/Express server handling sensitive operations and third-party integrations.
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/detect-ai-image |
POST | AI image detection via Sightengine (multipart upload) |
/api/reverse-geocode |
GET | Reverse geocoding with Supabase caching (~200m radius) |
/api/search-location |
GET | Forward geocoding (text β coordinates) via Nominatim proxy |
/api/send-email |
POST | Send generic HTML email |
/api/send-report-assignment |
POST | Send styled report assignment email to officers |
/api/notifications/register |
POST | Register FCM push notification token |
/api/notifications/unregister |
POST | Unregister FCM token (on logout) |
/api/notifications/tokens/:userId |
GET | Get active tokens for a user |
/api/clear-cache |
POST | Clear geocoding cache (debug) |
/api/view-cache |
GET | View cached geocoding entries (debug) |
β οΈ IMPORTANT: Never commit.envfiles. Use.env.exampleas a template.
The project uses environment variables across four applications. Copy the respective .env.example file to .env in each directory.
| Service | Purpose | Get it from |
|---|---|---|
| Clerk | User authentication (citizen app) | clerk.com |
| Supabase | Database, auth, real-time subscriptions | supabase.com |
| Google Gemini | AI image analysis (vision model) | makersuite.google.com |
| OpenWeatherMap | Weather data for home dashboard | openweathermap.org |
| Sightengine | AI-generated image detection | sightengine.com |
| Gmail SMTP | Email notifications (backend) | Google App Passwords |
CivicLens/.env.example β Citizen App (VITE_* prefixed)
CivicLens/backend/.env.example β Backend Server
CivicLens/admin/.env.example β Admin Panel
CivicLens/worker-app/.env.example β Worker App
- Node.js β₯ 18
- npm or bun
- A Supabase project (free tier works)
- API keys for Clerk, Gemini, OpenWeatherMap, and Sightengine
git clone https://github.com/KanishJebaMathewM/CivicLens.git
cd CivicLensRun the following SQL files in your Supabase SQL Editor (in order):
# 1. Core reports table
database-schema-reports.sql
# 2. Admin tracking columns
database-schema-admin-tracking.sql
# 3. Officers table
CREATE_OFFICERS_TABLE.sql
# 4. Worker flow migration
WORKER_FLOW_MIGRATION.sql
# 5. Any missing columns
ADD_MISSING_COLUMNS.sql# Install dependencies
npm install
# Copy environment template and fill in your keys
cp .env.example .env
# Start development server
npm run devThe app will be available at http://localhost:5173
cd backend
# Install dependencies
npm install
# Copy environment template and fill in your keys
cp .env.example .env
# Start development server (with auto-restart)
npm run devThe API will be available at http://localhost:3001
cd admin
# Install dependencies
npm install
# Copy environment template and fill in your keys
cp .env.example .env
# Start development server
npm run devThe admin panel will be available at http://localhost:5174
cd worker-app
# Install dependencies
npm install
# Copy environment template and fill in your keys
cp .env.example .env
# Start development server
npm run devThe worker app will be available at http://localhost:5175
# From root directory
npm run build # Build the Vite app
npx cap sync android # Sync web assets to Android
npx cap open android # Open in Android Studio| Column | Type | Description |
|---|---|---|
id |
UUID | Primary key (auto-generated) |
title |
TEXT | Issue title |
description |
TEXT | Detailed description |
category |
TEXT | Road Issues, Garbage, Water/Drainage, Streetlight, etc. |
status |
TEXT | pending / resolved / rejected |
severity |
TEXT | low / medium / high |
location_name |
TEXT | Human-readable address |
latitude |
DECIMAL | GPS latitude |
longitude |
DECIMAL | GPS longitude |
image_url |
TEXT | Uploaded image URL/base64 |
user_id |
TEXT | Reporter's user ID |
upvotes |
INTEGER | Community upvote count |
viewed_by_admin |
BOOLEAN | Whether admin has seen it |
admin_viewed_at |
TIMESTAMP | When admin viewed it |
resolved_by |
TEXT | Worker who resolved |
resolved_at |
TIMESTAMP | Resolution timestamp |
created_at |
TIMESTAMP | Submission time |
updated_at |
TIMESTAMP | Last update time |
reverse_geocacheβ Caches reverse geocoding results (~200m radius)fcm_tokensβ FCM push notification tokens per userofficersβ Municipal officers/workers registrynotificationsβ Notification events for broadcasts
- Auto-generates issue title (max 8 words)
- Auto-generates concise description (1β2 sentences)
- Auto-suggests category from predefined list
- Uses
gemini-2.5-flash-previewmodel with system instructions
- Detects AI-generated/fake images before submission
- Images must be β₯ 85% human probability to pass
- Compresses images server-side (via Sharp) before analysis
- 60-second timeout with graceful fallback
- Road Issues
- Garbage & Cleanliness
- Water / Drainage
- Streetlight / Electricity
- Public Safety
- Public Facilities
- Parks & Environment
- Other
CivicLens generates professional A4 PDF reports client-side using pdf-lib:
- Branded header with CivicLens logo and status badge
- Issue details β title, category, severity, date, location
- Description section with multi-line text wrapping
- Evidence images β original issue + resolution proof (side-by-side)
- Footer with generation timestamp and page numbers
- Supports both web download and native (Capacitor Filesystem) save
On native Android builds, CivicLens uses Capacitor SQLite for offline data:
| Cached Data | Auto-Refresh |
|---|---|
| Home feed reports | On reconnect |
| Nearby alerts | On reconnect |
| My reports list | On reconnect |
| Map markers | On reconnect |
| Weather data | 1-hour TTL |
| User profile | On login |
| Report statistics | On reconnect |
| Location history | Last 20 entries |
- All API keys are loaded from environment variables (
.env) .envfiles are excluded from version control via.gitignore- Backend uses Supabase Service Role Key (never exposed to client)
- Client uses Supabase Anon Key with Row-Level Security (RLS)
- Sightengine API credentials are server-side only
- SMTP credentials are server-side only
- CORS enabled on backend for cross-origin requests
google-services.jsonis gitignored (download from Firebase Console)
CivicLens/
βββ src/ # π± Citizen App
β βββ pages/ # All page components
β β βββ Home.tsx # Dashboard with weather, stats, issues
β β βββ ReportIssue.tsx # Report form with AI analysis
β β βββ ChooseLocation.tsx # Interactive map location picker
β β βββ IssuePreview.tsx # Preview & submit report
β β βββ MyReports.tsx # User's submitted reports
β β βββ ReportDetails.tsx # Full report with progress tracker
β β βββ MapView.tsx # City-wide issue map
β β βββ NearbyAlerts.tsx # Proximity-based issue feed
β β βββ Profile.tsx # User profile
β β βββ ...
β βββ services/ # Business logic
β β βββ geminiVision.ts # Gemini AI image analysis
β β βββ aiImageDetectionService.ts # Sightengine client
β β βββ WeatherService.ts # OpenWeatherMap integration
β β βββ offlineService.ts # SQLite offline caching
β β βββ pdfService.ts # A4 PDF generation
β β βββ notificationService.ts # FCM token management
β β βββ upvoteService.ts # Upvote toggle logic
β β βββ authService.ts # Auth state management
β βββ components/ # Reusable UI components
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utilities (Supabase client, etc.)
β βββ utils/ # Helper functions
β
βββ admin/src/ # π‘οΈ Admin Panel
β βββ pages/admin/ # Admin page components
β βββ services/ # Admin business logic
β βββ components/ # Admin UI components
β βββ contexts/ # Auth context
β
βββ worker-app/src/ # π· Worker App
β βββ pages/ # Worker page components
β βββ services/ # Worker business logic
β βββ components/ # Worker UI components
β
βββ backend/ # βοΈ Express API Server
β βββ server.js # Main server with all routes
β βββ services/ # Backend services
β βββ aiImageDetection.js # Sightengine integration
β
βββ android/ # π² Capacitor Android project
βββ *.sql # Database migration scripts
βββ capacitor.config.ts # Mobile build config
βββ package.json # Root dependencies
npm run dev # Start Vite dev server
npm run build # Production build
npm run preview # Preview production build
npm run lint # Run ESLintcd backend
npm run dev # Start with auto-restart (--watch)
npm start # Start production servercd admin
npm run dev # Start Vite dev server
npm run build # Production buildcd worker-app
npm run dev # Start Vite dev server
npm run build # Production build- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Copy
.env.exampleβ.envand configure your keys - Make your changes
- Commit (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open-source. See the repository for license details.
Built with β€οΈ by the CivicLens Team