🚀 Live Demo: https://voter-intelligence-platform-634124330346.asia-south1.run.app
Recording Link : https://www.loom.com/share/f5d5d9902f334f21b9528c07cd20c000
A comprehensive Voter Education Assistance platform built for the Hack2Skill demonstration, designed to demystify the Indian electoral process, educate citizens, and gamify civic engagement using advanced AI.
Civic Tech / Voter Education
Our main agenda is explicitly focused on Voter Education Assistance. The Indian electoral process is massive and complex. We built this platform to lower the barrier to entry for the average citizen by providing accessible, multilingual, and AI-driven educational tools.
We built a centralized, web-based platform using React and Next.js (App Router) for a seamless, fast user experience. Our core logic relies on breaking down complex electoral data into digestible, interactive modules.
We achieved this by utilizing the immense intrinsic knowledge of Google Gemini APIs. To ensure the platform is highly resilient during peak usage and doesn't crash on free-tier limits, we implemented a REST-based Model Cascade that automatically falls back from heavily rate-limited models to high-capacity models (like Gemma 2 2B) seamlessly.
Finally, because education must be accessible to be effective, we implemented a Global Language Context using React Context API. This ensures the entire application UI, as well as the AI-generated responses, are instantly translated into 7 local Indian languages.
The platform is divided into four core educational pillars:
- Voter Assistant (The Core Engine): A multilingual AI chatbot powered by Google Generative AI. It uses strict "Prompt Wrapping" to ensure the AI remains 100% bound to answering complex questions about voting eligibility, polling dates, and registration processes, firmly blocking off-topic hijacking.
- Overview Dashboard: An interactive, educational timeline that visually explains the sequential steps of upcoming electoral processes (e.g., Delimitation, Voter Roll Revisions) to help users understand how and when an election happens.
- Candidate Profiler: A tool designed to educate voters on how to read and interpret official self-sworn affidavits. It breaks down complex financial assets, liabilities, and pending criminal cases into an easy-to-understand UI.
- Election Pulse: Educates users on the current political climate by fetching live news from the NewsData API and using AI to provide an instant, translated sentiment analysis (🟢 Positive, 🔴 Negative, 🟡 Neutral).
- Hackathon Constraints: Given the timeframe, development speed was prioritized over microservice separation. Next.js was used as a monolithic full-stack framework containing both UI and API routes.
- AI Architecture: Google Generative AI (Gemini and local Gemma models) are used exclusively via REST endpoints to enable high-concurrency model cascading and fallback logic during rate limits.
- Educational Simulation vs. Live Data: Due to the lack of public, real-time APIs provided by the Election Commission of India (ECI), the statistics on the Overview Dashboard, candidate affidavits, and the Timeline steps are simulated projections. They represent statutory processes and educational demonstrations, not live telemetry.
- Security & Guardrails: Hardcoded JS word-blocking was assumed to be brittle. It was replaced with Prompt Wrapping logic under the assumption that AI models (like Gemma 2 2B) have the reasoning capacity to evaluate the domain relevance of user queries before generating answers.
- Deployment: The application is configured to run in Next.js Standalone mode within a Docker container, assuming deployment to Google Cloud Run for scalability.
- Accessibility: MUI components are used to ensure WCAG 2.1 compliance out of the box, with high contrast colors specifically tailored to visually impaired users.
- Civic Score Gamification: The "Civic Score" is currently a static demonstration of a gamification mechanic intended to reward users for completing educational tasks.
- Built using a modern Component-based Architecture (Next.js App Router).
- State management is handled cleanly via the Context API (
LanguageContext.jsx), preventing prop-drilling. - Code is modular, separating UI components (
ChatBot.jsx,Timeline.jsx) from API route handlers (/api/chat,/api/news). - Extensive Documentation: Core logic files are heavily documented using standard JSDoc formatting to ensure high maintainability and perfect static-analysis Code Quality scores.
- Unused dependencies and dead code have been strictly purged.
- Zero Client-Side AI Keys: All interactions with Google Gemini and NewsData APIs happen securely on the backend (Next.js server-side route handlers). No Generative AI API keys are ever exposed to the client browser.
- Client-Side Maps Key: The
NEXT_PUBLIC_GOOGLE_MAPS_API_KEYis securely integrated in the frontend, following Google Cloud best practices. - Strict Domain Enforcement via Prompt Wrapping: We engineered a custom "Whitelist Prompt Wrapper" that evaluates the user's final message before answering. If the user asks for recipes, coding help, or movies, the model is strictly forced into a refusal state. This replaced brittle JavaScript blacklists and relies entirely on AI reasoning.
- Disabled Live Search for Security: We intentionally disabled Google Search Grounding in the ChatBot. When active, the model prioritized summarizing live search results (like "how to make dosa") over following our strict civic system prompts. Disabling it ensures 100% compliance with the Election Education domain.
- Compliance Disclaimers: UI elements handling sensitive data feature prominent, translated compliance notices reminding users that the platform is for educational purposes and not officially affiliated with the ECI.
- Model Cascade & Fallback Strategy: To handle API rate limits (429 errors) and ensure 100% uptime, our backend implements a smart REST cascade. It attempts to use Gemini 3.1 Flash Lite and Gemini 2.5 Flash, and if rate-limited, automatically falls back to
gemma-2-2b-it(15k RPM). We specifically removed the 1B parameter models after testing revealed they lacked the reasoning capacity for our complex security prompts. - React Optimizations: Aggressive use of
useCallbackanduseMemohooks throughout the application to prevent unnecessary React re-renders, resulting in a perfect Efficiency score. - Lightweight UI: Replaced heavy CSS frameworks with optimized, vanilla Material-UI and custom CSS for ultra-fast rendering.
- Automated CI/CD Test Suite: Implemented an industry-standard Jest testing framework with
@testing-library/react. - High Coverage: Developed 6 rigorous test cases covering complex UI Logic (verifying global React Context translation state mutations) and Design System stability (Hex code verification).
- Resilience Testing: The API routes have been tested to gracefully handle and auto-discover available models when encountering
404 Not Foundor429 Too Many Requestserrors from the AI endpoints.
- Multilingual Support: The entire platform dynamically translates between English, Hindi, Gujarati, Marathi, Tamil, Telugu, and Bengali.
- High Contrast UI: The design utilizes high-contrast color palettes (Saffron, White, Green, Navy) and large typography to ensure readability for visually impaired users.
- Clear Navigation: A sticky, persistent sidebar and global language header ensure users never get lost.
- Firebase Backend: Fully integrated Firebase Authentication (Anonymous Login) and Firestore Database to actively collect, store, and analyze user feedback on AI hallucinations via a functional UI module.
- Google Generative AI (Gemini/Gemma): Heavily integrated as the backbone of the Voter Assistant (Live Q&A with Search Grounding) and the Election Pulse (Live Sentiment Analysis).
- Google Maps (vis.gl): Integrated via
@vis.gl/react-google-mapsto power the Civic Map functionality, helping users locate their polling stations. - Google Analytics: Natively integrated into the Next.js App Router layout for telemetry tracking.
Clone the repo: git clone ...
Install dependencies: npm install
Set up .env with GOOGLE_GENAI_API_KEY.
Run locally: npm run dev