This script guides you through demonstrating the Phase 2 features of IntelliWeather API.
# Start the server
cd Weather-API
pip install -r requirements.txt
uvicorn app:app --reload --port 8000
# Open Swagger docs
open http://localhost:8000/docs-
Open Swagger UI at
http://localhost:8000/docs- Point out the organized tags: Weather V2, Geocoding, Alerts, etc.
-
Hourly Forecast
curl "http://localhost:8000/weather/hourly?lat=40.7128&lon=-74.006&hours=48"- Show the structured JSON response
- Highlight: temperature, humidity, precipitation probability
-
CSV Export
curl "http://localhost:8000/weather/hourly?lat=40.7128&lon=-74.006&format=csv" -o hourly.csv open hourly.csv- "Users can export data to CSV for their own analysis"
-
Historical Data
curl "http://localhost:8000/weather/historical?lat=40.7128&lon=-74.006&start=2024-01-01&end=2024-01-07"- "We can fetch historical weather for any date range up to 1 year"
-
Search for a city
curl "http://localhost:8000/geocode/search?q=Lahore&limit=3"- Show coordinates, country, timezone, population
-
Reverse Geocoding
curl "http://localhost:8000/geocode/reverse?lat=31.5204&lon=74.3587"- "From coordinates, we can get the location name"
-
Show Cache Hit
- Make the same request again
- Point out
"source": "cache"in response - "Second request is instant - served from cache"
-
Get Alerts
curl "http://localhost:8000/alerts?lat=40.7128&lon=-74.006"- Show alert structure: severity, headline, instructions
-
Explain the System
- "Alerts are generated based on weather conditions"
- "In production, this would integrate with National Weather Service"
- "Alerts are cached for 15 minutes"
-
Download PDF Report
curl "http://localhost:8000/weather/download?lat=40.7128&lon=-74.006&type=pdf&range=daily&days=7" -o report.pdf open report.pdf- Show the formatted report with temperature chart
-
Download Excel Report
curl "http://localhost:8000/weather/download?lat=40.7128&lon=-74.006&type=excel&range=daily&days=7" -o report.xlsx open report.xlsx- Show multiple sheets: Weather data, Metadata
- "Excel files have proper styling and formatting"
-
Get Next-Day Prediction
curl "http://localhost:8000/predict/nextday?lat=40.7128&lon=-74.006"- Show predicted temperature and confidence interval
- "Simple ML model using historical data"
-
Model Info
curl "http://localhost:8000/predict/model/info"- Show model version and training date
-
Show Supported Languages
curl "http://localhost:8000/i18n/languages"- List: English, Hindi, Urdu, Arabic, Spanish
-
Get Hindi Translations
curl "http://localhost:8000/i18n/translations?lang=hi" | jq '.translations | {current_weather, feels_like, humidity}'
- Show Hindi text
-
Weather Description in Arabic
curl "http://localhost:8000/i18n/weather-description?code=3&lang=ar"- Show Arabic translation
-
Login First
curl -X POST "http://localhost:8000/auth/login" \ -H "Content-Type: application/json" \ -d '{"email":"demo@example.com","password":"demo123"}' \ -c cookies.txt
-
Create API Key
curl -X POST "http://localhost:8000/apikeys" \ -H "Content-Type: application/json" \ -d '{"name":"Demo Key","rate_limit":100}' \ -b cookies.txt
- "Key is only shown once - store securely"
-
Use API Key
curl "http://localhost:8000/weather/hourly?lat=40.7128&lon=-74.006" \ -H "X-API-Key: YOUR_API_KEY"
- "Each key has its own rate limit"
-
Open Dashboard
- Navigate to
http://localhost:8000/admin/dashboard - (Requires admin user)
- Navigate to
-
Show Statistics
- Total users
- Active sessions
- Cache hit rate
- Top searched locations
-
System Health
- Storage status
- Cache operational
- API connectivity
# Show docker-compose
cat docker-compose.yml
# Scale to 3 instances
docker-compose up -d --scale app=3
# Show NGINX load balancing
curl http://localhost/weather?lat=40.7128&lon=-74.006-
Architecture Highlights
- Multi-tier caching (memory → CSV → external API)
- Feature flags for all Phase 2 features
- Structured JSON logging
- Thread-safe operations
-
Production Ready
- Docker support with load balancing
- Health checks and metrics
- Rate limiting per IP and per API key
- Secure session management
-
Documentation
- Swagger/OpenAPI docs
- README.md
- QA checklist
- Demo scripts
| Issue | Solution |
|---|---|
| Server won't start | Check pip install -r requirements.txt |
| 401 errors | Login first or provide API key |
| 429 errors | Rate limit hit, wait 60 seconds |
| Empty alerts | No severe weather at that location |
| PDF not rendering | Check if data fetched successfully |
Q: Why CSV storage instead of a database? A: Simpler setup, no external dependencies. Demonstrates file-based persistence. Production would use PostgreSQL/Redis.
Q: How does the ML model work? A: Linear regression on historical temperatures. Features: day of year (cyclical), previous temps, trend.
Q: How accurate are predictions? A: Simple model with ±3°C confidence. Production would use more sophisticated approaches.
Q: What happens if Open-Meteo is down? A: Cached data is returned if available. Error responses include 503 status with clear message.