An elegant, data-driven platform for visualizing and predicting electoral outcomes in Tamil Nadu, India.
πΊοΈ Live Demo: http://localhost:5173 (when running locally) π API Docs: http://localhost:8000/api/docs
Votelytics is a full-stack web application designed for the Tamil Nadu Assembly Elections 2026. It provides:
- Interactive Map: GeoJSON-based map with all 234 Tamil Nadu constituencies
- Historical Analysis: Complete 2021 & 2016 election results (8,242 total candidates)
- Constituency Details: Detailed view of all candidates with vote counts and margins
- Party Color Coding: Visual representation of party performance (15+ parties)
- Predictions: Data-driven electoral forecasts with confidence levels (coming soon)
- Beautiful Visualizations: Party-wise seat distribution and trends
- FastAPI - Modern, fast Python web framework
- PostgreSQL (Supabase) - Cloud-hosted database
- SQLAlchemy - Python SQL toolkit and ORM
- Poetry - Dependency management
- Pydantic - Data validation using Python type annotations
- React 18 - UI library with hooks
- TypeScript - Type-safe JavaScript
- Vite - Lightning-fast build tool
- Leaflet - Interactive maps library
- React Router - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Recharts - Data visualization
- Axios - HTTP client
- Supabase PostgreSQL - Cloud PostgreSQL database
- 5 Tables: constituencies, elections, election_results, candidates, predictions
votelytics/
βββ client/ # React + TypeScript frontend
β βββ src/
β β βββ components/ # Reusable React components
β β βββ pages/ # Page components (Home, etc.)
β β βββ services/ # API service layer
β β βββ types/ # TypeScript type definitions
β β βββ utils/ # Helper functions
β βββ public/ # Static assets
β βββ package.json # Node dependencies
β
βββ server/ # FastAPI backend
β βββ app/
β β βββ api/ # API route handlers
β β βββ models/ # SQLAlchemy database models
β β βββ schemas/ # Pydantic schemas
β β βββ services/ # Business logic
β βββ scripts/ # Database utilities
β βββ data/ # Raw data files
β βββ pyproject.toml # Python dependencies (Poetry)
β
βββ docs/ # Documentation files
βββ README.md # This file
- Python 3.10+
- Node.js 18+
- Poetry (Python package manager)
- Git
cd C:\Users\ADMIN\OneDrive\Documents\projects\votelyticscd server
poetry install # First time only
poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadβ Backend running on: http://localhost:8000
cd client
npm install # First time only
npm run devβ Frontend running on: http://localhost:5173
Navigate to: http://localhost:5173
The project uses Supabase (cloud PostgreSQL) with Session Pooler:
Connection Details:
- Host:
aws-1-ap-southeast-1.pooler.supabase.com(Session Pooler) - Database:
postgres - Connection configured in:
server/.env
Database Schema:
- constituencies - 234 TN constituencies with GeoJSON boundaries
- elections - 2 historical elections (2021 & 2016)
- election_results - 8,242 detailed results (denormalized for performance)
- candidates - Candidate profiles and backgrounds
- predictions - Electoral forecasts with confidence levels
Complete Data Loaded:
- 234 constituencies with GeoJSON boundaries (100% coverage)
- 2021 Election: 4,232 candidates across all 234 constituencies
- 2016 Election: 4,010 candidates across all 234 constituencies
- Party results: DMK 133 (2021), ADMK 134 (2016)
- All vote counts, margins, and ranks included
GET /api/constituencies/- List all constituenciesGET /api/constituencies/{id}- Get constituency detailsGET /api/constituencies/code/{code}- Get by constituency codeGET /api/constituencies/district/{district}- Filter by district
GET /api/elections/- List all electionsGET /api/elections/{id}- Get election detailsGET /api/elections/{id}/results- All results for an electionGET /api/elections/constituency/{id}/history- Historical resultsGET /api/elections/year/{year}/results- Results by year
Interactive API Docs: http://localhost:8000/api/docs
- Full Backend API with FastAPI and Supabase (10+ endpoints)
- Complete Database with 8,242 election results (2021 & 2016)
- Real GeoJSON Boundaries for all 234 Tamil Nadu constituencies
- Interactive Leaflet Map with party color-coding
- Constituency Detail Page showing 2021 & 2016 results side-by-side
- Candidate Cards with vote counts, margins, and rankings
- Party Color System for 15+ political parties
- Responsive UI with Tailwind CSS (mobile, tablet, desktop)
- Click Navigation from map to constituency details
- Session Pooler connection for IPv6 compatibility
- Batched Data Loading scripts for large datasets
- State Dashboard with overall seat tally and party-wise charts
- Comparison Features - Side-by-side 2021 vs 2016 analysis
- More Historical Data - Load 2011 and 2006 elections
- Prediction Algorithms with ML models for 2026 forecasts
- Charts & Visualizations - Vote share trends, swing analysis
- User Polls and engagement features
- Admin Panel for data management
- Authentication using Supabase Auth
If ports 5173 or 8000 are busy, the servers will automatically try the next available port.
Backend is configured to allow ports: 5173, 5174, 5175, 5176, 3000
Edit server/app/config.py to add more ports if needed.
Check server/.env file for correct Supabase credentials.
# Backend
cd server && poetry install
# Frontend
cd client && npm install- Create schema in
server/app/schemas/ - Create route handler in
server/app/api/ - Register router in
server/app/main.py
- Create component in
client/src/components/ - Define types in
client/src/types/ - Use in pages from
client/src/pages/
cd server
poetry run alembic revision --autogenerate -m "description"
poetry run alembic upgrade head- Create a feature branch
- Make your changes
- Test thoroughly
- Commit with descriptive messages
- Push and create a pull request
MIT License
- Supabase Dashboard: https://supabase.com/dashboard/project/mksoocqeoylprohcbwtr
- FastAPI Docs: https://fastapi.tiangolo.com/
- React Docs: https://react.dev/
- Leaflet Docs: https://leafletjs.com/
- Tailwind CSS: https://tailwindcss.com/
For issues or questions, check:
- The README files in individual folders (client/, server/)
- API documentation at http://localhost:8000/api/docs
- Browser console (F12) for frontend errors
- Terminal logs for backend errors
Built with β€οΈ for transparent democracy in Tamil Nadu
Current Version: MVP Complete (October 31, 2024) Data Coverage: 100% (All 234 constituencies, 2021 & 2016 elections) Total Records: 8,242 election results Features: Interactive map, constituency details, party analysis Next Milestone: State dashboard and comparison features
Last Updated: October 31, 2024