🛡️ Inspiration
Municipal complaint systems are typically broken. Citizens submit issues into a "black box" with zero feedback on resolving priority, while government staff are overwhelmed with duplicate reports for the same incident (e.g., five neighbors reporting the same pothole). We wanted to build a transparent, autonomous system that coordinates civic action dynamically.
By employing a multi-agent mesh, we created CivicGuardian AI—a platform that treats civic complaints as active state graphs, validating reports, merging spatial duplicates, balancing officer workloads, and self-improving through citizen feedback loops.
🛠️ How We Built It
CivicGuardian AI is built on a distributed Next.js (React 19) frontend and a Python FastAPI backend. The agentic brain is coordinated via a custom state-graph pipeline:
- Evidence Validation (Gemini 1.5 Flash Vision): Categorizes the complaint and uses vision to filter spam or irrelevant uploads.
- Speech Agent (Gemini 1.5 Flash Audio): Transcribes citizen audio logs with a built-in player allowing review and re-recording.
- Location Agent: Resolves reverse geocodes and municipal wards.
- Duplicate Detection Agent: Utilizes the Haversine formula to merge duplicate reports within 100 meters: $$d = 2r \arcsin\left(\sqrt{\sin^2\left(\frac{\Delta \phi}{2}\right) + \cos(\phi_1)\cos(\phi_2)\sin^2\left(\frac{\Delta \lambda}{2}\right)}\right)$$
- Planning & Recommendation Agents: Evaluates active department backlogs to assign tickets to the least-burdened officer and generates detours/emergency contacts.
- Escalation Cron (APScheduler): Periodically runs background checks to escalate overdue tickets.
- Feedback Agent: Calculates rolling averages to score department resolution performance: $$P_{new} = \alpha R + (1 - \alpha) P_{old}$$ where \(\alpha = 0.2\) is the learning rate, \(R\) is the new citizen rating, and \(P_{old}\) is the previous score.
🚧 Challenges We Faced
- State Cleanups in Interactive Maps: Next.js mounts Leaflet maps dynamically. Triggers in state dependencies caused the map container to destroy and recreate mid-zoom. We resolved this by decoupling the mount effect dependency arrays.
- Multimodal API Fallbacks: Designing a system that runs cleanly without a Gemini API key. We engineered simulated fallback routers so the agent pipeline can be tested fully locally.
- Pydantic Namespace Constraints: Tracing schema attributes through SQLAlchemy and matching model configurations in FastAPI routers.
🎓 What We Learned
We learned that agentic architectures are only as good as their transparency. Adding Explainable AI (XAI) reasoning cards showing retro progress bars (e.g. ■■■■■■■■■□ (92%)) builds deep trust with the user, making AI decisions transparent and auditable.
🔮 What's Next for CivicGuardian AI
We plan to scale the project to support multiple municipalities with localized database partitions and deploy real-time SMS alert updates for citizens.
Built With
- apscheduler
- fastapi
- google-gemini-api
- json
- langgraph
- leaflet.js
- next.js
- openstreetmap
- python
- react
- sqlalchemy
- sqlite
- tailwind-css
- typescript
- websockets
- zustand
Log in or sign up for Devpost to join the conversation.