NepalPulse 2082 is a real-time, high-performance web dashboard for tracking the Nepal Federal Elections. Designed for mobile-first user experience and optimized for high traffic, it provides live vote counts, interactive constituency maps, head-to-head candidate matchups, and community features.
- ⚡ Real-time Vote Tracking: Pulls live data directly from the official Election Commission (
result.election.gov.np) using a heavily cached, Stale-While-Revalidate (SWR) background syncing architecture. - 📱 Mobile-Optimized UI/UX: Features a sleek, app-like mobile experience with safe-area padding, bottom tab bar navigation, Apple Web App integration, and touch-optimized interactions.
- ⚔️ Key Races Dashboard: Pinned head-to-head matchups for major constituencies (e.g., KP Oli vs Balen Shah in Jhapa-5, Aashika Tamang vs Rajendra Prasad Pandey in Dhading-1).
- 🔍 High-Performance Search: Fast, case-insensitive text search using PostgreSQL
pg_trgmGIN indexes to instantly filter 3,400+ candidates across 165 constituencies. - 💬 Anonymous Community: Interactive mock voting and threaded comment sections (integrated via Supabase).
- Frontend: Next.js (App Router), React 18, Tailwind CSS, Lucide React
- Backend: Next.js API Routes (Node.js)
- Database: Supabase (PostgreSQL with Row Level Security and Realtime Pub/Sub)
- Caching Strategy: In-memory caching + HTTP Stale-While-Revalidate for EC API protection under high load.
- Node.js (v18+)
- npm or pnpm
- A Supabase project
-
Clone the repository:
git clone https://github.com/asbinthapa99/election-count-.git cd election-count- -
Install dependencies:
npm install # or pnpm install -
Environment Variables: Create a
.env.localfile in the root directory and add your Supabase credentials:NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key NEXT_PUBLIC_SITE_URL=http://localhost:3000
-
Database Setup: Open your Supabase SQL Editor and run the entire contents of the
/supabase/full_setup.sqlfile. This will safely reset the schema, configure RLS, set up performance indexes, and seed the initial 165 constituencies. -
Run the development server:
npm run dev # or pnpm devOpen http://localhost:3000 with your browser to see the result.
To ensure the website remains fast and stable during election day traffic spikes without overwhelming the government's origin servers:
- API Route (
/api/candidates/ec): Acts as a proxy and cache. It hits the EC JSON dumps, caches them in memory, and returns them to the user. If the cache is stale, it serves the stale data immediately while triggering a background fetch to the EC. - Build & Rendering: Pages are heavily optimized, pre-fetching data securely and avoiding unnecessary React hydration re-renders.