# rouzzle/rouzzle_ios architecture

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

- Interactive diagram: https://gitdiagram.com/rouzzle/rouzzle_ios
- Repository: https://github.com/rouzzle/rouzzle_ios

## Overview

##### Project type and purpose
- This is a native iOS mobile application (“Rouzzle_iOS”) built with SwiftUI and the MVVM pattern.
- Purpose: help users build and track daily routines (AddRoutine, Home, Recommend, RoutineTimer, Statistic features), using on-device data storage and local recommendation logic.

##### High-level architecture and main components
a. App entry point
- Rouzzle_iOSApp.swift – SwiftUI App struct, sets up the DI container (Container.swift) and the root ContentView.
b. Feature modules (each follows MVVM)
- AddRoutine (Model, ViewModel, View)
- Home (Model, ViewModel, View)
- Recommend (Model, ViewModel, View)
- RoutineTimer (Model, ViewModel, View)
- Statistic (View)
c. Shared utilities and services
- Utils/Component – reusable SwiftUI UI components (buttons, alerts, pickers)
- Utils/Emoji – emoji picker components and view model
- Utils/Functions – pure helper functions (string conversion, statistics utils)
- Utils/Global – service implementations (QuotesProvider, RecommendTaskService, SwiftDataService)
- Utils/Protocol – service interfaces for DI (RecommendTaskServiceProtocol, SwiftDataServiceProtocol)
- NotificationManager – schedules local notifications
d. Data & resources
- Resources/RecommendTasks.json, RecommendTodoTasks.json – static recommendation data
- SwiftDataService – core data or SwiftData-backed persistence
- Assets.xcassets / Fonts – UI assets and typography

##### Relationships and data-flow
- Views bind to their ViewModels (via @StateObject or @ObservedObject).
- ViewModels depend on one or more services (through service protocols) to load/save data, fetch recommendations, provide quotes, schedule notifications.
- Services use JSON files or SwiftDataService for persistence.
- Container.swift wires up these dependencies with a simple DI approach: registers protocol implementations, instantiates view models, injects into root view.

##### Architectural patterns & principles
- MVVM per feature – clear separation of View, ViewModel, Model
- Service layer – protocols + implementations for data persistence and business logic
- Dependency Injection – Container.swift ensures testability and loose coupling
- SwiftUI + Combine/Publisher extensions for reactive UI updates
- Feature modularization – each feature in its own folder

##### Essential elements
– Arrowheads on all lines to denote direction of data or control flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "App Entry Point"
        A1["Rouzzle_iOSApp"]:::presentation
        A2["Container"]:::presentation
        A3["ContentView"]:::presentation
    end

    subgraph "Presentation Layer (Views)" 
        subgraph "AddRoutine"
            ARV1["AddRoutineContainerView"]:::presentation
            ARV2["AddRoutineView"]:::presentation
            ARV3["AddRoutineTaskView"]:::presentation
            ARV4["NewTaskSheetView"]:::presentation
            ARV5["TimeBasedRecommendSetView"]:::presentation
            ARV6["WeekSetTimeView"]:::presentation
        end
        subgraph "Home"
            HV1["RoutineHomeView"]:::presentation
            HV2["HeaderView"]:::presentation
            HV3["TaskListView"]:::presentation
            HV4["RoutineItemView"]:::presentation
            HV5["RoutineFilterToggle"]:::presentation
            HV6["RoutineSettingsSheet"]:::presentation
        end
        subgraph "Recommend"
            RV1["RecommendView"]:::presentation
            RV2["RecommendSheet"]:::presentation
            RV3["RecommendCardListView"]:::presentation
            RV4["RecommendCategoryView"]:::presentation
            RV5["RecommendExpandedCardView"]:::presentation
            RV6["RecommendTaskView"]:::presentation
            RV7["RecommendedSetView"]:::presentation
        end
        subgraph "RoutineTimer"
            RTV1["RoutineTimerView"]:::presentation
            RTV2["RoutineCompleteView"]:::presentation
            RTV3["TaskListSheet"]:::presentation
        end
        subgraph "Statistic"
            SV1["StatisticView"]:::presentation
            SV2["RoutineSummaryView"]:::presentation
            SV3["CalenderView"]:::presentation
            SV4["File.txt"]:::presentation
        end
    end

    subgraph "Presentation-Logic Layer (ViewModels)"
        subgraph "AddRoutine VM"
            ARVM["AddRoutineViewModel"]:::viewmodel
        end
        subgraph "Home VM"
            HVM1["RoutineHomeViewModel"]:::viewmodel
            HVM2["TaskListViewModel"]:::viewmodel
        end
        subgraph "Recommend VM"
            RVM["RecommendViewModel"]:::viewmodel
        end
        subgraph "RoutineTimer VM"
            RTVM1["RoutineTimerViewModel"]:::viewmodel
            RTVM2["RoutineCompleteViewModel"]:::viewmodel
        end
    end

    subgraph "Service Layer"
        S1["RecommendTaskService"]:::service
        S2["QuotesProvider"]:::service
        S3["SwiftDataService"]:::service
        S4["NotificationManager"]:::service
    end

    subgraph "Data & Resource Layer"
        D1["RecommendTasks.json"]:::data
        D2["RecommendTodoTasks.json"]:::data
        D3["SwiftData Store"]:::data
        D4["Assets.xcassets & Fonts"]:::data
    end

    %% App wiring
    A1 --> A2
    A2 --> A3

    %% Views to ViewModels
    ARV1 --> ARVM
    ARV2 --> ARVM
    ARV3 --> ARVM
    ARV4 --> ARVM
    ARV5 --> ARVM
    ARV6 --> ARVM

    HV1 --> HVM1
    HV2 --> HVM1
    HV3 --> HVM2
    HV4 --> HVM2
    HV5 --> HVM1
    HV6 --> HVM2

    RV1 --> RVM
    RV2 --> RVM
    RV3 --> RVM
    RV4 --> RVM
    RV5 --> RVM
    RV6 --> RVM
    RV7 --> RVM

    RTV1 --> RTVM1
    RTV2 --> RTVM2
    RTV3 --> RTVM1

    SV1 -.-> SV2
    SV2 -.-> SV3
    SV3 -.-> SV4

    %% ViewModels to Services
    ARVM --> S3
    ARVM --> S1
    HVM1 --> S3
    HVM2 --> S3
    RVM --> S1
    RVM --> S3
    RVM --> S2
    RTVM1 --> S3
    RTVM2 --> S3
    RTVM1 --> S4

    %% Services to Data
    S1 --> D1
    S1 --> D2
    S3 --> D3
    S2 --> D4
    S4 --> D3

    %% Legend
    subgraph "Legend"
        L1["Views (light blue)"]:::presentation
        L2["ViewModels (light green)"]:::viewmodel
        L3["Services (light orange)"]:::service
        L4["Data (light gray)"]:::data
    end

    %% Click events
    click A1 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/App/Rouzzle_iOSApp.swift"
    click A2 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/App/Container.swift"
    click A3 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/App/ContentView.swift"
    click ARVM "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/ViewModel/AddRoutineViewModel.swift"
    click ARV1 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/AddRoutineContainerView.swift"
    click ARV2 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/AddRoutineView.swift"
    click ARV3 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/AddRoutineTaskView.swift"
    click ARV4 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/NewTaskSheetView.swift"
    click ARV5 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/TimeBasedRecommendSetView.swift"
    click ARV6 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Features/AddRoutine/View/WeekSetTimeView.swift"
    click D1 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Resource/RecommendTasks.json"
    click D2 "https://github.com/rouzzle/rouzzle_ios/blob/develop/Rouzzle_iOS/Rouzzle_iOS/Resource/RecommendTodoTasks.json"

    classDef presentation fill:#E0F7FA,stroke:#006064;
    classDef viewmodel fill:#E8F5E9,stroke:#1B5E20;
    classDef service fill:#FFF3E0,stroke:#E65100;
    classDef data fill:#ECEFF1,stroke:#37474F;
```
