An interactive web application for visualizing and analyzing economic data from the World Bank API. This dashboard allows users to explore GDP trends, population data, and economic indicators for countries worldwide with AI-powered analytics.
https://world-GDP-trend.streamlit.app/
- 📊 Interactive Visualizations: Explore GDP, GDP per capita, GDP PPP, and population trends over time
- 🗺️ Global Coverage: Data for 200+ countries including Taiwan with continent filtering
- 🔍 SQL Query Interface: Direct database querying with DuckDB integration
- 🤖 AI-Powered Analytics: Natural language to SQL conversion and data analysis using ModelScope API
- 📈 Year-over-Year Growth: Automatic calculation of GDP per capita growth rates
- 🌐 Multilingual Support: Full English and Chinese interface with country name translations
- 💾 Data Persistence: Session-based query result storage
- 🌏 Multi-Source Data: Integrated data from World Bank API and IMF DataMapper
- Python 3.8+
- pip package manager
-
Clone the repository
git clone <repository-url> cd GDP_trend
-
Install dependencies
pip install streamlit pandas plotly duckdb openai python-dotenv wbgapi pycountry
-
Set up API key
Create a
.envfile in the project root:modelscope=your_api_key_here
Get your API key from ModelScope.
-
Download the data
python download_data.py
This will download the latest economic data from the World Bank API and save it to the
data/directory. -
Run the application
streamlit run app.py
The dashboard will open in your web browser at http://localhost:8501.
- Select countries from the dropdown (default: China, Japan, South Korea)
- Choose an economic indicator:
- GDP (Current USD)
- GDP Per Capita (Current USD)
- Total GDP PPP (Purchasing Power Parity)
- GDP Per Capita PPP
- Population Total
- GDP Per Capita YoY Growth (%)
- Adjust the year range using the slider (2000-2024)
- View interactive line charts and data tables
-
Use the
df_gdptable name in your SQL queries -
Examples:
SELECT * FROM df_gdp WHERE country_code_3 = 'CHN' AND year >= 2020 SELECT country_name, AVG(value) as avg_gdp FROM df_gdp WHERE indicator = 'gdp_per_capita_current_usd' AND year >= 2020 GROUP BY country_name ORDER BY avg_gdp DESC
Ask questions in natural language:
- "What is the average GDP per capita for China, Japan, and Korea from 2020 to 2023?"
- "Which countries had the highest GDP growth in 2023?"
- "Show me population trends for Asian countries"
The AI will generate and execute SQL queries to answer your questions.
GDP_trend/
├── app.py # Main Streamlit application
├── download_data.py # Data download script (World Bank + IMF APIs)
├── language.py # Bilingual translation module
├── data/
│ ├── all_countries_with_iso_continents.csv # Country metadata
│ └── gdp_data_2000_present.csv # Economic indicators data
├── images/ # Screenshot images for README
├── CLAUDE.md # Development guidance for Claude Code
├── README.md # This file (English)
├── _README_CN.md # Chinese version of README
├── favicon.svg # Application icon
├── requirements.txt # Python dependencies
└── .env # Environment variables (create this)
- World Bank API: Economic indicators for 200+ countries
- GDP (current USD)
- GDP per capita (current USD)
- GDP PPP (current international $)
- GDP per capita PPP (current international $)
- Total population
- IMF DataMapper API: Economic data for Taiwan
- GDP, GDP per capita, GDP PPP, GDP per capita PPP, and population
- pycountry: ISO country codes and names
- Time Range: 2000 to 2024
- Update Frequency: Manual via
download_data.pyscript
gdp_current_usd: GDP at market prices (current US$)gdp_per_capita_current_usd: GDP per capita (current US$)gdp_ppp_current_intl: GDP based on purchasing power parity (current international $)gdp_per_capita_ppp_current_intl: GDP per capita based on purchasing power parity (current international $)population_total: Total populationgdp_per_capita_current_usd_yoy: Year-over-year GDP per capita growth rate (%, calculated)
- Accessed via the
wbgapiPython package - Rate limiting implemented with delays between requests
- Automatic error handling for missing data
- Covers 200+ countries and territories
- Direct REST API calls for Taiwan economic data
- Base URL:
https://www.imf.org/external/datamapper/api/v1 - Provides GDP, GDP PPP, and population data for Taiwan (2000-2024)
- Used for AI-powered SQL generation and data analysis
- Base URL:
https://api-inference.modelscope.cn/v1 - Model:
ZhipuAI/GLM-4.6for SQL generation and data summarization - Supports bilingual output (English/Chinese)
Data Source: World Bank


