A backend-focused Flask project that fetches weather data from a 3rd‑party API, caches responses using a Redis‑like in‑memory cache, and serves results via a clean server‑rendered UI.
This project is intentionally designed to emphasize API integration, caching logic, environment variables, and clean architecture — not frontend complexity.
- 🔌 Fetches weather data from a 3rd‑party provider (Visual Crossing)
- 🧠 Caching layer with TTL (Redis‑like behavior, pure Python)
- ⏱️ Automatic cache expiry (12 hours)
- 🔐 Environment variable–based configuration
- 🧩 Clean separation of concerns (Flask / service / cache)
- 🖥️ Simple server‑rendered UI (no JavaScript required)
project/
│
├── app.py # Flask app (routes & orchestration)
├── weather_service.py # 3rd‑party weather API logic
├── cache.py # In‑memory Redis‑like cache with TTL
│
├── templates/
│ └── index.html # UI template
│
├── static/
│ └── styles.css # Basic styling
│
├── .env # Environment variables (not committed)
├── .env.example # Env template
├── requirements.txt
└── README.md
User submits form
↓
Flask route (/weather)
↓
Check cache (key = city + date range)
↓
Cache hit? → return cached data
Cache miss? → call 3rd‑party API
↓
store in cache (with TTL)
↓
return result
-
Implemented a Redis‑like in‑memory cache using Python dictionaries
-
Each cache entry stores:
- the response data
- an expiration timestamp (TTL)
-
Expired entries are automatically removed on access
Redis does not officially support Windows. To avoid unnecessary setup complexity, this project uses an in‑memory cache that mimics Redis behavior.
The cache layer is abstracted, so swapping to real Redis later requires minimal changes.
When deploying to Linux / Docker / Cloud:
- Replace cache internals with
redis-py - Keep the same
get_cache()andset_cache()interface
No changes required in app.py.
Create a .env file based on .env.example:
BASE_URL=https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/
API_KEY=your_api_key_here
⚠️ Never commit.envto version control.
pip install -r requirements.txt
python app.py
http://127.0.0.1:5000
The application currently displays the raw JSON response from the weather provider for transparency and debugging purposes.
This is intentional and aligns with API‑first design principles.
- Missing form fields → user‑friendly error
- API failure → graceful message
- Cache handles expiration automatically
- This project focuses on backend engineering, not frontend design
- No JavaScript is used (by choice)
- Ideal for demonstrating API usage, caching, and clean architecture
- Normalize weather response (temperature, humidity, condition)
- Add rate limiting
- Add logging
- Replace fake cache with real Redis
- Expose a pure JSON API endpoint
Redis is not magic — it’s a fast key‑value store with expiration. This project demonstrates that concept clearly and cleanly.
Built with focus on backend fundamentals and practical system design.
⭐ If you found this useful, consider starring the repo!
Project: https://roadmap.sh/projects/weather-api-wrapper-service


