Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌀️ Weather Microservices Platform

πŸ“Œ Project Overview

A distributed microservices-based platform for weather consultation, featuring city management, weather data retrieval, weather-based alerts, and request history tracking. The application demonstrates a scalable microservices architecture with service discovery, fault tolerance, and resilient inter-service communication.

🧩 Architecture

The system is composed of 4 independent microservices:

Service Port Description
Eureka Server 8761 Service discovery and registry
City Service 8081 City management (CRUD operations)
Weather Service 8082 Weather data retrieval and orchestration
Alert Service 8083 Weather-based alerts and notifications
History Service 8084 Weather request history persistence

System Workflow

Client β†’ Weather Service β†’ City Service (verify city)
              ↓
         OpenWeather API
              ↓
         History Service (store request)
              ↓
         Alert Service (check conditions)
              ↓
         Response to Client

πŸ› οΈ Technologies Used

Core Technologies

  • Java 17
  • Spring Boot 3
  • Spring Cloud Netflix Eureka
  • Spring Data JPA
  • H2 In-Memory Database
  • Maven

Communication & Integration

  • OpenFeign (Declarative REST client)
  • RestTemplate (HTTP communication)
  • OpenWeather API (External weather data provider)

Resilience & Fault Tolerance

  • Resilience4j (Circuit Breaker pattern)
  • Automatic fallback handling
  • Service failure isolation

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • Maven
  • Internet connection (for OpenWeather API)
  • OpenWeather API key (Get one here)

1️⃣ Start Services in Order

Important: Services must be started in the following sequence to ensure proper registration and communication:

  1. Eureka Server (Service Registry)
  2. City Service (Reference Data)
  3. History Service (Data Persistence)
  4. Weather Service (Business Orchestrator)
  5. Alert Service (Notification System)

2️⃣ Configuration

Update application.properties in Weather Service:

weather.api.key=YOUR_OPENWEATHER_API_KEY

To obtain an API key:

  1. Visit OpenWeatherMap
  2. Create a free account
  3. Generate an API key from your dashboard

3️⃣ Running the Services

For each service, navigate to its directory and run:

mvn clean install
mvn spring-boot:run

πŸ”— Service Access

Service URL Credentials
Eureka Dashboard http://localhost:8761 -
City H2 Console http://localhost:8081/h2-console JDBC URL: jdbc:h2:mem:citydb
History H2 Console http://localhost:8084/h2-console JDBC URL: jdbc:h2:mem:historydb

πŸ“‘ API Endpoints

1️⃣ City Service (Port 8081)

Get All Cities

GET /cities

Get City by Name

GET /cities/{name}

Add New City

POST /cities
Content-Type: application/json

{
  "name": "Paris",
  "country": "FR"
}

2️⃣ Weather Service (Port 8082)

Get Weather for City

GET /weather/{city}

Response example:

{
  "city": "Paris",
  "temperature": 15.5,
  "humidity": 65,
  "description": "Partly cloudy",
  "timestamp": "2024-01-15T10:30:00"
}

3️⃣ History Service (Port 8084)

Get Request History

GET /history

4️⃣ Alert Service (Port 8083)

Get Weather Alerts for City

GET /alerts/{city}

🧠 Weather Service Workflow

The Weather Service acts as the main orchestrator:

  1. City Verification: Checks if the requested city exists via City Service
  2. Data Retrieval: Calls the OpenWeather API to fetch weather data
  3. History Logging: Stores the request in History Service
  4. Alert Check: Triggers Alert Service to check notification conditions
  5. Response: Returns processed weather data to the client
  6. Fault Handling: In case of failure β†’ Circuit Breaker activates / Fallback response

🧯 Resilience & Fault Tolerance

The platform implements Resilience4j patterns for system stability:

Circuit Breaker

  • Monitors service health and prevents cascading failures
  • Opens circuit when failure threshold is reached
  • Automatically attempts recovery after cooldown period

Fallback Mechanism

  • Provides cached or default responses when services are unavailable
  • Ensures graceful degradation of functionality
  • Maintains user experience during partial outages

Fault Isolation

  • Service failures are contained and don't affect other microservices
  • Independent failure domains for each service

πŸ“‚ Project Structure

weather-microservices-platform/
β”‚
β”œβ”€β”€ eureka-server/          # Service discovery
β”œβ”€β”€ city-service/           # City management
β”œβ”€β”€ weather-service/        # Weather orchestrator
β”œβ”€β”€ alert-service/          # Alert notifications
└── history-service/        # Request history

Each microservice follows the standard Spring Boot structure:

service-name/
β”œβ”€β”€ src/main/java
β”‚   β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ repository/
β”‚   β”œβ”€β”€ entity/
β”‚   └── config/
└── src/main/resources
    └── application.properties

πŸ“Š Project Status

βœ… All microservices implemented and functional
βœ… Service discovery with Eureka
βœ… Circuit breaker and fault tolerance
βœ… External API integration
⏳ Frontend dashboard (planned)
⏳ Database migration to PostgreSQL (planned)

πŸ›‘οΈ Future Enhancements

  • API Gateway implementation (Spring Cloud Gateway)
  • Authentication and authorization (OAuth2/JWT)
  • Persistent database migration (PostgreSQL/MySQL)
  • Monitoring and logging (Prometheus, Grafana, ELK Stack)
  • Docker containerization and Kubernetes orchestration
  • Frontend dashboard with real-time weather updates
  • Notification system (Email/SMS alerts)
  • Unit and integration testing
  • API documentation with Swagger/OpenAPI

πŸ‘₯ Authors

Sara Tahiri
πŸ”— GitHub: github.com/SaraTahiri
πŸ’Ό LinkedIn: linkedin.com/in/tahiri-sara

Anas Lahmidi
πŸ”— GitHub: github.com/AnasLahmidi
πŸ’Ό LinkedIn: linkedin.com/in/anas-lahmidi

πŸ“ž Contact

For questions, suggestions, or collaboration opportunities:

πŸ“§ tahirisara911@gmail.com
πŸ“§ anaslahmidi03@gmail.com

πŸ“„ License

This project is developed for educational purposes.

About

Distributed Weather Platform built with Spring Boot microservices. Fetches external weather data, manages cities, and stores historical records. Uses REST APIs, Eureka for service discovery, OpenFeign for inter-service communication, and Resilience4J for fault tolerance. Demonstrates scalable and maintainable microservices design.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages