# arisuabhilash/weather-application architecture

> Architecture diagram of the GitHub repository arisuabhilash/weather-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arisuabhilash/weather-application
- Repository: https://github.com/arisuabhilash/weather-application

## Overview

##### Project Type and Purpose
- This is a full-stack, single-service web application built with Flask (Python) on the backend and plain HTML/CSS on the frontend.
- It retrieves live weather data from an external API (e.g., OpenWeatherMap) and renders it in the browser.
- The entire app is containerized using Docker and can be deployed locally or pushed to IBM Cloud Container Registry.

##### Core Components
a. Client (Web Browser)
b. Docker Container / Runtime
c. Flask Application (app.py)
- Serves static assets (CSS, images) and HTML templates.
- Exposes an HTTP endpoint (default port 4449).
- Retrieves weather data from an external Weather API.
d. External Weather API (third-party service)
e. (Optional) Cloud Registry / Orchestrator (IBM Cloud Container Registry & runtime)

##### Interactions and Data Flows
- User opens the browser → sends HTTP GET to Flask endpoint
- Flask serves index.html and style.css from static/templates
- On search (user enters city), browser triggers a form submission or AJAX call to Flask
- Flask receives the request, calls External Weather API over HTTPS
- External API returns JSON payload (temperature, humidity, wind, etc.)
- Flask processes the JSON, injects data into the template, and returns updated HTML/JSON to the client
- The browser renders the updated weather data

##### Architectural Patterns & Design Principles
- Monolithic, single-container service
- “Backend for Frontend” pattern: Flask provides both UI and API endpoints
- Containerization best practices: one service per container, environment variables for configuration
- Separation of concerns: static assets under `/static`, templates under `/templates`, business logic in `app.py`

##### Technologies & Frameworks
- Python 3.x, Flask (web framework)
- HTML / CSS (responsive layout)
- Docker (Dockerfile defines the image, exposes port 4449)
- External API: OpenWeatherMap (or similar)
- Optional IBM Cloud CLI for registry push and container deployment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "Client Layer" 
        direction TB
        Browser["Web Browser"]:::client
    end

    subgraph "Infrastructure Layer" 
        direction TB
        DockerHost["Docker Host"]:::infra
        subgraph "Docker Container" 
            direction TB
            FlaskApp["Flask App (app.py)\nPort:4449"]:::internal
            StaticDir["Static Assets\n/static"]:::internal
            CSSFile["style.css"]:::internal
            ImagesDir["images/"]:::internal
            TemplatesDir["HTML Templates\n/templates"]:::internal
            IndexHTML["index.html"]:::internal
            Requirements["requirements.txt"]:::internal
            DockerfileNode["Dockerfile"]:::infra
            GitIgnore[".gitignore"]:::infra
            Readme["readme.md"]:::infra
        end
    end

    subgraph "Third-Party Layer"
        direction TB
        WeatherAPI["External Weather API\n(OpenWeatherMap)"]:::external
        IBMCloud["IBM Cloud Container Registry"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET / POST\n(Port 4449)"| FlaskApp
    FlaskApp -->|"Serves HTML/CSS"| Browser
    StaticDir --> IndexHTML
    StaticDir --> CSSFile
    StaticDir --> ImagesDir
    TemplatesDir --> IndexHTML
    Browser -->|"Requests index.html"| FlaskApp
    FlaskApp -->|"HTTPS Request\n(API key via env)"| WeatherAPI
    WeatherAPI -->|"JSON Response"| FlaskApp
    DockerHost -->|"Runs Container"| FlaskApp
    DockerHost -->|"Push Image"| IBMCloud

    %% Click Events
    click FlaskApp "https://github.com/arisuabhilash/weather-application/blob/main/app.py"
    click StaticDir "https://github.com/arisuabhilash/weather-application/tree/main/static/"
    click CSSFile "https://github.com/arisuabhilash/weather-application/blob/main/static/css/style.css"
    click ImagesDir "https://github.com/arisuabhilash/weather-application/tree/main/static/images/"
    click TemplatesDir "https://github.com/arisuabhilash/weather-application/tree/main/templates/"
    click IndexHTML "https://github.com/arisuabhilash/weather-application/blob/main/templates/index.html"
    click DockerfileNode "https://github.com/arisuabhilash/weather-application/tree/main/Dockerfile"
    click Requirements "https://github.com/arisuabhilash/weather-application/blob/main/requirements.txt"
    click GitIgnore "https://github.com/arisuabhilash/weather-application/blob/main/.gitignore"
    click Readme "https://github.com/arisuabhilash/weather-application/blob/main/readme.md"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef client fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef infra fill:#F0E68C,stroke:#333,stroke-width:1px
```
