AI-powered Sustainable Development Analytics Platform
Live app: https://hijabf-ai4sdg-insights-app-ak34e9.streamlit.app/
A production-quality Streamlit dashboard that combines World Bank Open Data with Google Gemini AI to explore development indicators, compare countries, and generate cautious UNDP-style policy insights.
Designed as a polished portfolio project with a professional UN / UNDP visual language — blue-and-white palette, card layouts, and modular architecture.
AI4SDG Insights helps analysts and students:
- Explore Sustainable Development-related indicators for Pakistan, India, and Bangladesh
- View KPI cards, interactive Plotly charts, and summary statistics
- Map each indicator to a related UN Sustainable Development Goal (SDG)
- Generate grounded AI policy briefs via Gemini (executive summary, why it matters, challenges, recommended actions)
- Overlay a 5-year linear forecast and a heuristic SDG risk score
- Download CSV and professionally formatted PDF reports
| Area | Capabilities |
|---|---|
| Data | Live World Bank API, 1-hour cache, missing-value cleaning, graceful failure handling |
| Indicators | Population, GDP, Life Expectancy, Internet Users, Unemployment, CO₂ Emissions, Access to Electricity, Primary School Enrollment |
| Analytics | Latest value, YoY growth, polarity-aware trend, average / min / max, overall growth |
| Visuals | Interactive Plotly charts (hover, zoom, pan, image download), multi-country comparison |
| SDG Mapping | Dedicated module linking indicators to SDG number, title, description, and icon |
| AI Insights | Gemini policy analyst prompt; quota-aware error handling; ~180-word briefs |
| Forecast | Optional 5-year OLS forecast with dashed overlay and R² |
| Risk Score | Heuristic 0–100 SDG risk score with confidence and factors |
| Export | CSV + SDG Progress Note PDF (limitations, equity, 2030 scenario, AI notes) |
| Equity (LNOB) | Urban–rural / gender disaggregation where World Bank series exist |
| Data integrity | Coverage %, missing years, freshness, “what this cannot tell us” |
| 2030 scenarios | Bounded baseline vs adjusted growth paths to Agenda 2030 |
| UX | Wide layout, dark/light mode, sidebar search, toasts, spinners, footer |
AI4SDG_Insights/
├── app.py # Streamlit UI entry point
├── data_loader.py # World Bank API client + caching
├── analytics.py # Statistics, forecast, risk score
├── ai_insights.py # Gemini policy insight generation
├── sdg_mapping.py # Indicator ↔ SDG metadata
├── utils.py # Theming, charts, PDF/CSV helpers
├── requirements.txt
├── LICENSE
├── README.md
└── .streamlit/
└── secrets.toml.example
- Python 3.9+ (3.10 or 3.11 recommended)
- Internet access for World Bank API and Gemini
- A Google AI Studio / Gemini API key (for AI insights)
Python packages are listed in requirements.txt.
# 1. Navigate to the project
cd AI4SDG_Insights
# 2. Create and activate a virtual environment (recommended)
python -m venv .venv
# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS / Linux
source .venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt- Obtain an API key from Google AI Studio.
- Create Streamlit secrets:
# Windows
copy .streamlit\secrets.toml.example .streamlit\secrets.toml
# macOS / Linux
cp .streamlit/secrets.toml.example .streamlit/secrets.toml- Edit
.streamlit/secrets.toml:
GEMINI_API_KEY = "your-actual-api-key"Never commit real API keys. The app reads the key only from
st.secrets["GEMINI_API_KEY"].
streamlit run app.pyThe app opens in your browser (typically http://localhost:8501).
- Choose country and indicator (optionally search)
- Adjust the year range
- Toggle forecast and dark mode as needed
- Click ✨ AI Insight for a policy brief
- Click 📥 Prepare Report, then download CSV / PDF
Already live on Streamlit Community Cloud:
https://hijabf-ai4sdg-insights-app-ak34e9.streamlit.app/
To redeploy or fork:
- Push to GitHub (public).
- Open share.streamlit.io → New app → Main file:
app.py. - In App settings → Secrets, add:
GEMINI_API_KEY = "your-actual-api-key"World Bank charts work without a key. Only AI Insight needs GEMINI_API_KEY.
| View | Description |
|---|---|
| Main dashboard — KPI cards + trend chart (light mode) | |
| Pakistan / India / Bangladesh comparison | |
| Gemini policy brief panel | |
| Dark mode theme |
All time series are fetched from the World Bank Open Data API:
| Indicator | World Bank Code |
|---|---|
| Population | SP.POP.TOTL |
| GDP | NY.GDP.MKTP.CD |
| Life Expectancy | SP.DYN.LE00.IN |
| Internet Users | IT.NET.USER.ZS |
| Unemployment | SL.UEM.TOTL.ZS |
| CO₂ Emissions | EN.GHG.CO2.MT.CE.AR5 |
| Access to Electricity | EG.ELC.ACCS.ZS |
| Primary School Enrollment | SE.PRM.ENRR |
| Indicator | SDG | Goal |
|---|---|---|
| Internet Users | SDG 9 | Industry, Innovation and Infrastructure |
| Population | SDG 11 | Sustainable Cities and Communities |
| Life Expectancy | SDG 3 | Good Health and Well-Being |
| GDP | SDG 8 | Decent Work and Economic Growth |
| Access to Electricity | SDG 7 | Affordable and Clean Energy |
| CO₂ Emissions | SDG 13 | Climate Action |
| Primary School Enrollment | SDG 4 | Quality Education |
- Wide Streamlit layout with Montserrat / Source Sans typography
- UN-inspired blue & white palette with soft shadows and rounded cards
- Business logic separated from UI (
data_loader,analytics,ai_insights) - PEP 8-oriented modular Python; no notebook / Colab patterns
- Polarity-aware trend labels (rising unemployment is a watch signal, not “improving”)
- Expand country coverage beyond South Asia (ASEAN, Sub-Saharan Africa, etc.)
- Add multi-indicator correlation and radar charts
- Support additional Gemini models and streaming responses
- Persist user preferences (theme, last selection) via query params
- Multilingual UI (EN / UR / BN / HI)
- Official UNDP colour tokens and SDG icon assets
- Unit tests and CI for data cleaning / analytics
AI4SDG Insights is an educational / portfolio application. It is not an official United Nations or UNDP product. AI-generated text is illustrative and must be validated against official statistics and national planning frameworks before any policy use.
MIT — feel free to adapt for learning and portfolio showcases.