An interactive, data-backed smart city simulation prototype that bridges live environmental context with user-controlled urban planning policy variables. This project evaluates real-world environmental trade-offs in real-time, helping users visualize the impacts of infrastructure decisions.
- Developers: Vishesh Mehta & Shweta Sharma
- Organization: Karnavati University
This prototype supports the modeling and education of key UN SDGs :
- SDG 11 (Sustainable Cities and Communities): Models how cleaner transport and increased green cover reduce urban pollution and heat-island effects.
- SDG 13 (Climate Action): Evaluates the direct impact of emission-related decisions on live sustainability ratings.
- SDG 7 (Affordable and Clean Energy): Incorporates renewable energy adoption as a core driver for reducing energy demand.
- Language: Python (3.12+ recommended, tested up to Python 3.14)
- Framework: Flask 3.1.3
- Libraries: Flask-CORS 6.0.2, requests 2.34.2, python-dotenv 1.2.2
- External Data Integration: Open-Meteo Forecast and Air Quality APIs (Key-free)
- Language/Build System: Node.js (V18+ recommended) with React, Vite (5.0.0+), PostCSS, TailwindCSS (3.4.0)
- Libraries: Axios (HTTP client), Recharts (data visualization), Tailwind CSS (styling)
- Live Weather Telemetry: Collects actual temperature, humidity, wind speed, and air quality index (AQI) values.
- In-Memory Caching: Outfitted with safe caching (default: 10 minutes) and threading locks to prevent external API stampedes.
- Daily Rate Limiting: Safe per-client daily caps on api calls (configured via
DAILY_API_LIMIT) returningHTTP 429errors if exceeded. - Stale Cache Fallback: Automatically serves stale data temporarily if external telemetry sources are offline or timeouts occur.
- Weighted Simulation Logic: Translates traffic, trees, and renewable adoption levels into clamped metrics:
PollutionSustainability ScoreHeat Island EffectEnergy Usage
- Presets Handler: Offers three comparative defaults out of the box:
eco,industrial, andsmart.
Follow these steps to run the project locally on your machine.
git clone https://github.com/FrontMan-01/CityTwin.git
cd CityTwinThe backend directory contains the Flask server code (which sits in the root of the project).
# Create a virtual environment
python3 -m venv venv
# Activate the virtual environment
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtCreate a file named .env in the root folder (where app.py is located) and add the following:
CITY_NAME=London
OPENMETEO_LAT=51.5085
OPENMETEO_LON=-0.1257
OPENMETEO_TIMEZONE=Europe/London
OPENMETEO_CACHE_TTL=600
DAILY_API_LIMIT=10000(You can customize coordinates and timezone values to match your preferred city)
python app.pyThe server will run locally at http://localhost:5000.
The React frontend code is located inside the frontend subdirectory.
cd frontendnpm installnpm run devThe client app will launch at http://localhost:3000. The Vite development configuration contains a proxy mapping /api/* requests to the Flask server running on port 5000.
To execute the backend test suite covering caching, concurrency, limits, and math formulas, run:
python test_app.py