# hoviethao/-calculator- architecture

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

- Interactive diagram: https://gitdiagram.com/hoviethao/-calculator-
- Repository: https://github.com/hoviethao/-calculator-

## Overview

##### Project type and purpose
- This is a standalone desktop application (“Calculator”) implemented in Java Swing.
- Its sole purpose is to provide a GUI for basic arithmetic operations and maintain a history file (lich_su_phep_tinh.txt).

##### File structure
- build.xml, manifest.mf, nbproject/… — Ant build script and NetBeans project configuration.
- src/thuchanh1/ — Java source package containing:
- Thuchanh1.java (core entry point or logic controller)
- giaodien.form and giaodien.java (Swing GUI form + generated code)
- test/ — Unit tests (Student.java, StudentTest.java) demonstrating a testing layer.
- lich_su_phep_tinh.txt — Persistent storage for calculation history.

##### README for additional insights
- Confirms a simple Java Swing calculator without any external services or server components.

a. Main components
- GUI Layer (Swing Form & JFrame code)
- Application Logic (Calculator engine / controller class)
- Persistence (history file)
- Build System (Ant)
- Testing Module

b. Relationships & interactions
- User events in GUI → invoke Application Logic methods
- Application Logic → reads/writes lich_su_phep_tinh.txt
- Build System pulls sources, compiles classes, packages JAR using manifest.mf
- Test Runner uses JUnit tests in test/ to validate logic

c. Architectural patterns & principles
- MVC‐lite: separation of View (giaodien), Controller/Model (Thuchanh1 logic)
- Single‐process, event‐driven Swing architecture
- Layered components: UI → Business Logic → Persistence

d. Key technologies
- Java SE 8+
- Swing (javax.swing) for GUI
- Ant for build automation
- JUnit (in test/) for unit testing

##### Diagramming conventions
- From “Swing GUI” → “Calculator Engine” (method calls)
- From “Calculator Engine” ↔ “History File” (read/write)
- From “Ant Build” → all source directories (compilation)
- From “JUnit Test Suite” → “Calculator Engine” (test dependency)
- UI in blue
- Logic in green
- Persistence in orange
- Build/Test tools in gray

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    User["User"]:::actor

    %% Presentation Layer
    subgraph "Presentation Layer (UI)"
        direction TB
        GUIForm["giaodien.form"]:::ui
        GUIClass["giaodien.java"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic (Controller)"
        direction TB
        Logic["Thuchanh1.java"]:::logic
    end

    %% Persistence Layer
    Persistence["lich_su_phep_tinh.txt"]:::persistence

    %% Build & Config Tools
    subgraph "Build & Config Tools"
        direction TB
        Ant["Ant Build (build.xml)"]:::tools
        Manifest["Manifest (manifest.mf)"]:::tools
        NB["NetBeans Config (nbproject/)"]:::tools
    end

    %% Test Suite
    subgraph "Test Suite"
        direction TB
        Test1["Student.java"]:::test
        Test2["StudentTest.java"]:::test
    end

    %% Connections
    User --> GUIClass
    GUIForm --> GUIClass
    GUIClass --> Logic
    Logic --> Persistence
    Persistence --> Logic
    Ant --> GUIForm
    Ant --> GUIClass
    Ant --> Logic
    Ant --> Manifest
    Ant --> NB
    Test2 --> Logic
    Test1 --> Logic

    %% Click Events
    click GUIForm "https://github.com/hoviethao/-calculator-/blob/master/src/thuchanh1/giaodien.form"
    click GUIClass "https://github.com/hoviethao/-calculator-/blob/master/src/thuchanh1/giaodien.java"
    click Logic "https://github.com/hoviethao/-calculator-/blob/master/src/thuchanh1/Thuchanh1.java"
    click Persistence "https://github.com/hoviethao/-calculator-/blob/master/lich_su_phep_tinh.txt"
    click Ant "https://github.com/hoviethao/-calculator-/blob/master/build.xml"
    click Manifest "https://github.com/hoviethao/-calculator-/blob/master/manifest.mf"
    click NB "https://github.com/hoviethao/-calculator-/tree/master/nbproject/"
    click Test1 "https://github.com/hoviethao/-calculator-/blob/master/test/Student.java"
    click Test2 "https://github.com/hoviethao/-calculator-/blob/master/test/StudentTest.java"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#0000FF,stroke-width:1px;
    classDef logic fill:#D5F5E3,stroke:#28B463,stroke-width:1px;
    classDef persistence fill:#FCF3CF,stroke:#F1C40F,stroke-width:1px;
    classDef tools fill:#D7DBDD,stroke:#7F8C8D,stroke-width:1px;
    classDef test fill:#E8DAEF,stroke:#8E44AD,stroke-width:1px;
    classDef actor fill:#FFFFFF,stroke:#000000,stroke-width:1px;
```
