List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Define what APIs are expected from the system...
1). fetch weather.
api-/weather/fetch
method-GET
query:
lat:-
long:-
response
{ "coord": { "lon": 7.367, "lat": 45.133 }, "weather": [ { "id": 501, "main": "Rain", "description": "moderate rain", "icon": "10d" } ], "base": "stations", "main": { "temp": 284.2, "feels_like": 282.93, "temp_min": 283.06, "temp_max": 286.82, "pressure": 1021, "humidity": 60, "sea_level": 1021, "grnd_level": 910 }, "visibility": 10000, "wind": { "speed": 4.09, "deg": 121, "gust": 3.47 }, "rain": { "1h": 2.73 }, "clouds": { "all": 83 }, "dt": 1726660758, "sys": { "type": 1, "id": 6736, "country": "IT", "sunrise": 1726636384, "sunset": 1726680975 }, "timezone": 7200, "id": 3165523, "name": "Province of Turin", "cod": 200 }
Here, we are going to use a NoSQL database that will store vendor API or webhook responses. The data will be stored in the database with latitude, longitude, and a timestamp for historical retrieval.
data model
{ "_id": "5553a998e4b02cf7151190c9", "location": { "city": "New York City", "state": "NY", "country": "USA", "latitude": 40.7128, "longitude": -74.0060 }, "current_weather": { "timestamp": "2025-09-06T11:00:00Z", "temperature": 20.5, "humidity": 65, "wind_speed": 15, "wind_direction": "NW", "condition": "Partly Cloudy", "icon_code": "02d" }, "daily_forecasts": [ { "date": "2025-09-07", "temp_max": 22, "temp_min": 15, "condition": "Rainy", "icon_code": "09d" }, { "date": "2025-09-08", "temp_max": 25, "temp_min": 17, "condition": "Sunny", "icon_code": "01d" }, // ... up to 7 days ], "hourly_forecasts": [ { "timestamp": "2025-09-06T12:00:00Z", "temperature": 21.0, "condition": "Cloudy", "icon_code": "03d" }, { "timestamp": "2025-09-06T13:00:00Z", "temperature": 21.5, "condition": "Cloudy", "icon_code": "03d" }, // ... up to 24-48 hours ], "historical_data": [ { "timestamp": "2025-09-05T11:00:00Z", "temperature": 18.2, "humidity": 60, "condition": "Cloudy" }, { "timestamp": "2025-09-05T10:00:00Z", "temperature": 17.5, "humidity": 58, "condition": "Cloudy" }, // ... many more entries ] }
In high-level design, we are going to create a weather service that is responsible for orchestrating the flow. The weather service will call the third-party service, and then the third party will call the vendor for data. The weather service will then put the data into Redis and a database. Redis will be used for quick responses to recent weather pulls based on latitude and longitude keys, while the database will contain all historical data. Based on vendor webhooks, the weather service will publish events to Kafka, and then the notification system will send real-time bad weather forecasts to users.
flowchart TD
A[Client] --> |Weather Request| B[API Gateway]
B --> |Forward Request| C[Weather Service]
C --> |Cache Weather Data| D[Redis Cache]
C --> |Fetch Data| E[Third Party Service]
E --> |Get Weather| F[Weather Data Provider]
F --> |Weather Response| E
E --> |Send Data| C
C --> |Store Historical Data| G[NoSQL Database]
C --> |Publish Updates| H[Kafka]
H --> |Handle Notifications| I[Notification System]
I --> |Send Real-Time Alerts| A
Client Request: The client initiates a request with latitude and longitude, which is routed through an API Gateway to the weather service.
Orchestration: The weather service orchestrates the flow by calling a third-party service to fetch weather data from a vendor.
Data Storage & Response: The weather service stores the fetched data in both a NoSQL database for historical records and Redis for fast, recent data retrieval before responding to the client.
This service's main responsibility is to orchestrate weather reporting functionalities.
flowchart TD F[Kafka Topic] -->|Subscribe| G[Notification Processor] G -->|Send Alert| H[Firebase] G -->|Send Alert| I[SMS Gateway] G -->|Send Alert| J[Email Service] subgraph Notification Service G H I J end
Explain any trade offs you have made and why you made certain tech choices...
when our Thirdparty service providers have down time and we need to provide ssls simility to them to our client.