# mohamedabolyazeed/calculator architecture

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

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

## Overview

##### Project type and purpose
- This is a small-scale desktop Java application (a “calculator”) created with NetBeans.
- It includes a Swing-based GUI form and a Java class that implements calculation logic.
- It has an Ant build script (build.xml) and the standard NetBeans project metadata (nbproject folder).

##### File structure
- Top level “Calculate” directory contains:
- build.xml – Ant build definitions
- manifest.mf – JAR manifest metadata
- nbproject/ – IDE project configuration
- build/ – compiled classes output
- src/calculate/ holds:
- Calculator.form – GUI layout definition (NetBeans Swing form)
- Calculator.java – controller/business-logic class
- No server, database, or external dependencies.

##### README
- Very brief (“# calculator”), confirming this is a simple GUI calculator tool.

##### Main components
a. Presentation Layer (View)
- Component: CalculatorForm (Swing JFrame + UI widgets)
- Purpose: capture user input (numbers, operators) and display results
b. Controller/Business Logic Layer
- Component: Calculator.java
- Purpose: parse input events, perform arithmetic operations, return results
c. Build & Packaging
- Ant Build (build.xml)
- NetBeans Project Metadata (nbproject/)
- Manifest (manifest.mf) to assemble a runnable JAR
d. Runtime Environment
- Java Virtual Machine (JRE)

##### Relationships & interactions
- User clicks buttons on CalculatorForm → events forwarded to Calculator.java
- Calculator.java computes results and invokes methods on CalculatorForm to update display
- Ant build script compiles src/ → build/classes/ → bundles classes + manifest into .jar

##### Architectural patterns & design principles
- Simple two-tier MVC (View vs. Controller/Logic), no persistence layer
- Separation of UI layout (.form files) from Java code (Calculator.java)
- Build automation via Ant for reproducibility

##### Technologies, frameworks, libraries
- Java SE (Swing for UI)
- Ant (build automation)
- NetBeans (project metadata for IDE support)

##### Final checklist
- All components named and grouped by layer
- Important artefacts (build.xml, manifest.mf) in the build section

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actor
    User["User"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        CalculatorForm["CalculatorForm (Swing UI)"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        CalculatorLogic["Calculator.java (Business Logic)"]:::logic
    end

    %% Build & Packaging Layer
    subgraph "Build & Packaging"
        AntBuild["Ant Build Script (build.xml)"]:::build
        Manifest["JAR Manifest (manifest.mf)"]:::build
        NetBeansMetadata["NetBeans Project Metadata (nbproject/)"]:::build
        CompiledClasses["Compiled Classes (build/classes/)"]:::build
        JarArtifact["Runnable JAR"]:::build
    end

    %% Runtime Environment
    JVM["Java Virtual Machine (JRE)"]:::runtime

    %% Relationships
    User -->|"click buttons"| CalculatorForm
    CalculatorForm -->|"forward events"| CalculatorLogic
    CalculatorLogic -->|"update display"| CalculatorForm

    %% Build flow
    CalculatorLogic -->|"source input"| AntBuild
    CalculatorForm -->|"source input"| AntBuild
    AntBuild -->|"compiles to"| CompiledClasses
    CompiledClasses -->|"bundles with"| Manifest
    CompiledClasses -->|"bundles with"| NetBeansMetadata
    Manifest --> JarArtifact
    NetBeansMetadata --> JarArtifact
    JarArtifact -->|"runs on"| JVM

    %% Click Events
    click CalculatorForm "https://github.com/mohamedabolyazeed/calculator/blob/main/Calculate/src/calculate/Calculator.form"
    click CalculatorLogic "https://github.com/mohamedabolyazeed/calculator/blob/main/Calculate/src/calculate/Calculator.java"
    click AntBuild "https://github.com/mohamedabolyazeed/calculator/blob/main/Calculate/build.xml"
    click Manifest "https://github.com/mohamedabolyazeed/calculator/blob/main/Calculate/manifest.mf"
    click NetBeansMetadata "https://github.com/mohamedabolyazeed/calculator/tree/main/Calculate/nbproject/"
    click CompiledClasses "https://github.com/mohamedabolyazeed/calculator/tree/main/Calculate/build/classes/"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef logic fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef build fill:#eeeeee,stroke:#757575,color:#212121
    classDef runtime fill:#fff9c4,stroke:#fdd835,color:#f57f17
    classDef external fill:#f8bbd0,stroke:#e91e63,color:#880e4f
```
