# arturoccs/weatherapp architecture

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

- Interactive diagram: https://gitdiagram.com/arturoccs/weatherapp
- Repository: https://github.com/arturoccs/weatherapp

## Overview

##### Main Components
- User Interface (UI) Layer: Represented by JavaFX, using FXML files (HomeScreen.fxml and Item.fxml) along with a CSS file for styling. The HomeScreenController.java and ItemController.java in the application package are the bridge between the interface and the control logic.
- Controller Layer: This layer includes classes that parse and process the data. In the “controller” package, there are DataParser.java, JsonParser.java, and TxtParser.java, which handle conversion and file operations.
- Model Layer: Includes classes in the “model” package such as City.java, Coord.java, Data.java, WeatherData.java, Temp.java, and MyListener.java. These classes encapsulate the weather information and are the targets for JSON-to-Java object conversion.
- Application Entry Point: The Main.java class in the “application” package ties everything together by initiating the program and launching the JavaFX UI.

##### Relationships and Interactions
- The entry point (Main.java) initializes the JavaFX application; it loads the FXML files that represent the views.
- The Controllers (HomeScreenController and ItemController) interact with the view components and invoke the appropriate parsing classes (JsonParser, TxtParser, and DataParser) to handle data ingestion.
- The Parsing Controllers convert JSON files into the corresponding Model objects (e.g., City and WeatherData). Data is then stored or retrieved as text files.
- Utility classes are used by both controllers and model classes to format and transform data for presentation or storage.
- Dependency flows from the UI to Controllers → Parsing Components → Model and Utility components.
- External services such as the data source (JSON files) and the local file system for text file storage are also part of the overall connected system.

##### Architectural Patterns & Technologies
- MVC / MVVM Style: Although not strictly enforced, the separation between the FXML-based views, their controllers, and model components follows a Model-View-Controller separation.
- Technologies & Dependencies: Java SE 22, Maven (pom.xml), JavaFX (for the GUI), and likely the Gson library (for JSON processing) as declared in the dependency list.
- Build/CI Integration: The existence of GitHub workflows (e.g., .github/workflows/maven.yml) indicates continuous integration practices.

##### Final Details
- That while the current implementation centers on meteorological data analysis, the design is modular. It is designed to easily extend to other types of JSON format data (like inventory, articles, etc.) by customizing the parser and model components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    MB("pom.xml"):::external
    EJSON("JSON_Input"):::external
    TFS("TXT_Storage"):::external

    %% Application Entry Point
    subgraph "Application Entry"
        M("Main.java"):::entry
    end

    %% UI Layer
    subgraph "UI Layer"
        F1("HomeScreen.fxml"):::ui
        F2("Item.fxml"):::ui
        CSS("application.css"):::ui
        HC("HomeScreenController"):::ui
        IC("ItemController"):::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        DP("DataParser"):::controller
        JP("JsonParser"):::controller
        TP("TxtParser"):::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        City("City"):::model
        Coord("Coord"):::model
        Data("Data"):::model
        WD("WeatherData"):::model
        Temp("Temp"):::model
        ML("MyListener"):::model
    end

    %% Utility Layer
    subgraph "Utility Layer"
        FMT("Format"):::utility
        TIM("TemperatureIconMapper"):::utility
    end

    %% Connections: External to Application Entry
    MB --> M

    %% Connections: Application Entry to UI Layer
    M --> F1
    M --> F2

    %% UI: FXML files load their controllers and styles
    F1 --> HC
    F2 --> IC
    F1 --> CSS

    %% Connections: UI Controllers to Controller Layer (Data Parsing)
    HC --> DP
    HC --> JP
    HC --> TP
    IC --> DP
    IC --> JP
    IC --> TP

    %% Controller Layer to Model Layer
    DP --> City
    DP --> Coord
    DP --> Data
    DP --> WD
    DP --> Temp
    DP --> ML
    JP --> City
    JP --> WD
    TP --> Data

    %% Controller Layer to Utility Layer (for formatting/mapping)
    DP --> FMT
    DP --> TIM
    JP --> FMT
    JP --> TIM
    TP --> FMT
    TP --> TIM

    %% External Data Flow
    JP --> EJSON
    TP --> TFS

    %% Styling Classes
    classDef ui fill:#dfefff,stroke:#333,stroke-width:2px;
    classDef controller fill:#ffdfba,stroke:#d2691e,stroke-width:2px;
    classDef model fill:#ffe1f1,stroke:#d6336c,stroke-width:2px;
    classDef utility fill:#eaffda,stroke:#6fcf97,stroke-width:2px;
    classDef entry fill:#f0f9ff,stroke:#5fa2ce,stroke-width:2px;
    classDef external fill:#ffe6e6,stroke:#a94442,stroke-width:2px;

    %% Click Events
    click MB "https://github.com/arturoccs/weatherapp/blob/main/pom.xml"
    click M "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/application/Main.java"
    click F1 "https://github.com/arturoccs/weatherapp/blob/main/src/main/resources/assets/HomeScreen.fxml"
    click F2 "https://github.com/arturoccs/weatherapp/blob/main/src/main/resources/assets/Item.fxml"
    click CSS "https://github.com/arturoccs/weatherapp/blob/main/src/main/resources/assets/application.css"
    click HC "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/application/HomeScreenController.java"
    click IC "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/application/ItemController.java"
    click DP "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/controller/DataParser.java"
    click JP "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/controller/JsonParser.java"
    click TP "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/controller/TxtParser.java"
    click City "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/City.java"
    click Coord "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/Coord.java"
    click Data "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/Data.java"
    click WD "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/WeatherData.java"
    click Temp "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/Temp.java"
    click ML "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/model/MyListener.java"
    click FMT "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/utility/Format.java"
    click TIM "https://github.com/arturoccs/weatherapp/blob/main/src/main/Java/com/arturoccs/utility/TemperatureIconMapper.java"
```
