This project is a Weather API Wrapper Service built with ASP.NET Core. Instead of fetching weather data directly from the provider every time, this service acts as a middleware that implements an intelligent caching strategy using Redis.
It solves two main problems:
- Rate Limiting & Cost: Reduces the number of calls to the third-party API (Visual Crossing).
- Latency: Provides instant responses for frequently requested cities by serving data from the cache.
- Third-Party Integration: Wraps the Visual Crossing Weather API.
- Redis Caching: Implements the Cache-Aside pattern:
- Checks Redis first for cached city data
- If not found, fetches from the API and saves to Redis
- TTL (Time-To-Live): Cached data expires automatically after 12 hours
- Dockerized: Fully containerized using Docker Compose (API + Redis)
- Secure Configuration: Uses Environment Variables and
.envfiles to protect API keys
- .NET 9 (ASP.NET Core Web API)
- StackExchange.Redis
- Docker & Docker Compose
- Scalar / Swagger (API Documentation)
- Docker Desktop
- A free API key from Visual Crossing
- Clone the repository
git clone <your-repo-url>
cd <your-project-folder>- Create a
.envfile
# .env
WEATHER_API_KEY=your_visual_crossing_api_key_here- Run with Docker Compose
docker-compose up --build- Access the API
- Scalar / Swagger UI: http://localhost:8080/scalar/v1
- Endpoint:
GET http://localhost:8080/weather/{city}
Bu proje, ASP.NET Core ile geliştirilmiş Hava Durumu API Sarmalayıcı (Wrapper) Servisidir. Hava durumu verilerini her istek için doğrudan sağlayıcıdan almak yerine, Redis kullanarak akıllı bir önbellekleme (caching) stratejisi uygular.
Çözdüğü ana problemler:
- Maliyet ve Rate Limit: Üçüncü parti API çağrılarını azaltır
- Performans: Sık istenen şehirler için milisaniyeler içinde yanıt döner
-
Visual Crossing API Entegrasyonu
-
Redis Önbellekleme (Cache-Aside Pattern)
- Önce Redis kontrol edilir
- Veri yoksa API’den çekilip Redis’e kaydedilir
-
TTL: Veriler 12 saat sonra otomatik silinir
-
Docker Desteği: API ve Redis Docker Compose ile ayağa kalkar
-
Güvenli Konfigürasyon:
.envve environment variable kullanımı
- .NET 9 (ASP.NET Core Web API)
- StackExchange.Redis
- Docker & Docker Compose
- Scalar / Swagger
- Docker Desktop
- Visual Crossing API Anahtarı
- Projeyi klonla
git clone <repo-adresiniz>
cd <proje-klasoru>.envdosyası oluştur
WEATHER_API_KEY=sizin_visual_crossing_api_keyiniz- Docker ile başlat
docker-compose up --build- API Kullanımı
- Swagger: http://localhost:8080/scalar/v1
- Örnek İstek:
GET http://localhost:8080/weather/ISTANBUL