# charityhsu/yip architecture

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

- Interactive diagram: https://gitdiagram.com/charityhsu/yip
- Repository: https://github.com/charityhsu/yip

## Overview

##### Main Components
- Model:
- Manages encoding/decoding of data using the Codable protocol as well as data persistence.
- Core Data is used for persistence, indicated by the YearInPixels.xcdatamodeld directory.

- View:
- Contains all UI elements including storyboards (LaunchScreen.storyboard and Main.storyboard) located under the Base.lproj folder.
- Custom UI components like the CollectionViewCell, CustomLayout, and SectionHeaderView.

- Controller:
- Holds the glue between Model and View. Controllers include MonthViewController, ParentViewController, PopupVC, ReminderVC, and YearViewController.
- Handles user interactions, navigation, and updating the UI.

- Application Lifecycle & External Services:
- AppDelegate.swift and SceneDelegate.swift manage the overall application lifecycle.
- Integration points for local notifications and system alerts.
- Sound (button_tap.mp3) is used to provide user feedback.

- Xcode Project Files:

##### Out the Interactions
- Communication flow starting with the AppDelegate/SceneDelegate initializing the application.
- How the View layer (via storyboards and custom UI components) is connected to the Controller layer.
- How Controller objects (e.g., MonthViewController and YearViewController) interact with Models to load, persist, and modify data.
- Directional flows such as:
- User actions triggering Controller events.
- Controller updates altering Model state.
- Model changes prompting updates in the View.
- How the app manages local notifications (reminders) and plays audio feedback through the Audio component.

##### Architectural Patterns & Design Principles
- Clearly denote the Model-View-Controller separation, emphasizing how the responsibilities are divided.
- How UIKit components (like UICollectionView) enable complex layouts and interactions.
- Mention that no third-party libraries are used, which reinforces a pure UIKit and Swift-based approach.

##### Relevant Technologies, Frameworks, and Tools
- Swift 5 as the programming language and Xcode 11 as the development IDE.
- UIKit for the UI, Core Data for data persistence, and local notification frameworks.
- Auto Layout and Storyboard for building the interface.
- That the app leverages native iOS frameworks to manage data flows and UI rendering.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services Subgraph
    subgraph "External Services"
        AD["App Delegate"]:::external
        SD["Scene Delegate"]:::external
        AF["Audio Feedback"]:::external
        LN["Local Notifications"]:::external
    end

    %% Presentation Layer (View) Subgraph
    subgraph "Presentation Layer (View)"
        SB["Storyboards"]:::view
        CV["CollectionViewCell"]:::view
        CL["CustomLayout"]:::view
        SH["SectionHeaderView"]:::view
        AS["Assets"]:::view
    end

    %% Application Logic (Controller) Subgraph
    subgraph "Application Logic (Controller)"
        CT["Controllers"]:::controller
    end

    %% Data Management (Model) Subgraph
    subgraph "Data Management (Model)"
        DM["Domain Logic (Data Structures)"]:::model
        PD["Core Data Persistence"]:::persistence
    end

    %% User Node
    U["User"]:::user

    %% Connections
    U -->|"triggers"| SB
    U -->|"triggers"| CV
    U -->|"triggers"| CL
    U -->|"triggers"| SH
    U -->|"triggers"| AS

    SB -->|"loadsUI"| CT
    CV -->|"interacts"| CT
    CL -->|"interacts"| CT
    SH -->|"interacts"| CT
    AS -->|"providesAssets"| CT

    AD -->|"initializes"| CT
    SD -->|"managesScenes"| CT

    CT -->|"processes"| DM
    DM -->|"persists"| PD

    CT -->|"playsSound"| AF
    CT -->|"schedulesNotif"| LN
    DM -->|"updatesUI"| SB

    %% Click Events
    click DM "https://github.com/charityhsu/yip/tree/master/YearInPixels/Model/"
    click PD "https://github.com/charityhsu/yip/tree/master/YearInPixels/YearInPixels.xcdatamodeld/"
    click SB "https://github.com/charityhsu/yip/tree/master/YearInPixels/View/Base.lproj/"
    click CV "https://github.com/charityhsu/yip/blob/master/YearInPixels/View/CollectionViewCell.swift"
    click CL "https://github.com/charityhsu/yip/blob/master/YearInPixels/View/CustomLayout.swift"
    click SH "https://github.com/charityhsu/yip/blob/master/YearInPixels/View/SectionHeaderView.swift"
    click AS "https://github.com/charityhsu/yip/tree/master/YearInPixels/View/Assets.xcassets/"
    click CT "https://github.com/charityhsu/yip/tree/master/YearInPixels/Controller/"
    click AD "https://github.com/charityhsu/yip/blob/master/YearInPixels/Resources/AppDelegate.swift"
    click SD "https://github.com/charityhsu/yip/blob/master/YearInPixels/Resources/SceneDelegate.swift"
    click AF "https://github.com/charityhsu/yip/blob/master/YearInPixels/Resources/button_tap.mp3"

    %% Styles
    classDef user stroke:#8e44ad,fill:#dcd0ff,stroke-width:2px;
    classDef view stroke:#e67e22,fill:#fdebd0,stroke-width:2px;
    classDef controller stroke:#2980b9,fill:#d6eaf8,stroke-width:2px;
    classDef model stroke:#27ae60,fill:#d4efdf,stroke-width:2px;
    classDef persistence stroke:#1e8449,fill:#d0ece7,stroke-width:2px;
    classDef external stroke:#c0392b,fill:#f9e79f,stroke-width:2px;
```
