# ip25-solutions/quickcalculator architecture

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

- Interactive diagram: https://gitdiagram.com/ip25-solutions/quickcalculator
- Repository: https://github.com/ip25-solutions/quickcalculator

## Overview

##### Project’s Main Components
- UI / Presentation Layer:
- This is implemented in the "app/src/main/java/com/ipsolutions/quickcalculator/presentation" directory (e.g., MainScreen.kt) along with the UI styles under "ui/theme". The UI leverages Jetpack Compose.
- Business Logic / ViewModel:
- While the file structure does not have an explicit "viewmodel" folder, the "logic" directory (e.g., CalculatorEstate.kt) appears to handle state management and logic that sits between the UI and core computational components.
- Core / Domain Layer:
- The "core" directory (e.g., Calculator.kt) encapsulates key functionalities. These files contain the fundamental operations and possibly core business rules or algorithms.
- Evaluation Component:
- As cited in the README, JavaScript (via the ScriptEngineManager) is used to evaluate mathematical expressions, so include an evaluation engine component that interacts with the core logic.
- Android System Components:
- AndroidManifest.xml, resource directories (res for UI layouts, images, themes, etc.), and configuration files that are essential for app initialization and styling.
- Testing Components:
- Existence of both instrumented tests ("app/src/androidTest") and unit tests ("app/src/test"), indicating a separation for verifying UI / integration aspects and core functionality.

##### Relationships and Interactions
- The UI components (the Compose screens and theme definitions) interact with the ViewModel (or logic layer) using the MVVM pattern.
- The ViewModel (or state/logic layer) orchestrates user interactions from the UI and communicates with the Core domain (Calculator operations).
- The Core component may also interface with the JavaScript evaluation engine to compute expressions.
- Testing layers interact with each of these components as separate units, ensuring modularity.
- Any build and deployment processes are managed via gradle scripts (build.gradle.kts, settings.gradle.kts) which are separate from runtime architecture but crucial for the build pipeline.

##### Architectural Patterns and Technologies
- MVVM: Enforce the separation between UI (View), logic/state management (ViewModel), and business rules (Model/Core).
- Jetpack Compose: Defines how UI elements are declared and updated.
- Kotlin: The core programming language throughout the project.
- JavaScript Evaluation: A specific sub-component (invoked via ScriptEngineManager) for handling mathematical expression parsing and evaluation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "UI/Presentation Layer"
        UITheme["Presentation - UI Theme"]:::ui
        MainScreen["Presentation - MainScreen (Entry Point)"]:::ui
    end

    %% Logic / ViewModel Layer
    subgraph "Logic / ViewModel Layer"
        CalculatorEstate["Logic - CalculatorEstate"]:::logic
    end

    %% Domain / Core Layer
    subgraph "Domain / Core Layer"
        Calculator["Domain - Calculator"]:::domain
    end

    %% Evaluator Component
    subgraph "Evaluator Component"
        JSEvaluator["Evaluator - JavaScript Engine"]:::util
    end

    %% Android System Components
    subgraph "Android System Components"
        AndroidManifest["AndroidManifest.xml"]:::system
        ResFiles["Resource Files (res/)"]:::system
    end

    %% Testing Components
    subgraph "Testing Components"
        InstrTest["Instrumented Tests"]:::test
        UnitTest["Unit Tests"]:::test
    end

    %% Build & Configuration Components
    subgraph "Build & Configuration"
        AppBuild["App Build Script (Gradle)"]:::build
        BuildScript["Build Script (Gradle)"]:::build
        Settings["Settings (Gradle)"]:::build
    end

    %% Relationships
    UITheme -->|"styles"| MainScreen
    MainScreen -->|"sendsUserInput"| CalculatorEstate
    CalculatorEstate -->|"invokesOperation"| Calculator
    Calculator -->|"usesEvaluator"| JSEvaluator

    AndroidManifest -->|"initializesApp"| MainScreen
    ResFiles -->|"providesAssets"| UITheme

    AppBuild -->|"buildsApp"| AndroidManifest
    BuildScript -->|"buildsApp"| AndroidManifest
    Settings -->|"configuresApp"| AndroidManifest

    InstrTest ---|"testsUI"| MainScreen
    InstrTest ---|"testsUI"| UITheme
    UnitTest ---|"testsLogicDomain"| CalculatorEstate
    UnitTest ---|"testsLogicDomain"| Calculator

    %% Legend
    subgraph "Legend"
        L1["UI Component - Blue"]:::ui
        L2["Logic Component - Green"]:::logic
        L3["Domain Component - Gold"]:::domain
        L4["Utility/JS Evaluator - Salmon"]:::util
        L5["Android System - LightGrey"]:::system
        L6["Testing - Pink"]:::test
        L7["Build/Config - Lavender"]:::build
    end

    %% Click Events
    click MainScreen "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/main/java/com/ipsolutions/quickcalculator/presentation/MainScreen.kt"
    click UITheme "https://github.com/ip25-solutions/quickcalculator/tree/master/app/src/main/java/com/ipsolutions/quickcalculator/ui/theme"
    click CalculatorEstate "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/main/java/com/ipsolutions/quickcalculator/logic/CalculatorEstate.kt"
    click Calculator "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/main/java/com/ipsolutions/quickcalculator/core/Calculator.kt"
    click AndroidManifest "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/main/AndroidManifest.xml"
    click ResFiles "https://github.com/ip25-solutions/quickcalculator/tree/master/app/src/main/res"
    click InstrTest "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/androidTest/java/com/ipsolutions/quickcalculator/ExampleInstrumentedTest.kt"
    click UnitTest "https://github.com/ip25-solutions/quickcalculator/blob/master/app/src/test/java/com/ipsolutions/quickcalculator/ExampleUnitTest.kt"
    click AppBuild "https://github.com/ip25-solutions/quickcalculator/blob/master/app/build.gradle.kts"
    click BuildScript "https://github.com/ip25-solutions/quickcalculator/blob/master/build.gradle.kts"
    click Settings "https://github.com/ip25-solutions/quickcalculator/blob/master/settings.gradle.kts"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef domain fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef util fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef system fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef test fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef build fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef legend fill:#ffffff,stroke:#000,stroke-width:1px;
```
