CoolFace
Apppublic

Sajid-ul-Islam/Global-Economical-Analytics

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

๐Ÿ“Š EconVision โ€” Global Economic Intelligence Dashboard

A full-stack data science portfolio project built on real economic data: live World Bank + FRED APIs, ML forecasting, AI chat agent, and interactive multi-country analysis. Deployed on Streamlit Cloud.

Live App: global-economics.streamlit.app


Features

FeatureDetails
โšก High Performance90% reduction in database overhead via batched bulk upserts and Streamlit memory snapshots
๐Ÿ“ˆ Live DataWorld Bank API (GDP, GDP per capita, debt, inflation, unemployment) + FRED (gold, silver, oil, DXY)
๐Ÿ”ฎ ML ForecastingProphet time-series predictions to 2031 with 80% confidence intervals; linear trend fallback
๐ŸŒ World MapAnimated choropleth across all countries โ€” continuous scale or 5-tier debt risk categories
๐Ÿ—บ๏ธ Global Debt Coverage173-country static debt snapshot (data/global_debt_2024.csv) fills map gaps instantly
๐Ÿ” ComparisonBar charts with debt threshold reference lines, correlation scatter (coloured by country), ranking tables
๐Ÿงช What-If SimulatorAdjust GDP growth and debt trajectory; compare against Prophet ML baseline
๐Ÿšจ Anomaly DetectionZ-score based flagging of unusual year-over-year changes
๐Ÿ† Health ScoresComposite 0โ€“100 index from GDP per capita, debt, inflation, and unemployment
๐ŸŽฒ 3D AnimationThree-indicator multivariate scatter in 3D space with animated year progression
๐Ÿ“‰ Macro TrendsUSD purchasing power erosion (1970โ€“2024) + Gold vs Silver dual-axis chart
๐Ÿค– AI AgentClaude-powered chat with in-context RAG, semantic cache, and 4-model fallback chain
๐Ÿ—„๏ธ Data LabProvenance tracking, freshness dashboard, cross-source verification, CSV/JSON export

Pages

PageDescription
DashboardKPI cards, YoY deltas, health score gauges, timeline charts, anomaly flags
CompareBar comparisons, correlation explorer, ranking table, what-if simulator; auto-detects org group (NATO, G7, BRICSโ€ฆ)
World MapAnimated choropleth with risk-category toggle for debt indicator
Data LabRaw data explorer, freshness monitor, live verification, export, AI chat agent
Macro TrendsUSD purchasing power chart, Gold vs Silver history with G/S ratio

Architecture

econ-dashboard/
โ”œโ”€โ”€ app.py                     # Entry point + routing
โ”œโ”€โ”€ pages/
โ”‚   โ”œโ”€โ”€ Dashboard.py           # KPIs, timelines, anomalies, health scores
โ”‚   โ”œโ”€โ”€ Compare.py             # Bar charts, correlation, rankings, what-if
โ”‚   โ”œโ”€โ”€ World_Map.py           # Choropleth world map with risk categories
โ”‚   โ”œโ”€โ”€ Data_Lab.py            # Provenance, freshness, verification, export, AI agent tab
โ”‚   โ””โ”€โ”€ Macro_Trends.py        # USD purchasing power + precious metals
โ”œโ”€โ”€ components/
โ”‚   โ””โ”€โ”€ charts.py              # All Plotly components (timeline, bar, gauge, correlation, debt classify)
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ data_fetcher.py        # World Bank + FRED APIs, static debt CSV loader
โ”‚   โ”œโ”€โ”€ database.py            # Supabase CRUD (upsert, fetch, freshness, query log)
โ”‚   โ”œโ”€โ”€ forecasting.py         # Prophet + linear fallback, anomaly detection, health score
โ”‚   โ”œโ”€โ”€ agent.py               # Claude RAG: context builder, semantic cache, model router
โ”‚   โ””โ”€โ”€ ui.py                  # Sidebar (countries, indicators, year range) + CSS theme
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ global_debt_2024.csv   # 173-country static debt snapshot (IMF/WB 2024)
โ”œโ”€โ”€ .streamlit/
โ”‚   โ”œโ”€โ”€ config.toml            # Dark theme config
โ”‚   โ””โ”€โ”€ secrets.toml.example   # Keys template
โ”œโ”€โ”€ agent.md                   # AI Agent architecture documentation
โ”œโ”€โ”€ skill.md                   # Analytical skills documentation
โ”œโ”€โ”€ Dockerfile                 # Container build
โ”œโ”€โ”€ docker-compose.yml         # Local container stack
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ packages.txt

Data Sources

SourceIndicatorsRefreshAPI Key
World Bank APIGDP, GDP per capita, Debt/GDP, Inflation, Unemployment, Life ExpectancyAuto, 24h TTLNot required
FRED (St. Louis Fed)Gold price, Silver price, Brent oil, US Dollar Index (DXY)Auto, 24h TTLFree โ€” get one
Static CSVGlobal debt snapshot (173 countries, 2024)FixedNot required

Setup

1. Create Supabase tables

Go to supabase.com โ†’ new project โ†’ SQL Editor and run:

sql
CREATE TABLE IF NOT EXISTS economic_data (
    id BIGSERIAL PRIMARY KEY,
    country_code VARCHAR(3) NOT NULL,
    country_name TEXT NOT NULL,
    indicator VARCHAR(50) NOT NULL,
    year INTEGER NOT NULL,
    value FLOAT,
    source TEXT,
    fetched_at TIMESTAMPTZ DEFAULT NOW(),
    verified_at TIMESTAMPTZ,
    UNIQUE (country_code, indicator, year)
);

CREATE TABLE IF NOT EXISTS predictions (
    id BIGSERIAL PRIMARY KEY,
    country_code VARCHAR(3) NOT NULL,
    indicator VARCHAR(50) NOT NULL,
    year INTEGER NOT NULL,
    predicted FLOAT NOT NULL,
    lower_bound FLOAT,
    upper_bound FLOAT,
    model TEXT DEFAULT 'prophet',
    created_at TIMESTAMPTZ DEFAULT NOW(),
    UNIQUE (country_code, indicator, year, model)
);

CREATE TABLE IF NOT EXISTS data_freshness (
    id BIGSERIAL PRIMARY KEY,
    country_code VARCHAR(3) NOT NULL,
    indicator VARCHAR(50) NOT NULL,
    last_fetched TIMESTAMPTZ DEFAULT NOW(),
    last_verified TIMESTAMPTZ,
    status TEXT DEFAULT 'ok',
    UNIQUE (country_code, indicator)
);

CREATE TABLE IF NOT EXISTS query_log (
    id BIGSERIAL PRIMARY KEY,
    query TEXT NOT NULL,
    response TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

Copy your Project URL and anon/public key from Settings โ†’ API.

2. Local development

bash
git clone https://github.com/Sajid-ul-Islam/econmical-dashboard.git
cd econ-dashboard
pip install -r requirements.txt

cp .streamlit/secrets.toml.example .streamlit/secrets.toml
# Fill in your keys, then:
streamlit run app.py

3. Streamlit Cloud deployment

  1. 1.Push to GitHub.
  2. 2.Go to share.streamlit.io โ†’ connect repo โ†’ main file: app.py.
  3. 3.Under Advanced Settings โ†’ Secrets, paste:
toml
[supabase]
url = "https://xxxx.supabase.co"
key = "your-anon-key"

[anthropic]
api_key        = "sk-ant-..."
groq_key       = "gsk_..."
openrouter_key = "sk-or-..."
huggingface_key = "hf_..."

[fred]
api_key = "your-fred-key"
  1. 1.Deploy.

4. Docker (optional)

bash
docker-compose up --build
# App runs at http://localhost:8501

AI Agent

The agent uses In-Context RAG โ€” it serialises the currently loaded DataFrame into a structured prompt and sends it with every query. No vector database required. It tries four providers in order (Claude โ†’ Groq โ†’ Gemini โ†’ OpenRouter) and reports which model answered. A TF-IDF semantic cache (threshold 0.97) avoids redundant API calls for repeated questions.

See `agent.md` for full architecture details.


Analytical Skills

See `skill.md` for detailed documentation of all 9 analytical capabilities:

  1. 1.ML Time-Series Forecasting (Prophet + fallback)
  2. 2.Statistical Anomaly Detection (Z-score)
  3. 3.Composite Economic Health Scoring (4-factor)
  4. 4.Scenario Simulation / What-If Analysis
  5. 5.Cross-Source Verification (drift detection)
  6. 6.3D Multivariate Animation
  7. 7.Debt Risk Classification (5-tier)
  8. 8.USD Purchasing Power Erosion
  9. 9.Precious Metals Comparison (Gold vs Silver)

Sources: World Bank Open Data ยท FRED (Federal Reserve Bank of St. Louis) ยท IMF/WB debt estimates ยท BLS CPI data ยท Anthropic Claude