DEV Community

Cover image for Building CivicGuide: How I used Gemini AI to Simplify Voting ๐Ÿ—ณ๏ธ
Anil Surve
Anil Surve

Posted on

Building CivicGuide: How I used Gemini AI to Simplify Voting ๐Ÿ—ณ๏ธ

๐Ÿ‘€ The Problem Nobody Talks About

Democracy doesnโ€™t fail because of a lack of rights; it fails because of confusion.

  • Voter forms are hard to understand.
  • Government websites are difficult to navigate.
  • Information is rarely available in local languages.

This is not a data problem. This is a user experience problem.

๐Ÿ’ก The Idea

What if instead of searching through complex government portals, you could just ask?

โ€œI moved to a new district. Do I need to update my voter ID?โ€

CivicGuide answers like a human would: simple, context-aware, and in your native language.

๐Ÿง  Why Gemini 2.5 Flash?

I chose Gemini 2.5 Flash for three specific reasons:

  1. Reasoning: It handles messy, unstructured civic data with ease.
  2. Native Multilingualism: It generates high-quality output in local dialects without heavy translation layers.
  3. Multimodality: It processes image and text in a single pipeline.

๐Ÿ—๏ธ System Architecture

Diagram showing the flow from Flutter Web through a ChatController to the API Layer, connecting to Gemini and Civic APIs

The flow is straightforward:
User โ†’ Flutter Web โ†’ ChatController โ†’ API Layer โ†’ Gemini
With side integrations for Civic and Calendar APIs.


๐Ÿš€ Key Features & Implementation

๐ŸŽ™๏ธ Feature 1: Voice Input

Users can speak naturally. One "gotcha" I encountered was that browser APIs require user-triggered initialization.

void _toggleListening() async {
  if (!_speechAvailable) {
    _speechAvailable = await _speechToText.initialize();
  }
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ธ Feature 2: Image Understanding

You can upload a voter ID or a ballot, and the AI extracts meaning rather than just performing OCR.

{
  "parts": [
    { "text": "Explain this document" },
    { "inline_data": { "mime_type": "image/jpeg", "data": "<base64>" } }
  ]
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“… Feature 3: Smart Reminders

The AI detects dates in the conversation and suggests a "Add to Calendar" action using a hidden signal in the prompt.

๐Ÿงฉ Engineering Challenges

1. TTS Chaos Bug

Multiple voices were speaking at once during testing. I fixed this by implementing a centralized AudioController to manage the singleton state of the speech engine.

2. Civic API Limitations

Official address validation was too strict for some regions. I solved this by using Gemini to "sanitize" and interpret the user's address before sending it to the API.

๐ŸŒ 3. Multilingual Consistency

The UI and AI would sometimes mismatch languages. I built a dual-layer system to solve this:

  • Layer 1: UI Translation Map.
  • Layer 2: System prompt enforcement (e.g., "Reply strictly in Hindi").

โš–๏ธ Non-Partisan by Design

This was the most critical part of the build. I enforced neutrality through a rigorous system prompt:

  • No political opinions allowed.
  • Use only official sources.
  • Maintain a neutral, helpful tone.

๐ŸŽฏ Design Decisions

  • No Login: Zero friction and privacy-first.
  • WhatsApp-style UI: Familiar UX leads to faster adoption.
  • Multimodal AI: Because real documents are more helpful than generic answers.

๐Ÿ“Š The Results

  • โœ… 4-language support
  • โœ… Real-time election data integration
  • โœ… Voice + Vision AI
  • โœ… ~2.3 MB production build

๐Ÿ”ฎ Whatโ€™s Next?

I'm looking into offline support using local models and expanding the data set to include EU and global election formats.

The hardest problem wasnโ€™t the codeโ€”it was designing the right prompts.

Try CivicGuide Live ๐Ÿš€

๐Ÿ’ป Source Code

CivicGuide ๐Ÿ—ณ๏ธ

CivicGuide is a context-aware, multimodal, privacy-first election education assistant built with Flutter Web. It helps citizens understand their local voting processes through a conversational AI interface โ€” available in English, Hindi, Marathi, and Spanish.


๐Ÿ“Œ Chosen Vertical

Civic Education & Voter Accessibility

Elections are the foundation of democracy, yet millions of eligible voters are disenfranchised not by law, but by confusion. Complex registration forms, obscure deadlines, and bureaucratic jargon create invisible barriers โ€” especially for first-time voters, non-English speakers, and citizens navigating two very different democratic systems (the United States and India).

CivicGuide targets this problem directly: a zero-login, privacy-first AI assistant that demystifies the voting process for anyone, anywhere, in their own language.


๐Ÿง  Approach and Logic

The "Forked Path" Architecture

Rather than a generic chatbot, CivicGuide uses a guided state machine to first onboard the user (collect language + location) before routing them into the correctโ€ฆ





๐Ÿ’ฌ Let's Discuss!

Iโ€™d love to get your feedback on the architecture and the overall approach. Specifically:

  • How are you handling multilingual prompt enforcement in your own apps?
  • Do you think AI has a place in sensitive areas like civic tech, or is the risk of hallucination too high?
  • What edge cases did I miss in my non-partisan system prompt?

I'm looking forward to your "brutal" criticism!

Top comments (0)