Skip to main content

public 3d-motion repository

EduNation

// Zaid-Ahmed-Ansari/EduNation

๐ŸŒ NationHub โ€” A full-stack interactive geopolitical analytics and policy simulation platform. Explore real-time country data, compare nations side-by-side, and simulate policy impacts with an immersive 3D globe interface. Built with React, Three.js, Express, Supabase & Redis.

$ git log --oneline --stat
stars:2forks:1updated:2026-03-25
README.md
readonly

EduNation Banner

Features

Stack

License


๐Ÿ“– Table of Contents


๐Ÿ”— Check it Live

๐ŸŒ Launch EduNation โ†’

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 Click any country to explore

Analytics Dashboard

Analytics 25+ real-time indicators

Policy Simulation

Simulation Adjust 25 policy sliders

Cross-Country Comparison

Compare 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

TechnologyPurpose
React 19UI framework
TypeScriptType safety
ViteBuild tool & dev server
Three.js + React Three Fiber3D globe rendering
TanStack QueryAsync state management & caching
ZustandGlobal state (lightweight)
RechartsCharts & data visualization
Tailwind CSS 4Utility-first styling
Lucide ReactIcons
GSAPScroll animations

Backend

TechnologyPurpose
Express 5REST API server
TypeScriptType safety
SupabasePostgreSQL database + auth
Upstash RedisServerless Redis caching
AxiosHTTP client for external APIs

Data Sources

SourceData
World Bank API25 economic/social indicators
REST CountriesCountry metadata, flags, borders
World Happiness ReportHappiness Index (2009โ€“2024)
Our World in DataCOโ‚‚ 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

1. Clone the Repository

git clone https://github.com/zaid-ahmed-ansari/EduNation.git
cd EduNation

2. Start the Full Stack (Docker)

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:

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

# 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:

  • 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 if tables are missing

Schema bootstrap logic lives in 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 and Code of Conduct 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 for details.


๐Ÿ™ Acknowledgments


README image

metadata.json
TypeScriptdata-visualizationopen-sourcereactSimulationsThree.js

[INFO] 2 topics link to curated motion topic pages.