ElectoGuide is an interactive election learning assistant designed to educate citizens, students, and political enthusiasts about the complex electoral process of a democracy. It features a responsive browser-based UI built with Vanilla JS, HTML, and CSS (featuring a space-themed aesthetic).
This project focuses on simplifying complex civic processes using AI-driven adaptive learning and accessible design.
https://electoguide-655808244864.asia-south1.run.app
Check out the official launch post on LinkedIn.
Civic Tech & Educational Technology (EdTech) The project focuses on electoral literacy. It breaks down the democratic electoral process into an understandable, chronological journey.
ElectoGuide follows a simple but scalable architecture:
-
Frontend (Vanilla JS + HTML + CSS)
Handles UI rendering, state transitions, and user interactions. -
Backend (Python HTTP Server)
- Handles
/api/chatrequests - Connects to Gemini API
- Logs interactions to Firestore
- Handles
-
AI Layer (Google Gemini 2.5 Flash)
Generates contextual responses based on:- current stage
- user query
-
Cloud Layer (Google Cloud Run)
- Containerized deployment
- Auto-scaling backend
-
Data Layer (Firestore)
- Stores interaction logs
- Enables analytics and scalability
- Natural language understanding for unscripted queries
- Contextual, adaptive explanations based on the user's current election stage
- Dynamic answers to specific user questions (e.g., "What is the voting process?")
- State machine and core transition logic (
stateManager.js) - UI/UX design and interaction handling
- Timeline visualization
- Voice/audio TTS integration
- Offline multilingual support (English/Hindi toggle)
The architecture of ElectoGuide is built around State-Driven Adaptive Learning.
- Separation of Concerns: The application strictly separates data (
electionContent.js), state management (stateManager.js- centralized shared logic), and presentation (DOM manipulation inapp.js). - Adaptive Complexity: The core logic relies on a state machine that tracks the user's Persona (Beginner, Student, Advanced) and Learning Mode (Guided, Quick, Timeline, Quiz). The system dynamically adjusts the verbosity, tone, and depth of the explanations based on these variables.
- Directed Progression: The election process is modeled as a linear sequence of events (Announcement → Nomination → Campaigning, etc.). Users navigate this flow via a command parser that interprets actions (
next,simple,quiz,go to counting) and updates the global state.
To fulfill the requirement for meaningful integration of Google Services, ElectoGuide natively integrates multiple Google Cloud APIs:
- Google Gemini API (
gemini-2.5-flash): Powers the contextual AI assistant to provide dynamic, stage-aware explanations. - Google Cloud Firestore:
- Used to log real-time user interactions from the
/api/chatendpoint. - Each query is stored with:
- event type (user_query)
- user input
- server timestamp
- This enables analytics, debugging, and future personalization of learning paths.
- Used to log real-time user interactions from the
- Google Cloud Storage: Initialized within the backend environment to prepare for scalable static asset and state storage.
- Google Cloud Run: The entire application is containerized and deployed as a scalable, serverless container on GCP.
Why Gemini 2.5 Flash?
-
Latency Advantage: Flash provides near-instantaneous responses, which is critical for a smooth, conversational educational flow.
-
Cost Efficiency: It is highly cost-effective for generating short, contextual educational explanations at scale.
-
Dynamic Learning: The AI generates a concise, contextually accurate response that explains the complex electoral nuance, returning it directly to the UI's Learning Console.
Throughout development, our prompt structure evolved to improve accuracy and context:
- Initial Phase: Initial prompts were generic Q&A (e.g., "Answer this user question: {question}"). This resulted in overly broad answers.
- Context Injection: Improved by adding the current election stage context (e.g., "The user is in the 'Polling Day' stage. Answer: {question}").
- Final Prompt Structure:
- Persona instructions ("You are ElectoGuide, an expert AI election assistant.")
- Current stage context injected dynamically
- User query
- Output constraints ("Maximum 3–4 sentences. No markdown formatting.")
- Result: This ensured context-aware, adaptive, and consistently formatted responses.
ElectoGuide includes several accessibility and multi-modal features designed to improve usability for a diverse audience:
- Voice Input (Web Speech API): Hands-free command execution. Users can click the microphone icon 🎤 to speak their questions or commands. The system transcribes and submits them using native browser technology.
- Audio-Based Learning Mode: A native Text-to-Speech integration using the
SpeechSynthesisAPI. Users can click the "🔊 Listen" button to have the full context of the current card read aloud automatically. - Multilingual Support (English + Hindi): A rule-based offline translation system instantly translates the user interface, stage descriptions, and quiz content into Hindi dynamically.
- Interactive Visual Timeline: The "Timeline Mode" isn't just a list—it's a responsive, vertical UI stepper with glowing neon accents and pulsing waypoints that physically visualizes the user's journey through the election process.
- Accessibility Enhancements: Features include a specialized "Explain Like I'm 10" mode that simplifies vocabulary and sentence structure, alongside a design system with larger, readable fonts and ARIA-compliant button labels.
- Security & Robustness: Backend payload validation is strictly enforced with 500-character payload limits to prevent abuse and optimized header parsing to ensure the server never crashes on malformed HTTP requests.
- Lightweight backend using Python’s built-in HTTP server (no heavy frameworks)
- Minimal API calls (Gemini only triggered for user queries)
- Optimized prompt size (short responses: 3–4 sentences)
- Static frontend served efficiently via Cloud Run
- Non-blocking UI with asynchronous fetch calls
- Input validation on all incoming API requests
- Payload size limiting to prevent abuse
- Environment variables used for API key management
- Safe fallback handling if external services fail
- No sensitive data exposed to frontend
- Currently uses rule-based translation (can be replaced with real-time translation APIs)
- Voice input depends on browser support (Web Speech API limitations)
- Firestore logging is basic (can be extended for analytics dashboards)
- Future plans:
- User accounts & progress tracking
- Real-time election data integration
- Mobile-first UI optimization
To demonstrate maximum impact, use this exact narrative flow during a pitch:
- The Hook: "Imagine a first-time voter in a rural area who has no idea how an EVM works. They don't need a textbook, they need a guide."
- The Voice Demo: "Instead of typing, they can just ask." → Click the 🎤 button and speak "What is the voting process?"
- The Multimodal Shift: Let the AI generate the explanation. Then say, "But what if they don't read English well?" → Instantly switch the language dropdown to Hindi. The entire UI instantly translates offline.
- The Accessibility Win: Hit the 🔊 Listen button and let the browser read the Hindi explanation aloud.
- The Visual Finish: Switch to the "Timeline View" mode and scroll through the glowing visual journey to show how the system visualizes complex data.
-
Open your terminal (PowerShell or Command Prompt) in the project directory.
-
(Optional but recommended) Set your active project:
gcloud config set project YOUR_PROJECT_ID- For Windows PowerShell users, run:
$env:PYTHONUTF8=1- Deploy the application using the Dockerfile configuration:
gcloud run deploy electoguide --source . --region asia-south1 --project electoguide-495113 --allow-unauthenticated --port 8080Note: For first-time deployment, you must also pass your API key by adding
--set-env-vars GEMINI_API_KEY=<your-api-key>to the command above. Subsequent deployments will preserve this key.
- Wait for the build and deployment to complete. Once finished, the CLI will output a Service URL.
- Open the Service URL in your browser to access the live application.
While the Web Dashboard is the primary experience, ElectoGuide also includes a fully functional Python Command-Line Interface.
- Run the main CLI script:
python main.py
- Navigate by typing commands like
next,simple,deep,quiz, orgo to voting.