# antranapp/scenarios architecture

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

- Interactive diagram: https://gitdiagram.com/antranapp/scenarios
- Repository: https://github.com/antranapp/scenarios

## Overview

##### Main Components
- App Controllers – Various controllers in Sources/Scenarios/AppController (e.g., BasicAppController, NavigationAppController, ScenarioSelectorAppController, etc.) are responsible for defining how the scenario is applied at runtime. They mediate between the scenario configuration and the rest of the app’s UI.
- UI & Views Modules – The framework includes multiple UI modules (using SwiftUI and UIKit) found in folders like Pexels/Sources/Common/Views, Sample/Sample/Sources/Common/Views, and Scenarios-related views. Clearly denote these as Presentation layers.
- Networking & Services – The repositories include networking components (e.g., NetworkClient, GithubService) and helper services (e.g., FavouritesImageManager, AuthenticationService) that provide the data layer for the demos. Represent these as data service modules.
- Mocks & Scenarios – In addition to production implementations, there are mock services (inside folders like Scenarios/Mocks and Sample/Sample/Sources/Internal/Mocks) that support rapid prototyping and testing. Clearly note the dual environments (Production vs. Mock) and how they interface with the Scenario Manager.
- Assets & Configuration – There are multiple assets folders and configuration files (e.g., Info.plist variants for Production, Internal, etc.) that indicate environment-specific settings. Include these as configuration components that feed into both the scenario logic and the build process.

##### Relationships and Interactions
- App Controllers: They handle switching between different UI flows and rendering the selected scenario.
- Networking/Services: The selected scenario will also determine whether to use production or mocked data sources.
- Build configuration elements (e.g., Package.swift, build scripts in Scripts/) which influence the overall application configuration and deployment environment.

##### Architectural Patterns and Design Principles
- Modular Architecture – The design follows a clear modular separation between core services and various scenario implementations. Emphasize the recommended modular approach.
- MVVM/MVC for UI – Although not explicitly named, the presence of ViewModels (e.g., DashboardViewModel, FavouritesViewModel) alongside Views suggests an MVVM pattern. Represent this pattern in the UI layer.
- Dependency Injection / Environment Abstraction – The ability to swap between production and mocked services implies a design pattern for loosely coupling components (e.g., passing implementations of Networking or Services interfaces). Note these dependencies accordingly.
- Extensibility – The framework is built to allow new types of scenarios. Document extensibility points where new scenarios can integrate into the scenario manager and app controllers.

##### Relevant Technologies, Frameworks, or Libraries
- Swift – The whole project is written in Swift, and uses the Swift Package Manager (Package.swift) for dependency management.
- Xcode Projects – There are multiple Xcode projects (Pexels, Sample, and Scenarios workspaces) that demonstrate how various scenarios are constructed and run.
- GitHub API Integration – In the Sample app, networking components integrate with GitHub, so highlight the external service dependency for data.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build & Config Tools
    subgraph "Build & Config Tools"
        PackageConfig["Package.swift"]:::build
        Scripts["Scripts/"]:::build
    end

    %% Assets & Configuration
    subgraph "Assets & Configuration"
        GlobalAssets["Global Assets"]:::config
        SampleResources["Sample Resources"]:::config
        PexelsMedia["Pexels Production Media"]:::config
        PexelsScenariosMedia["Pexels Scenarios Media"]:::config
    end

    %% Core Framework
    subgraph "Core Framework"
        ScenarioManager["Scenario Manager"]:::core
        ScenarioFolder["Scenario Folder"]:::core
        AppControllers["App Controllers"]:::core
    end

    %% Networking & Services
    subgraph "Networking & Services"
        PexelsNetworking["Pexels Networking"]:::data
        PexelsServices["Pexels Services"]:::data
        SampleNetworking["Sample Networking"]:::data
    end

    %% Mocks & Scenarios
    subgraph "Mocks & Scenarios"
        PexelsMocks["Pexels Mocks"]:::mock
        SampleMocks["Sample Mocks"]:::mock
        SampleScenarios["Sample Scenarios"]:::mock
    end

    %% UI & Views Modules
    subgraph "UI & Views Modules"
        PexelsViews["Pexels Views"]:::ui
        SampleViews["Sample Views"]:::ui
    end

    %% Relationships
    PackageConfig -->|"configures"| GlobalAssets
    Scripts -->|"runs"| GlobalAssets
    GlobalAssets -->|"feeds"| ScenarioManager
    Scripts -->|"setup"| ScenarioManager

    ScenarioManager -->|"uses"| ScenarioFolder
    ScenarioManager -->|"controls"| AppControllers

    ScenarioManager -->|"injects"| PexelsNetworking
    ScenarioManager -->|"injects"| PexelsServices
    ScenarioManager -->|"injects"| SampleNetworking

    ScenarioManager -->|"selects"| PexelsMocks
    ScenarioManager -->|"selects"| SampleMocks
    ScenarioManager -->|"selects"| SampleScenarios

    AppControllers -->|"manages"| PexelsViews
    AppControllers -->|"manages"| SampleViews

    %% Click Events
    click ScenarioManager "https://github.com/antranapp/scenarios/blob/master/Sources/Scenarios/ScenariosManager.swift"
    click ScenarioFolder "https://github.com/antranapp/scenarios/tree/master/Sources/Scenarios/Scenario/"
    click AppControllers "https://github.com/antranapp/scenarios/tree/master/Sources/Scenarios/AppController/"
    click PexelsViews "https://github.com/antranapp/scenarios/tree/master/Pexels/Sources/Common/Views"
    click SampleViews "https://github.com/antranapp/scenarios/tree/master/Sample/Sample/Sources/Common/Views"
    click PexelsNetworking "https://github.com/antranapp/scenarios/tree/master/Pexels/Sources/Common/Networking"
    click PexelsServices "https://github.com/antranapp/scenarios/tree/master/Pexels/Sources/Common/Services"
    click SampleNetworking "https://github.com/antranapp/scenarios/tree/master/Sample/Sample/Sources/Common/Networking"
    click PexelsMocks "https://github.com/antranapp/scenarios/tree/master/Pexels/Sources/Scenarios/Mocks"
    click SampleMocks "https://github.com/antranapp/scenarios/tree/master/Sample/Sample/Sources/Internal/Mocks"
    click SampleScenarios "https://github.com/antranapp/scenarios/tree/master/Sample/Sample/Sources/Internal/Scenarios"
    click GlobalAssets "https://github.com/antranapp/scenarios/tree/master/Assets"
    click SampleResources "https://github.com/antranapp/scenarios/tree/master/Sample/Sample/Resources"
    click PexelsMedia "https://github.com/antranapp/scenarios/blob/master/Pexels/Sources/Production/Media.xcassets"
    click PexelsScenariosMedia "https://github.com/antranapp/scenarios/blob/master/Pexels/Sources/Scenarios/Media.xcassets"
    click PackageConfig "https://github.com/antranapp/scenarios/blob/master/Package.swift"
    click Scripts "https://github.com/antranapp/scenarios/tree/master/Scripts/"

    %% Styles
    classDef core fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ui fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef build fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef config fill:#FDEBD0,stroke:#CA6F1E,stroke-width:2px;
    classDef mock fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
