# fossasia/susi_ios architecture

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

- Interactive diagram: https://gitdiagram.com/fossasia/susi_ios
- Repository: https://github.com/fossasia/susi_ios

## Overview

##### Main System Components
a. User Interface (UI) Layer:
- Includes the Controllers (found in the “Susi/Controllers” directory), Custom Views (“Susi/Custom Views”), and Storyboards (“Susi/Storyboards”). These components handle user interactions and display data.
- Also includes UI testing (SusiUITests) and the localization support (Susi/Localization).

b. Model / Domain Layer:
- This is represented by the “Susi/Model” directory which contains model classes (e.g., Message, User, Skill, etc.) representing domain data received from—and sent to—the backend.

c. Service / Networking Layer:
- Although not explicitly separated into a “Services” folder, the Models and Helpers (found in “Susi/Helpers”) indicate connections to external APIs (the SUSI Server, as described in the README). This layer is responsible for API communication, data parsing, and any network-dependent logic.

d. External Integrations and Libraries:
- Integration with external libraries like Snowboy (in “Susi/Snowboy Files”) for wake word detection and YouTube Player functionality (“Susi/Youtube-Player”).
- Dependency management via Cocoapods (see the Podfile) and various build scripts (in the Scripts folder) that help automate build, testing, and deployment processes.

e. Build and CI/CD Configuration:
- CI/CD configuration files (.circleci, .github) and various scripts in the “Scripts” directory create a pipeline for building, testing, linting (with SwiftLint), and deploying the app.

##### Relationships and Interactions
- The app’s entry point (AppDelegate in “Susi/Supporting Files”) initializes the UI and sets up the application environment.
- The UI layer (Controllers and Custom Views) interacts with the Model layer to fetch and display data, and it also calls out to the Service layer for executing API calls.
- External integrations such as Snowboy and the YouTube player serve very specific, separate roles and should be depicted as plug-in modules connected to the central communication flow between UI and services.
- Build scripts, configuration files (like Podfile, SwiftLint configurations), and CI/CD pipelines drive the development and deployment processes.

##### Architectural Patterns and Design Principles
- The overall structure follows the MVC or similar architectural patterns where view controllers mediate between the user interface and the underlying data model.
- Separation of concerns is maintained between the UI, business logic (in Controllers and Helpers), and model representations.
- The architecture also accommodates external modules (audio processing via Snowboy, video playback via Youtube-Player) as independent yet connected components.

##### Relevant Technologies and Frameworks
- Swift 4.2 and Xcode 10 for the development environment.
- Cocoapods for dependency management.
- Various external libraries (Snowboy, YouTube Player, FBShimmering for animations) that integrate as sub-modules.
- Testing frameworks (as indicated by the SusiUITests) for UI validation.

##### Specific Elements
- Clear labels for each major component (such as “UI Layer”, “Model Layer”, “Service Layer”, “External Integrations”, “Build/CI Pipeline”).
- Annotations or labels that mention important libraries (Snowboy, Youtube-Player), configuration files (Podfile, SwiftLint config), and development tools (Xcode, Cocoapods, CircleCI).
- A representation of the integration of CI/CD (via .circleci and GitHub folders) that highlights how code quality and deployment processes are handled.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        Controllers["Controllers"]
        CustomViews["Custom Views"]
        Storyboards["Storyboards"]
        Localization["Localization"]
        UITesting["UI Testing"]
    end

    %% Model / Domain Layer
    subgraph "Model / Domain Layer"
        DataModels["Data Models"]
        ClientAPI["Client API"]
    end

    %% Service / Networking Layer
    subgraph "Service / Networking Layer"
        APIHelpers["API Helpers"]
    end

    %% External Integrations and Libraries
    subgraph "External Integrations"
        Snowboy["Snowboy (Wake Word)"]
        YouTube["YouTube Player"]
        FBShimmer["FBShimmering (Animations)"]
    end

    %% Build and CI/CD Configuration
    subgraph "Build / CI/CD"
        CICD["CI/CD Config"]
        BuildScripts["Build Scripts"]
        Dependency["Dependency Management & Linters"]
    end

    %% External Service
    SUSIServer(["SUSI Server"])

    %% Data Flow Connections
    Controllers -->|"fetches/upates"| DataModels
    Controllers -->|"calls"| APIHelpers
    DataModels -->|"uses"| ClientAPI
    ClientAPI -->|"communicates with"| APIHelpers
    APIHelpers -->|"requests to"| SUSIServer
    SUSIServer -->|"responses"| APIHelpers

    %% UI Updates
    DataModels -->|"updates"| CustomViews

    %% External Integrations Connections from UI
    Controllers -->|"triggers"| Snowboy
    Controllers -->|"integrates"| YouTube
    CustomViews -->|"renders"| FBShimmer

    %% Build/CI/CD Flow
    Dependency -->|"manages"| BuildScripts
    BuildScripts -->|"executes"| CICD

    %% Click Events for UI Layer
    click Controllers "https://github.com/fossasia/susi_ios/tree/master/Susi/Controllers"
    click CustomViews "https://github.com/fossasia/susi_ios/tree/master/Susi/Custom Views"
    click Storyboards "https://github.com/fossasia/susi_ios/tree/master/Susi/Storyboards"
    click Localization "https://github.com/fossasia/susi_ios/tree/master/Susi/Localization"
    click UITesting "https://github.com/fossasia/susi_ios/tree/master/SusiUITests"

    %% Click Events for Model / Domain Layer
    click DataModels "https://github.com/fossasia/susi_ios/tree/master/Susi/Model"
    click ClientAPI "https://github.com/fossasia/susi_ios/tree/master/Susi/Model/Client"

    %% Click Event for Service / Networking Layer
    click APIHelpers "https://github.com/fossasia/susi_ios/tree/master/Susi/Helpers"

    %% Click Events for External Integrations
    click Snowboy "https://github.com/fossasia/susi_ios/tree/master/Susi/Snowboy Files"
    click YouTube "https://github.com/fossasia/susi_ios/tree/master/Susi/Youtube-Player"
    click FBShimmer "https://github.com/fossasia/susi_ios/tree/master/Susi/Shimmer"

    %% Click Events for Build / CI/CD
    click CICD "https://github.com/fossasia/susi_ios/blob/master/.circleci"
    click BuildScripts "https://github.com/fossasia/susi_ios/tree/master/Scripts"
    click Dependency "https://github.com/fossasia/susi_ios/tree/master/Podfile"
```
