CivicOS
Civic Intelligence Platform
An AI-powered civic intelligence platform that maps citizen issues to responsible government departments, officials, laws, and complaint channels.
97% reduction via Redis caching
pgvector & Ollama RAG
GitHub Actions & Flyway
The Challenge
Citizens face a labyrinth of bureaucracy when navigating government departments. Traditional search relies on exact keywords, ignoring context. We needed a system capable of mapping a plain-text citizen complaint directly to the correct hierarchical government department, citing the relevant laws, and escalating the issue appropriately.
Jurisdiction-Aware Search Architecture
Instead of relying purely on expensive LLM calls, I designed a hybrid approach. The core mapping relies on recursive PostgreSQL Common Table Expressions (CTEs). This allows the system to traverse the hierarchical chain of accountability—from a local municipal worker up to the state department—in a single database query, maintaining strict regional mapping without hallucinations.
Performance & Caching Strategy
Handling complex recursive CTEs and vector similarity searches introduced significant latency. The initial search API took ~900ms to resolve. By implementing a Redis caching layer for frequent regional queries and using Kafka-based event streaming to decouple search analytics from the critical path, I reduced the response time to 27ms (a 97% improvement).