A neutral, citation-first election process assistant for voters, students, first-time voters, and citizens to understand election workflows clearly. Built for Google PromptWars Virtual 2026 - Challenge 2.
- 1. Chosen Vertical
- 2. Approach and Logic
- 3. How the Solution Works
- 4. Key Assumptions Made
- 5. Features
- 6. Tech Stack
- 7. Security & Reliability
- 8. Installation & Setup
- 9. Recent Optimizations & Testing Depth
Challenge 2 - Election Process Education
Objective: Create an assistant that helps users understand the election process, timelines, and steps in an interactive and easy-to-follow way.
CivicGuide approaches election education through dynamic multi-jurisdiction personalization and reliable, nonpartisan AI grounding.
- Localization First: Instead of providing static, generic election information, the platform prompts the user for their country of residence, state, first-time voter status, and recent address changes.
- Dual-Jurisdiction Coverage: It perfectly adapts its entire interface, timelines, glossary, quiz, and AI assistant to either India or the United States.
- Official Grounding: AI responses from Google Gemini are dynamically steered by trusted, nonpartisan local databases (ECI for India and USA.gov / Vote.gov for the USA) to strictly avoid bias, political recommendations, or obsolete URLs.
- Guided Intake Form: Gathers basic non-PII details (Country, State/UT, first-time voter status, address changes, age group).
- Dynamic Dashboard & Timeline: Generates a personalized checklist outlining the upcoming exact steps (registering, shifting address, ID requirements, polling day prep).
- Continuous Election Timeline: Offers a dynamic, scrollable timeline with complete maps and an interactive polling booth search box.
- Interactive Civic Glossary & Quiz: Empowers users to learn key democratic terms and test their knowledge with localized questions.
- Smart AI Assistant: Users can ask the AI questions in a direct conversation. It reads the user’s selected country and returns highly localized, nonpartisan answers grounded in official sources.
- Neutrality: The assistant assumes users require purely factual, operational guidance on how to vote and when to register, strictly avoiding any political or candidate bias.
- Official URLs: Assumes current official domains (e.g.,
voters.eci.gov.inandvote.gov) remain the authoritative entry points for registration. - Dynamic Session Mode: In-memory local user sessions (persisted via LocalStorage) allow any visitor to instantly switch their country profile directly within the UI on-the-fly.
- Multi-state/UT/Region guided intake
- Cross-country toggle directly from the header
- Polling booth interactive map search
- Contextual, dual-jurisdiction glossary and quiz
- Grounded Gemini AI assistant with direct country injection
- Frontend: React + TypeScript + Vite + Vanilla CSS
- Backend: Fastify + TypeScript (Node.js)
- AI Integration: Google GenAI SDK (Gemini 2.5 Flash)
- Deployment: Google Cloud Build + Google Cloud Run
- Google Cloud Secret Manager: Retrieves the
GEMINI_API_KEYsecurely in the production container to prevent API key leakage. - Google Cloud Logging: Structured JSON logging ensures detailed backend tracking, error handling, and AI API call latencies are securely visible.
- Testing Suite: Includes a complete Vitest test suite covering:
- Multi-jurisdiction timeline generation logic.
- Interactive country switching logic.
- Mocking AI responses for consistent integration testing.
- Clone the repository and navigate to the project directory:
npm install --force
- Create a
.envfile in the root directory and add your Gemini API key:GEMINI_API_KEY=your_actual_api_key_here
- Run the automated test suite:
npm run test - Start the application locally:
npm run dev
- Frontend Bundle Optimizations: Implemented dynamic import splitting with
React.lazy()andReact.Suspensefallback logic for the Map and AI Assistant pages. - Dynamic Caching: Configured a specialized Fastify caching hook with advanced
Cache-Controlheaders for all server static data routes to ensure maximum response performance. - Dual-Country Context Isolation: Extracted cross-country switching functionality into a specialized
useElectionContextcustom hook, optimizing the code for the Glossary, Journey, and Quiz pages. - Architectural Code Maturity: Added thorough JSDoc definitions across all exported functions to secure architectural documentation rigor.
- Testing Depth Expansion:
- Added exactly two Playwright E2E "Happy Path" tests to validate the voter workflow.
- Integrated a k6 benchmarking script to validate server responsiveness SLAs.