# hicte/light_calculator architecture

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

- Interactive diagram: https://gitdiagram.com/hicte/light_calculator
- Repository: https://github.com/hicte/light_calculator

## Overview

##### Main Components
- Flutter Application (Core): The heart of the application is in the “lib” directory which includes:
– Entry point (lib/main.dart) that initializes the app.
– The UI screens such as home_screen (in lib/screens) and custom widgets (displayer, keyboard_button, keyboart).
– Business logic modules such as lib/calculator.dart for calculation functionality and lib/constants.dart for app constants.
– Utility functions (lib/utils/utils.dart) that support these modules.
- Platform-specific Wrappers: In the platform-specific directories (android, ios, linux, and web), Flutter’s generated files, platform integration, and configuration settings enable the application to run on each system. For example:
– Android: The “android” directory with Gradle build scripts and platform-specific Kotlin/Java code.
– iOS: The “ios” folder with Xcode projects and Swift code (AppDelegate.swift).
– Linux & Web: Each of these have their own entry points (like linux/main.cc and web/index.html).
- Plugins & External Dependencies: The generated plugin registrants (e.g., GeneratedPluginRegistrant.java for Android and ios/Runner/GeneratedPluginRegistrant.*) indicate the use of external Dart/Flutter plugins that interface with native platform capabilities.

##### Relationships and Interactions
- The Flutter App (core) runs as a single code base that includes UI layers (screens and widgets) and business logic (calculator algorithms, utilities).
- When deployed, the Flutter framework interoperates with the native platform through the platform channels. For instance, the Android and iOS specific code handles platform-specific services, while on web and Linux the Flutter engine operates via web rendering and CMake respectively.
- The modular separation (UI, business logic, utilities) helps maintain clarity in responsibilities, and navigation flows from the entry point (main.dart) to various UI components.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The code is divided into presentation (UI/screens/widgets), business logic (calculator.dart), and helper utilities (utils.dart).
- Cross-Platform Abstraction: Flutter’s single code base abstracts platform differences, with dedicated directories for handling native-specific configurations and integrations.
- Plugin Architecture: Usage of plugins facilitates native functionality while preserving uniform Flutter code.

##### Relevant Technologies and Tools
- Flutter SDK & Dart: Central for application development.
- Gradle (Android) / Xcode (iOS): For platform-specific builds.
- CMake (Linux) and HTML/CSS/JS (Web): For building on Linux and web platforms.
- IDE integration (as shown by .idea and .iml files) which might influence the development environment.

##### Instructed Elements
- Use clear labels:
– “Core Flutter App” (housing main.dart, UI screens, business logic, and utilities).
– “Platform Integrations” with child nodes: Android (including Gradle, Kotlin), iOS (with Swift, Xcode), Linux (CMake, C++ files), and Web (HTML, manifest).
– “Flutter Engine & Plugins” (denoting plugin registrants and helper code interfacing with native code).
– From the core app to each platform-specific environment to illustrate the deployment flow.
– Indicate data flow between the UI (e.g., calculator input widgets) and the business logic (calculation algorithms).
– Show feedback loops for user interactions.

##### Final Detailed Overview
– Include an intermediary layer representing the “Flutter Engine & Plugin System” that bridges the core Flutter code with the native code in each platform.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Flutter App"
        A["Entry Point: main.dart"]:::flutter
        B["UI Layer (Screens & Widgets)"]:::flutter
        C["Business Logic (Calculator & Constants)"]:::flutter
        D["Utilities (Utils)"]:::flutter
        A --> B
        B --> C
        C --> D
    end

    E["Flutter Engine & Plugin System"]:::engine
    A --> E

    subgraph "Platform Integrations"
        subgraph Android
            A1["Android - GeneratedPluginRegistrant"]:::android
            A2["Android - MainActivity"]:::android
            A1 --> A2
        end
        subgraph iOS
            I1["iOS - AppDelegate"]:::ios
            I2["iOS - PluginRegistrant"]:::ios
            I1 --> I2
        end
        subgraph Linux
            L1["Linux - Main (C++)"]:::linux
            L2["Linux - Build Config"]:::linux
            L3["Linux - GeneratedPluginRegistrant"]:::linux
            L1 --> L2
            L2 --> L3
        end
        subgraph Web
            W1["Web - Index"]:::web
            W2["Web - Manifest"]:::web
            W1 --> W2
        end
    end

    E --> A1
    E --> I1
    E --> L1
    E --> W1

    classDef flutter fill:#007BFF,stroke:#333,color:#fff;
    classDef engine fill:#6c757d,stroke:#333,color:#fff;
    classDef android fill:#28a745,stroke:#333,color:#fff;
    classDef ios fill:#fd7e14,stroke:#333,color:#fff;
    classDef linux fill:#6f42c1,stroke:#333,color:#fff;
    classDef web fill:#20c997,stroke:#333,color:#fff;

    click A "https://github.com/hicte/light_calculator/blob/main/lib/main.dart"
    click B "https://github.com/hicte/light_calculator/tree/main/lib/screens"
    click C "https://github.com/hicte/light_calculator/blob/main/lib/calculator.dart"
    click D "https://github.com/hicte/light_calculator/blob/main/lib/utils/utils.dart"

    click A1 "https://github.com/hicte/light_calculator/blob/main/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java"
    click A2 "https://github.com/hicte/light_calculator/blob/main/android/app/src/main/kotlin/com/example/light_calculator/MainActivity.kt"

    click I1 "https://github.com/hicte/light_calculator/blob/main/ios/Runner/AppDelegate.swift"
    click I2 "https://github.com/hicte/light_calculator/blob/main/ios/Runner/GeneratedPluginRegistrant.{h,m}"

    click L1 "https://github.com/hicte/light_calculator/blob/main/linux/main.cc"
    click L2 "https://github.com/hicte/light_calculator/blob/main/linux/CMakeLists.txt"
    click L3 "https://github.com/hicte/light_calculator/blob/main/linux/flutter/generated_plugin_registrant.{cc,h}"

    click W1 "https://github.com/hicte/light_calculator/blob/main/web/index.html"
    click W2 "https://github.com/hicte/light_calculator/blob/main/web/manifest.json"
```
