# appbrewery/bmi-calculator-ios13 architecture

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

- Interactive diagram: https://gitdiagram.com/appbrewery/bmi-calculator-ios13
- Repository: https://github.com/appbrewery/bmi-calculator-ios13

## Overview

##### Main Components
- App Lifecycle & Configuration: Represent the application startup and lifecycle managed by AppDelegate.swift and SceneDelegate.swift. These components tie into the iOS app framework and set the stage for view rendering.
- Controllers (Logic & User Interaction): Highlight the “Controllers” directory which contains ViewController.swift. This is where user input from the UI (e.g., height and weight entries) is received, processed, and where the BMI calculation is performed.
- Business Logic & Data Processing: Although not a separate module in such a small project, the calculation logic embedded in the view controllers embodies the core functionality. Clearly show how input is processed (such as converting strings to numbers, optionally handling nil values, performing the BMI calculation, and delivering health advice).

##### Relationships and Interactions
- Data flows from the user input in the views to the corresponding controller.
- The controller then performs computations (using logic to calculate BMI) and updates the views with results.
- The system’s lifecycle in the AppDelegate and SceneDelegate orchestrates the loading and presentation of the UI.
- Assets and localized resources (from Assets.xcassets and Base.lproj directories) support UI rendering and localization.

##### Architectural Patterns & Design Principles
- Use the MVC (Model-View-Controller) design pattern. Even if the “Model” isn’t explicitly separated into its own files (given the simplicity of this project), emphasize how the View Controller is responsible for both data processing and view updates.
- Concept of using Optionals in Swift to safely handle user inputs and enforce strong type safety.
- Separation of concerns: while the view handles user data and presentation, the controller manages interactions and calculations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Lifecycle (AppDelegate & SceneDelegate)"
        AD["AppDelegate.swift"]:::lifecycle
        SD["SceneDelegate.swift"]:::lifecycle
    end

    subgraph "User Interface (Storyboards & Assets)"
        LS["LaunchScreen.storyboard"]:::ui
        MS["Main.storyboard"]:::ui
        AS["Assets.xcassets"]:::ui
    end

    subgraph "Controllers"
        VC["ViewController.swift"]:::controller
    end

    %% Relationships
    AD -->|"configures"| LS
    AD -->|"configures"| MS
    SD -->|"configures"| LS
    SD -->|"configures"| MS
    LS -->|"userAction"| VC
    MS -->|"userAction"| VC
    VC -->|"updatesUI"| MS
    MS -->|"loadsAssets"| AS

    %% Click events
    click AD "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/AppDelegate.swift"
    click SD "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/SceneDelegate.swift"
    click LS "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/Base.lproj/LaunchScreen.storyboard"
    click MS "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/Views/Base.lproj/Main.storyboard"
    click AS "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/Assets.xcassets"
    click VC "https://github.com/appbrewery/bmi-calculator-ios13/blob/master/BMI Calculator/Controllers/ViewController.swift"

    %% Styles
    classDef lifecycle fill:#FAD7A0,stroke:#000,stroke-width:2px;
    classDef ui fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef controller fill:#A9DFBF,stroke:#000,stroke-width:2px;
```
