"The world's largest democracy begins with you."
PromptWars: Virtual β Build with AI, Challenge 2 Vertical: Election Process Education Assistant
ElectIQ is a production-ready, dual-mode interactive election education platform built for Indian voters β especially first-time voters. It combines visual exploration with structured learning and AI-powered assessment, all wrapped in a vintage civic handbook aesthetic that honours the weight and history of Indian democracy.
| Mode | Description |
|---|---|
| The Flow Map | Visual node-based flowchart of the complete Indian election lifecycle (7 stages). Every node is clickable β opens a rich dossier side panel with pre-written accurate content, a timeline marker, and an inline Gemini AI chat scoped to that stage. |
| Learn & Quiz | A structured 7-module lesson journey with progress saved to Firestore. After each module, Gemini generates a fresh 4-question quiz. Final reward: a personalised Voter Readiness Certificate generated by Gemini and downloadable as PDF. |
| Service | How It's Used |
|---|---|
Google Gemini API (gemini-1.5-flash) |
Flowmap per-stage AI chat, dynamic quiz generation (4 MCQs per module), score encouragement messages, personalised voter checklist |
| Firebase Authentication | Google Sign-In (OAuth popup) and Email/Password auth β no anonymous sessions |
| Firebase Hosting | Static site deployment with security headers and CDN |
| Firebase Firestore | Persists user progress (completed modules, quiz scores, explored stages) per authenticated UID |
| Google Fonts | Playfair Display, Crimson Pro, Hind, IM Fell English β all loaded with font-display: swap |
| Google Translate Widget | All 22 scheduled Indian languages accessible from the header |
| Google Analytics 4 | Page views, user sessions, quiz interactions tracked |
ElectIQ/
βββ index.html β Landing page (public) β smart CTA swap for signed-in users
βββ login.html β Auth gate β Google Sign-In + Email/Password
βββ flowmap.html β Interactive election lifecycle flowchart (protected)
βββ learn.html β 7-module lesson journey (protected)
βββ quiz.html β Gemini-generated MCQ quiz (protected)
βββ checklist.html β Personalised Voter Readiness Certificate (protected)
βββ css/
β βββ base.css β Design system: all CSS variables, resets, shared components
β βββ landing.css β Landing page specific styles
β βββ auth.css β Login card, Google button, form fields, avatar dropdown
β βββ flowmap.css β Flowchart, node cards, dossier side panel, Gemini chat
β βββ learn.css β Lesson card, progress bar with tally marks
β βββ quiz.css β MCQ answer sheets, correct/wrong stamps, score card
β βββ checklist.css β Gazette document style, print stylesheet
βββ js/
β βββ config.js β GITIGNORED: Firebase + Gemini credentials (copy from config.example.js)
β βββ config.example.js β Safe template β commit this, not config.js
β βββ auth.js β Firebase Auth: Google sign-in, email/password, sign-out, auth guard
β βββ header.js β Auth guard runner + user avatar dropdown for protected pages
β βββ gemini.js β Gemini REST API wrapper: sanitization, debounce, caching, JSON parsing
β βββ firebase.js β Firestore progress tracker using authenticated UID
β βββ flowmap.js β Stage data, node rendering, dossier logic, Gemini chat
β βββ learn.js β 7 lesson modules, progress bar, Firebase save/restore
β βββ quiz.js β Quiz generation, MCQ rendering, answer feedback, score summary
β βββ checklist.js β Checklist generation, phase grouping, print, Web Share API
β βββ translate.js β Google Translate widget init
βββ assets/icons/ β SVG line-art icons for each of the 7 election stages
βββ .gitignore β Excludes js/config.js and other non-committed files
βββ firebase.json β Firebase Hosting config with security headers
βββ README.md
- User opens
flowmap.htmlβ theflowmap.jsmodule renders 7 node cards in three colour-coded phase groups (Pre-Election in Saffron, Election Day in Green, Post-Election in Navy) - Clicking a node slides in a manila folder dossier panel from the right
- The dossier shows 3β4 paragraphs of pre-written, ECI-accurate content + a timeline marker
- The "ASK GEMINI β" rubber stamp button opens an inline chat panel scoped to that stage
- Chat history is maintained per stage within the session
- Explored stages get a green ink checkmark stamp; state persists via Firestore
- User opens
learn.htmlβ progress is restored from Firestore on returning visits - One lesson module at a time, displayed in a khadi white card with ruled-line texture
- "Next Module β" advances and saves progress; "Test Me on This" links to the quiz
quiz.html?module=Ncalls Gemini to generate 4 MCQs for that module (cached in sessionStorage)- Users select answers, submit per question, receive immediate correct/wrong stamp feedback
- After all 4 questions, a score summary card appears with a Gemini-generated encouragement message
- After all 7 modules, the user is directed to
checklist.html - Gemini generates a personalised 8β10 item voter checklist grouped by phase (Before/During/After)
- Users can tick off items, download as PDF via
window.print(), or share via the Web Share API
- A modern web browser (Chrome, Firefox, Safari, Edge)
- A text editor
- Internet access (for Google Fonts, Firebase SDK, Gemini API)
-
Clone the repository
git clone https://github.com/Atrijaa-Biswas/electiq.git cd electiq -
Create your config file
cp js/config.example.js js/config.js
-
Fill in your credentials in
js/config.js:- Gemini API key: Get from Google AI Studio
- Firebase config: Create a project at Firebase Console, enable Hosting, Firestore (in production mode), and Anonymous Auth. Copy the Web App config object.
- GA4 Measurement ID: Optional β create a GA4 property at analytics.google.com
-
Open locally
The simplest way is to use the VS Code Live Server extension, or any static file server:
# Python python -m http.server 8080 # Node npx serve .
Then open
http://localhost:8080in your browser.Note:
file://protocol won't work for the Firebase SDK module imports. You must use a local HTTP server.
-
Install Firebase CLI
npm install -g firebase-tools
-
Login
firebase login
-
Initialize project (first time only)
firebase init hosting # Choose your Firebase project # Set public directory to: . # Configure as single-page app: No
-
Deploy
firebase deploy --only hosting
-
Firestore Security Rules β in Firebase Console β Firestore β Rules, set:
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /users/{userId} { allow read, write: if request.auth != null && request.auth.uid == userId; } } }
ElectIQ uses Firebase Authentication with real user accounts rather than anonymous sessions. This means:
- Progress is tied to a real identity and persists across browsers and devices
- Firestore security rules can enforce strict per-user data isolation
- Users can sign in with their Google account (one tap) or email/password
- All quiz scores, explored stages, and lesson progress belong to the user's UID, not a transient session token
- Go to Firebase Console β Authentication β Sign-in method
- Enable Google β set a project support email
- Enable Email/Password
- Do NOT enable Anonymous, Phone, or any other provider
Each protected page (flowmap.html, learn.html, quiz.html, checklist.html) starts with body { opacity: 0 }. The page JS calls HeaderController.init() before any rendering. This internally calls onAuthStateChanged from Firebase Auth:
- If the user is signed in β body is revealed, user avatar is rendered in the header
- If not signed in β browser immediately redirects to
login.htmlbefore the user can see any content
This prevents any flash of protected content before redirect.
Paste these exact rules in Firebase Console β Firestore β Rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/{document=**} {
allow read, write: if request.auth != null
&& request.auth.uid == userId;
}
}
}This means:
- Unauthenticated requests are denied entirely
- Each signed-in user can only read and write documents under their own UID path
- No user can access another user's progress data
js/config.jsis listed in.gitignoreβ never commit it- All user input is sanitized (HTML stripped, 500-char limit) before reaching Gemini
- Display names are sanitized (HTML stripped, max 50 chars) before being stored in Firebase Auth profile
- Content Security Policy meta tags on every HTML page restrict scripts to trusted Google domains
- Firestore rules restrict each user to their own document path
- Firebase SDK manages ID tokens internally β tokens are never manually stored or exposed
- All external resources loaded over HTTPS
- Users have modern browsers (ES6+ module support)
- Gemini API key has sufficient quota for quiz/chat usage
- Firebase project has Firestore, Google Sign-In, Email/Password Auth, and Hosting enabled
- The platform is designed for educational use β content accuracy is based on ECI public documentation as of 2024
- The Google Translate widget is sufficient for multilingual support (no custom translation API calls)
window.print()PDF generation is acceptable β no server-side PDF library required- Google Sign-In popup works in the deployment environment (popups must not be blocked)
The UI aesthetic is inspired by post-independence Indian civic documents β aged parchment backgrounds, sepia ink borders, Playfair Display headlines, and Ashoka Chakra watermarks. All animations are slow and deliberate (no flashy effects). The design passes WCAG AA contrast requirements and is fully keyboard navigable.
MIT License β see LICENSE for details.
Built for PromptWars: Virtual β Build with AI, Challenge 2. ElectIQ is an independent civic education tool and is not affiliated with the Election Commission of India.