WattIf is a Toronto-focused renewable siting and city-simulation demo. The backend owns the world state, simulation engine, optimizer, planner, and optional ML bridge. The frontend renders the live map experience, keeps the client state in sync, and falls back to mock data when the backend is unavailable.
backend/ FastAPI app, simulation engine, planner, optimizer, and data loader
frontend/ Vite + React UI, Zustand store, API client, and map components
ml/ Optional ML models and inference helpers
data/ Processed Toronto datasets used by the backend
scripts/ Data extraction and preprocessing utilities
docs/ Architecture notes and supporting documentation
cd backend
uv run uvicorn app.main:app --reloadcd frontend
npm install
npm run devIf you prefer a single mental model: start the backend first, then run the frontend. The frontend will still load with mock data if the API is down, but the live experience comes from the FastAPI server.
- Processed city data is loaded from data/processed.
- backend/app/data/loader.py builds the world or falls back to seeded data.
- backend/app/state.py creates the singleton world and session state.
- backend/app/main.py exposes REST and WebSocket endpoints.
- frontend/src/api/client.ts fetches live data and falls back to mocks.
- frontend/src/store.ts keeps the UI state synchronized and drives the map panels.
See docs/architecture.md for the full system overview, folder map, and runtime diagrams.
Backend checks live under backend/pyproject.toml and frontend scripts live in frontend/package.json.
- Backend API:
uvicorn app.main:app --reload - Frontend dev server:
npm run dev - Frontend build:
npm run build - Frontend lint:
npm run lint