๐ŸŒ EduNation

EduNation Banner

An interactive geopolitical analytics & policy simulation platform
Explore real-time country data on a 3D globe, compare nations side-by-side, and simulate the impact of 25 policy levers on a country's future.

Features Stack License

--- ## ๐Ÿ“– Table of Contents - [๐Ÿ”— Check it Live](#-check-it-live) - [๐ŸŽฏ Why EduNation?](#-why-edunation) - [๐Ÿ‘ฅ Who is this for?](#-who-is-this-for) - [โœจ Feature Preview](#-feature-preview) - [๐Ÿš€ Core Features](#-core-features) - [๐Ÿง  Architecture Overview](#-architecture-overview) - [๐Ÿ› ๏ธ Tech Stack](#๏ธ-tech-stack) - [โšก Quick Start](#-quick-start) - [๐Ÿณ Docker Services](#-docker-services) - [๐ŸŸข Good First Issues](#-good-first-issues) - [๐Ÿค Contributing](#-contributing) - [โค๏ธ Support EduNation](#๏ธ-support-edunation) --- ## ๐Ÿ”— Check it Live **[๐ŸŒ Launch EduNation โ†’](https://edu-nation-j4o5.vercel.app/)** Explore the fully interactive 3D globe and simulate policy impacts directly from your browser. *(Note: Initial load may be slow as we are currently using free-tier hosting for the API.)* --- ## ๐ŸŽฏ Why EduNation? EduNation was built to make global policy and economic data interactive, intuitive, and exploratory โ€” enabling students, researchers, and curious minds to simulate "what if" scenarios and understand how nations evolve over time. ## ๐Ÿ‘ฅ Who is this for? - **Students** learning economics, geopolitics, or data analysis - **Developers** interested in data visualization and simulations - **Researchers** exploring country-level trends - **Anyone** curious about "what if" macro-policy scenarios --- ## โœจ Feature Preview ### 3D Interactive Globe ![Globe](https://raw.githubusercontent.com/zaid-ahmed-ansari/EduNation/main/frontend/src/assets/globe.png) *Click any country to explore* ### Analytics Dashboard ![Analytics](https://raw.githubusercontent.com/zaid-ahmed-ansari/EduNation/main/frontend/src/assets/analytics.png) *25+ real-time indicators* ### Policy Simulation ![Simulation](https://raw.githubusercontent.com/zaid-ahmed-ansari/EduNation/main/frontend/src/assets/simulation.png) *Adjust 25 policy sliders* ### Cross-Country Comparison ![Compare](https://raw.githubusercontent.com/zaid-ahmed-ansari/EduNation/main/frontend/src/assets/compare.png) *Side-by-side nation analysis* --- ## ๐Ÿš€ Core Features ### ๐ŸŒ Interactive 3D Globe - Photorealistic Earth rendered with **Three.js** & **React Three Fiber** - Click any country to navigate directly to its analytics dashboard - Smooth camera transitions and hover-to-label interactivity ### ๐Ÿ“Š Analytics Dashboard - **25+ real-time economic indicators** sourced from the World Bank API - **Happiness Index** from the official World Happiness Report (2009โ€“2024) - **Data Year selector** โ€” lock all metrics to any year from 2000โ€“2024 - **Progressive loading** โ€” dashboard shell loads instantly, individual metrics show spinners - Category filters: Economy, Health, Education, Trade, Energy, Demographics, Environment - GDP trend charts (nominal & inflation-adjusted), bar comparisons, and raw data inspector ### โš–๏ธ Policy Simulation Engine - **25 policy sliders** including tax rate, healthcare, UBI, carbon tax, space program, and more - Projects GDP, life expectancy, COโ‚‚ emissions, population, and happiness over 10 years - Baseline alignment warning ensures data consistency across all simulated metrics - Real-time interactive charts update as you drag sliders ### ๐Ÿ” Cross-Country Comparison - Compare any two nations side-by-side across all 25+ indicators - Visual polarity cues โ€” better values are highlighted in bold - Respects the selected Data Year for both countries ### ๐Ÿ—๏ธ Three-Tier Caching Architecture - **Redis (Upstash)** โ†’ **PostgreSQL (Supabase)** โ†’ **External API** waterfall - Once any user fetches a country's data, it's cached in Redis for instant access - Persistent fallback in Supabase's `api_cache` table - Dramatically reduces API calls and improves response times --- ## ๐Ÿง  Architecture Overview `Frontend (React) โ†’ Backend (Express) โ†’ Redis Cache โ†’ PostgreSQL โ†’ External APIs` 1. **User Request**: The React frontend requests country data. 2. **Tier 1 (Redis)**: The Express backend checks Upstash Redis. If a hit, data is returned instantly (~50ms). 3. **Tier 2 (PostgreSQL)**: On a Redis miss, it queries the Supabase `api_cache` table. If found, it backfills Redis and returns data (~200ms). 4. **Tier 3 (External API)**: If no database record exists, it fetches from the World Bank/REST Countries external APIs, parses the data, saves to Supabase, sets Redis, and returns it. --- ## ๐Ÿ› ๏ธ Tech Stack ### Frontend | Technology | Purpose | |---|---| | [React 19](https://react.dev/) | UI framework | | [TypeScript](https://www.typescriptlang.org/) | Type safety | | [Vite](https://vitejs.dev/) | Build tool & dev server | | [Three.js](https://threejs.org/) + [React Three Fiber](https://docs.pmnd.rs/react-three-fiber) | 3D globe rendering | | [TanStack Query](https://tanstack.com/query) | Async state management & caching | | [Zustand](https://zustand-demo.pmnd.rs/) | Global state (lightweight) | | [Recharts](https://recharts.org/) | Charts & data visualization | | [Tailwind CSS 4](https://tailwindcss.com/) | Utility-first styling | | [Lucide React](https://lucide.dev/) | Icons | | [GSAP](https://greensock.com/gsap/) | Scroll animations | ### Backend | Technology | Purpose | |---|---| | [Express 5](https://expressjs.com/) | REST API server | | [TypeScript](https://www.typescriptlang.org/) | Type safety | | [Supabase](https://supabase.com/) | PostgreSQL database + auth | | [Upstash Redis](https://upstash.com/) | Serverless Redis caching | | [Axios](https://axios-http.com/) | HTTP client for external APIs | ### Data Sources | Source | Data | |---|---| | [World Bank API](https://data.worldbank.org/) | 25 economic/social indicators | | [REST Countries](https://restcountries.com/) | Country metadata, flags, borders | | [World Happiness Report](https://worldhappiness.report/) | Happiness Index (2009โ€“2024) | | [Our World in Data](https://ourworldindata.org/) | COโ‚‚ emissions history | --- ## ๐Ÿ“ Project Structure ``` edunation/ โ”œโ”€โ”€ .gitignore # Root gitignore โ”œโ”€โ”€ LICENSE # MIT License โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines โ”œโ”€โ”€ CODE_OF_CONDUCT.md # Contributor Covenant โ”œโ”€โ”€ README.md # โ† You are here โ”œโ”€โ”€ schema.sql # Full database schema โ”œโ”€โ”€ DATABASE_SCHEMA.MD # Schema documentation โ”‚ โ”œโ”€โ”€ backend/ โ”‚ โ”œโ”€โ”€ .env.example # Environment variable template โ”‚ โ”œโ”€โ”€ package.json โ”‚ โ”œโ”€โ”€ tsconfig.json โ”‚ โ””โ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ index.ts # Express server entry point โ”‚ โ”œโ”€โ”€ config/ โ”‚ โ”‚ โ”œโ”€โ”€ supabase.ts # Supabase client init โ”‚ โ”‚ โ””โ”€โ”€ redis.ts # Upstash Redis client init โ”‚ โ”œโ”€โ”€ controllers/ โ”‚ โ”‚ โ”œโ”€โ”€ countryController.ts # Country + indicators endpoints โ”‚ โ”‚ โ””โ”€โ”€ simulationController.ts # Simulation + rankings endpoints โ”‚ โ”œโ”€โ”€ routes/ โ”‚ โ”‚ โ”œโ”€โ”€ index.ts # Route aggregator โ”‚ โ”‚ โ””โ”€โ”€ countryRoutes.ts# All API route definitions โ”‚ โ”œโ”€โ”€ services/ โ”‚ โ”‚ โ”œโ”€โ”€ worldBank.service.ts # WB API (Redisโ†’DBโ†’API flow) โ”‚ โ”‚ โ”œโ”€โ”€ restCountries.service.ts# REST Countries API โ”‚ โ”‚ โ”œโ”€โ”€ owid.service.ts # Our World in Data API โ”‚ โ”‚ โ””โ”€โ”€ geo.service.ts # GeoJSON service โ”‚ โ”œโ”€โ”€ utils/ โ”‚ โ”‚ โ””โ”€โ”€ cache.ts # Multi-tier caching utility โ”‚ โ”œโ”€โ”€ data/ โ”‚ โ”‚ โ”œโ”€โ”€ unified_happiness.json # Happiness 2009โ€“2024 โ”‚ โ”‚ โ””โ”€โ”€ owid_co2.json # Pre-cached COโ‚‚ emissions โ”‚ โ””โ”€โ”€ scripts/ โ”‚ โ””โ”€โ”€ ingest.ts # Full DB population script โ”‚ โ””โ”€โ”€ frontend/ โ”œโ”€โ”€ .env.example # Environment variable template โ”œโ”€โ”€ package.json โ”œโ”€โ”€ index.html โ”œโ”€โ”€ vite.config.ts โ””โ”€โ”€ src/ โ”œโ”€โ”€ main.tsx # React entry point โ”œโ”€โ”€ App.tsx # Root component + routing โ”œโ”€โ”€ index.css # Global styles โ”œโ”€โ”€ api/ โ”‚ โ””โ”€โ”€ index.ts # Axios API client โ”œโ”€โ”€ components/ โ”‚ โ”œโ”€โ”€ 3d/Globe.tsx # Three.js globe component โ”‚ โ”œโ”€โ”€ layout/SearchOverlay.tsx # Country search UI โ”‚ โ”œโ”€โ”€ simulation/ โ”‚ โ”‚ โ”œโ”€โ”€ PolicyPanel.tsx # 25-slider policy panel โ”‚ โ”‚ โ””โ”€โ”€ ProjectionChart.tsx # Simulation result charts โ”‚ โ””โ”€โ”€ ui/ # Reusable UI primitives โ”œโ”€โ”€ pages/ โ”‚ โ”œโ”€โ”€ LandingPage.tsx # Hero + 3D globe landing โ”‚ โ”œโ”€โ”€ AnalyticsDashboard.tsx # Full analytics view โ”‚ โ”œโ”€โ”€ SimulationDashboard.tsx # Policy simulation view โ”‚ โ””โ”€โ”€ ReferencePage.tsx # Reference/about page โ”œโ”€โ”€ simulation/ โ”‚ โ””โ”€โ”€ engine.ts # Simulation computation engine โ”œโ”€โ”€ store/ โ”‚ โ”œโ”€โ”€ uiStore.ts # UI state (Zustand) โ”‚ โ””โ”€โ”€ simulationStore.ts # Simulation state (Zustand) โ””โ”€โ”€ utils/ โ””โ”€โ”€ formatters.ts # Number/currency formatters ``` --- ## โšก Quick Start ### Prerequisites - [Docker Desktop](https://www.docker.com/products/docker-desktop/) with Docker Compose ### 1. Clone the Repository ```bash git clone https://github.com/zaid-ahmed-ansari/EduNation.git cd EduNation ``` ### 2. Start the Full Stack (Docker) ```bash docker compose up -d --build ``` This starts all required containers (frontend, backend, postgres, redis) and runs schema initialization automatically before the backend starts. Note: For local Docker development, you do not need to create or edit backend .env. Development environment variables (including NODE_ENV=development) are already provided in docker-compose.yml. ### 3. (Optional) Seed Data If you want local Postgres to contain preloaded indicator data: ```bash docker compose exec backend npx tsx src/scripts/ingest.ts ``` ### 4. Open in Browser Navigate to **http://localhost:5173** and explore the globe! ๐ŸŒ ### 5. Useful Docker Commands ```bash # View running services docker compose ps # View backend logs docker compose logs -f backend # Stop everything docker compose down # Stop and remove volumes (fresh DB/Redis) docker compose down -v ``` --- ## ๐Ÿณ Docker Services EduNation runs with these services in [docker-compose.yml](./docker-compose.yml): - `frontend` (`edunation-frontend`): Vite React app on `http://localhost:5173` - `backend` (`edunation-backend`): Express API on `http://localhost:5000` - `postgres` (`edunation-postgres`): PostgreSQL 16 on `localhost:5432` - `redis` (`edunation-redis`): Redis 7 on `localhost:6379` - `db-init` (`edunation-db-init`): one-time schema bootstrap job that applies [SCHEMA.SQL](./SCHEMA.SQL) if tables are missing Schema bootstrap logic lives in [scripts/init-db.sh](./scripts/init-db.sh). --- ## ๐ŸŸข Good First Issues - Improve UI responsiveness on smaller mobile screens - Add more countries to the simulation baseline dataset - Enhance React chart performance for large datasets - Improve caching strategy documentation inside the codebase --- ## ๐Ÿค Contributing We welcome contributions! Please read our [Contributing Guidelines](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) before getting started. 1. Fork the project 2. Create your feature branch (`git checkout -b feat/amazing-feature`) 3. Commit your changes (`git commit -m 'feat: add amazing feature'`) 4. Push to the branch (`git push origin feat/amazing-feature`) 5. Open a Pull Request --- ## ๐Ÿ“„ License Distributed under the **MIT License**. See [`LICENSE`](./LICENSE) for details. --- ## ๐Ÿ™ Acknowledgments - [World Bank Open Data](https://data.worldbank.org/) for economic indicators - [World Happiness Report](https://worldhappiness.report/) for happiness index data - [REST Countries](https://restcountries.com/) for country metadata - [Our World in Data](https://ourworldindata.org/) for environmental data - [Supabase](https://supabase.com/) for the database platform - [Upstash](https://upstash.com/) for serverless Redis ---

Built with โค๏ธ by Zaid Ahmed Ansari

โค๏ธ Support EduNation

If you find this project useful, you can support its development:

๐Ÿ‡ฎ๐Ÿ‡ณ UPI Support

Your support helps cover API & server costs and keeps EduNation free for everyone.