How valentin5944/weatherapp works
Project Type and Purpose
• This is a monolithic, desktop GUI application (built in Python) for fetching, processing, and displaying weather data from the OpenWeatherMap API.
• It demonstrates API consumption, JSON data handling, and a GUI built with the CustomTkinter library.
High-Level Architecture Overview
A. External Service
• OpenWeatherMap REST API
B. Application (monolith)
1. Presentation Layer (GUI)
– main.py / modules.gui.main_screen
– GUI components: side_bar, main_info, forecast_frame, forecast_component, city_weather, image
2. Business Logic Layer
– modules.weather_data (API client using requests)
3. Persistence Layer
– modules.read_json & modules.write_json (read/write to JSON files)
4. Static Resources
– static/config.json (API key and settings)
– static/weather_data.json & static/forecast.json (cached data)
C. Local File System
Components and Their Interactions
1. User interacts with the GUI (clicks “Search City” or refresh forecast)
2. GUI invokes Business Logic:
– calls modules.weather_data.fetch_current() / .fetch_forecast()
– weather_data reads API credentials from static/config.json
3. Business Logic sends HTTP request → OpenWeatherMap API
4. API returns JSON payload → business logic processes & transforms it
5. Processed data is passed to Persistence Layer:
– modules.write_json stores raw or formatted data in static/weather_data.json / forecast.json
6. GUI reads from modules.read_json (or receives data directly)
– modules.gui components render the latest data on screen
Architectural Patterns & Design Principles
• Layered Architecture: clear separation of GUI, business logic, and persistence.
• Modular Design: each feature (API client, JSON I/O, GUI widget) is a self-contained module.
• Single Responsibility: read_json/write_json only handle file I/O; weather_data only handles API calls; gui modules only handle rendering.
Technologies & Frameworks
• Python 3.x
• CustomTkinter for GUI
• requests for HTTP
• json (stdlib) for data serialization
• venv for isolation