# todaywhat/todaywhat-ios architecture

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

- Interactive diagram: https://gitdiagram.com/todaywhat/todaywhat-ios
- Repository: https://github.com/todaywhat/todaywhat-ios

## Overview

##### Main Components Identification

The system should be divided into these major components:

a. Platform-specific Applications:
- iOS App
- watchOS App
- macOS App
- Widgets (iOS and macOS)

b. Core Components:
- Feature Modules
- Shared Components
- User Interface Layer
- Data Layer

##### Component Relationships

Key interactions:
**UI Layer → Feature Modules → Clients → External Services**
- ↑
- Shared Components
- ↑
- Data Layer (Local/Remote)

##### Specific Elements

a. Platform-specific Components:
- iOS main app with widgets
- watchOS app with complications
- macOS app with menu bar integration

b. Feature Modules:
- Meal management
- TimeTable handling
- School settings
- Allergy management
- Tutorial system

c. Shared Infrastructure:
- DesignSystem
- Configuration management
- Dependency injection
- Analytics and logging

d. External Services:
- Neis API integration
- Firebase services
- App Store connection

##### Implementation Details

- SwiftUI as the primary UI framework
- TCA for state management
- Swift Concurrency for async operations
- GRDB for local storage
- WidgetKit integration
- Watch Connectivity framework

##### Data Flow Representation

Clear paths for:
- User interactions
- API data fetching
- Local data persistence
- Cross-device synchronization
- Widget updates

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this multi-platform app work cohesively while sharing code and functionality across different Apple platforms.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Platform Layer"
        iOS["iOS App"]
        Watch["watchOS App"]
        Mac["macOS App"]
        iWidget["iOS Widget"]
        mWidget["macOS Widget"]
    end

    subgraph "Feature Layer"
        MealF["Meal Feature"]
        TimeF["TimeTable Feature"]
        SchoolF["School Settings"]
        AllergyF["Allergy Settings"]
        TutorialF["Tutorial Feature"]
    end

    subgraph "UI Layer"
        DesignSys["Design System"]
    end

    subgraph "Data Layer"
        LocalDB["Local Database"]
        NeisAPI["Neis API Client"]
        MealAPI["Meal API Client"]
        TimeAPI["TimeTable API Client"]
    end

    subgraph "Communication Layer"
        WatchConn["Watch Connectivity"]
        WidgetComm["Widget Communication"]
    end

    subgraph "Infrastructure"
        Analytics["Analytics/Logging"]
        Constants["Constants"]
        Foundation["Foundation Utils"]
        Device["Device Utils"]
    end

    %% Platform connections
    iOS --> DesignSys
    Watch --> DesignSys
    Mac --> DesignSys
    iWidget --> DesignSys
    mWidget --> DesignSys

    %% Feature connections
    iOS --> MealF
    iOS --> TimeF
    iOS --> SchoolF
    iOS --> AllergyF
    iOS --> TutorialF

    Watch --> MealF
    Watch --> TimeF
    Watch --> SchoolF

    Mac --> MealF
    Mac --> TimeF
    Mac --> SchoolF
    Mac --> AllergyF

    %% Data Layer connections
    MealF --> LocalDB
    MealF --> MealAPI
    TimeF --> LocalDB
    TimeF --> TimeAPI
    SchoolF --> NeisAPI

    %% Communication connections
    iOS --> WatchConn
    Watch --> WatchConn
    iOS --> WidgetComm
    iWidget --> WidgetComm
    mWidget --> WidgetComm

    %% Infrastructure usage
    iOS --> Analytics
    Watch --> Analytics
    Mac --> Analytics
    iOS --> Constants
    iOS --> Foundation
    iOS --> Device

    %% Styling
    classDef platform fill:#a8d1f0
    classDef feature fill:#90EE90
    classDef data fill:#FFE5B4
    classDef comm fill:#DDA0DD
    classDef infra fill:#D3D3D3
    classDef ui fill:#ADD8E6

    class iOS,Watch,Mac,iWidget,mWidget platform
    class MealF,TimeF,SchoolF,AllergyF,TutorialF feature
    class LocalDB,NeisAPI,MealAPI,TimeAPI data
    class WatchConn,WidgetComm comm
    class Analytics,Constants,Foundation,Device infra
    class DesignSys ui

    %% Click events
    click iOS "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/App/iOS/"
    click Watch "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/App/watchOS/"
    click Mac "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/App/macOS/"
    click iWidget "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/App/iOS-Widget/"
    click mWidget "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/App/macOS-Widget/"
    click MealF "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Feature/MealFeature/"
    click TimeF "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Feature/TimeTableFeature/"
    click SchoolF "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Feature/SchoolSettingFeature/"
    click AllergyF "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Feature/AllergySettingFeature/"
    click TutorialF "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Feature/TutorialFeature/"
    click DesignSys "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/UserInterface/DesignSystem/"
    click LocalDB "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/LocalDatabaseClient/"
    click NeisAPI "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/NeisClient/"
    click MealAPI "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/MealClient/"
    click TimeAPI "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/TimeTableClient/"
    click WatchConn "https://github.com/todaywhat/TodayWhat-iOS/blob/master/Projects/App/watchOS/Sources/Manager/WatchSessionManager.swift"
    click WidgetComm "https://github.com/todaywhat/TodayWhat-iOS/blob/master/Projects/Shared/ConstantUtil/Sources/AppGroup.swift"
    click Analytics "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/TWLog/"
    click Constants "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/ConstantUtil/"
    click Foundation "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/FoundationUtil/"
    click Device "https://github.com/todaywhat/TodayWhat-iOS/tree/master/Projects/Shared/DeviceUtil/"
```
