# xuanlockun/meovivu architecture

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

- Interactive diagram: https://gitdiagram.com/xuanlockun/meovivu
- Repository: https://github.com/xuanlockun/meovivu

## Overview

##### Main Components
- Presentation Layer: Represented by the GUI components found in the “SourceCode/src/dulich/View” folder (e.g., LoginForm, Main, TourForm, Profile, etc.). Also include custom Swing components (like those within “SourceCode/src/dulich/Swing” – e.g., CustomTable, PlaceholderText, RoundJPanel) that enhance the UI.
- Business Logic Layer: Although not explicitly separated, some business logic might be embedded in the View classes and possibly in the “Model” directory (e.g., DataAccess.java). This DataAccess component is essential as it acts as the interface to the database, managing CRUD operations.
- Data Access Layer (Persistence): Encapsulated by “SourceCode/src/dulich/Model/DataAccess.java” and supported by the provided SQL script (meovivu.sql). Mention the JDBC integration (using ojdbc11.jar) as a bridge between the application and the underlying database.
- External Services & Libraries: Include components for:
- OpenWeatherMap API integration (as indicated by the README instruction to add an API key in the main form).
- Report Generation: Use of iTextpdf (from lib/itextpdf.jar) to generate PDF reports, and the existing PDF reports in “SourceCode/reports” as examples/result artifacts.
- Charting: jFreeChart (referenced by lib/jfreechart-demo-1.5.2-jar-with-dependencies.jar) to create visual data representations.
- JSON Parsing: Using json-simple (lib/json_simple.jar) for handling JSON data.

##### Depicting Relationships and Interactions
- Data flow from the Data Access layer to the Database, ensuring you indicate that JDBC (via ojdbc11.jar) is the connecting technology.

##### Architectural Patterns and Design Principles
- Although it’s a desktop application, highlight the separation of concerns by illustrating the UI components (Java Swing forms and custom components) separately from business logic and data access functionality.
- Modularity by showing that each UI screen (such as Login, Main, Profile, Tour forms) interacts with a central data access layer.
- That external dependencies (database connection, external API) are abstracted away through JDBC and specific library calls.

##### Detailed Step-by-Step Guidance
b. Next, create a “Business Logic / Controller” section. Since much of the logic is embedded in the view and model files, indicate the “DataAccess” component here.
- “OpenWeatherMap API” (annotate that communication happens via json-simple for JSON and requires an API key).
- “Report Generation Tools” with sub-nodes indicating iTextpdf and jFreeChart.
- From UI → Business Logic: User actions triggering data retrieval or report generation.
- From Business Logic → Database: Data operations via JDBC.
- Data retrieval flows: External API responses feeding back into the UI or report generation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface (Presentation Layer)"
        direction TB
        GUIForms["GUI Forms"]:::presentation
        CustomSwing["Custom Swing Components"]:::presentation
    end

    subgraph "Business Logic / Data Access"
        direction TB
        DataAccess["DataAccess"]:::business
    end

    subgraph "Database"
        direction TB
        DB["Oracle Database"]:::database
    end

    subgraph "External Dependencies"
        direction TB
        OWAPI["OpenWeatherMap API & JSON (json-simple)"]:::external
        PDF["iTextpdf (PDF Generation)"]:::external
        Charts["jFreeChart (Charting)"]:::external
        Reports["Sample Reports"]:::external
    end

    %% Data Flow Connections
    GUIForms -->|"UserInput"| DataAccess
    CustomSwing -->|"UserInput"| DataAccess
    DataAccess -->|"CRUD_via_JDBC(ojdbc11.jar)"| DB
    DataAccess -->|"GeneratePDF(iTextpdf)"| PDF
    DataAccess -->|"GenerateCharts(jFreeChart)"| Charts
    DataAccess -->|"FetchWeatherData"| OWAPI
    OWAPI -->|"ReturnJSONResponse"| DataAccess

    %% Click Events for Component Mapping
    click GUIForms "https://github.com/xuanlockun/meovivu/tree/main/SourceCode/src/dulich/View"
    click CustomSwing "https://github.com/xuanlockun/meovivu/tree/main/SourceCode/src/dulich/Swing"
    click DataAccess "https://github.com/xuanlockun/meovivu/blob/main/SourceCode/src/dulich/Model/DataAccess.java"
    click DB "https://github.com/xuanlockun/meovivu/blob/main/meovivu.sql"
    click DB "https://github.com/xuanlockun/meovivu/blob/main/lib/ojdbc11.jar"
    click PDF "https://github.com/xuanlockun/meovivu/blob/main/lib/itextpdf.jar"
    click Reports "https://github.com/xuanlockun/meovivu/tree/main/SourceCode/reports"
    click Charts "https://github.com/xuanlockun/meovivu/blob/main/lib/jfreechart-demo-1.5.2-jar-with-dependencies.jar"
    click OWAPI "https://github.com/xuanlockun/meovivu/blob/main/lib/json_simple.jar"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef external fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
    classDef database fill:#F5DEB3,stroke:#A0522D,stroke-width:2px;
```
