# alperen23230/rick-and-morty-ios-app architecture

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

- Interactive diagram: https://gitdiagram.com/alperen23230/rick-and-morty-ios-app
- Repository: https://github.com/alperen23230/rick-and-morty-ios-app

## Overview

##### Main Components
- App Core: This includes the main application’s entry points (AppDelegate, SceneDelegate) and primary configurations.
- MVVM Layers: Within the “RickAndMortyiOS” directory, you have subdirectories for Screens (Characters, Episodes, Locations, Character Detail, and Main App) that illustrate the separation into Views and corresponding ViewModels.
- Domain Models & Entities: The Core/Entity directory holds the enumerations, models (network data models, error models) and possibly domain logic.
- Dependency Injection: Although not explicitly labeled, the presence of a dedicated “Core” and various distinct modules implies dependency injection is set up to decouple components.
- Widget Module: The RickAndMortyWidget directory is a separate module that handles iOS 14 widget functionality.

##### Relationships and Interactions
- UI (Screens & Custom Views) ⇔ ViewModels: Illustrate that each screen (such as a view controller or custom view) communicates with a corresponding view model which contains the presentation logic.
- ViewModels ⇔ Networking/Domain: The view models invoke services from the Networking layer to fetch or post data. This data is defined and structured via the Entity/Models classes.
- Networking Layer: Show that network requests (CharactersRequest, EpisodesRequest, LocationsRequest, etc.) are managed by a network service which also relies on Combine to handle asynchronous operations.
- Extensions/Utilities: These are used across the various components to support common functionalities, which can be represented as shared libraries.
- Widget:

##### Architectural Patterns and Design Principles
- MVVM: Clearly demarcate the boundaries between Models, Views, and ViewModels.
- Reactive Programming: Show that Combine is used for handling observable data streams between the layers.
- Modularization: Illustrate the separation between the main app and the widget extension.
- Reusability: Note that commonly used UI and utility extensions are abstracted into reusable components.

##### Relevant Technologies or Frameworks
- UIKit (given the use of storyboards and Xcode project structure)
- Combine (reactive programming)
- Diffable Data Sources and Compositional Layout (for dynamic UI updates)
- Possibly a DI framework or custom dependency injection techniques
- Core Data (planned caching, though currently not implemented)
- iOS WidgetKit (for the widget extension, indirectly indicated by widget support files)

##### Elements
- Use clear labels for each component:
- “Main App UI” (with sub-components like Characters Screen, Episodes Screen, etc.)
- “ViewModels” for corresponding screens
- “Networking Service” and individual request components
- “Domain/Entity Models”
- “Widget Extension”
- “Shared Extensions & Utilities”
- From UI components to their respective ViewModels (data-binding directions)
- From ViewModels to Networking/Services indicating API requests.
- Data flow from Networking back to the ViewModels (using Combine publishers).
- Dependency injection paths between components.
- UI components (e.g., rounded rectangles)
- Relationships, such as “invokes”, “updates”, “communicates with”, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Core
    subgraph "App Core"
        AC1["AppDelegate"]:::appCore
        AC2["SceneDelegate"]:::appCore
    end

    %% UI Layer
    subgraph "UI Layer"
        U1["CharactersViewController"]:::ui
        U2["EpisodesViewController"]:::ui
        U3["LocationsViewController"]:::ui
        U4["CharacterDetailViewController"]:::ui
        U5["MainAppTabBarController"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        VM1["CharactersViewModel"]:::viewModel
        VM2["EpisodesViewModel"]:::viewModel
        VM3["LocationsViewModel"]:::viewModel
    end

    %% Networking Layer
    subgraph "Networking Layer"
        NET["NetworkService"]:::network
        RQ1["CharactersRequest"]:::network
        RQ2["EpisodesRequest"]:::network
        RQ3["LocationsRequest"]:::network
        ENP["Endpoint Definitions"]:::network
    end

    %% Domain Models & Entities
    subgraph "Domain Models & Entities"
        DM["Domain Models & Entities"]:::domain
    end

    %% Extensions & Utilities
    subgraph "Extensions & Utilities"
        EXT["Extensions & Utilities"]:::extension
    end

    %% Dependency Injection
    DI["DI Container"]:::di

    %% Widget Module
    subgraph "Widget Module"
        WID["Widget Extension"]:::widget
    end

    %% Relationships
    %% App Core initializes UI Layer
    AC1 -->|"initializes"| U1
    AC1 -->|"initializes"| U2
    AC1 -->|"initializes"| U3
    AC1 -->|"initializes"| U4
    AC1 -->|"initializes"| U5
    AC2 -->|"initializes"| U1
    AC2 -->|"initializes"| U2
    AC2 -->|"initializes"| U3
    AC2 -->|"initializes"| U4
    AC2 -->|"initializes"| U5

    %% UI Layer binds to ViewModel Layer
    U1 -->|"binds_with"| VM1
    U2 -->|"binds_with"| VM2
    U3 -->|"binds_with"| VM3

    %% DI supplies ViewModels and UI components
    DI -->|"supplies"| VM1
    DI -->|"supplies"| VM2
    DI -->|"supplies"| VM3
    DI -->|"configures"| U5

    %% ViewModels invoke Networking Layer and receive data via Combine
    VM1 -->|"invokes"| NET
    VM2 -->|"invokes"| NET
    VM3 -->|"invokes"| NET
    NET -->|"publishes_data"| VM1
    NET -->|"publishes_data"| VM2
    NET -->|"publishes_data"| VM3

    %% Networking Layer uses Requests and Endpoints
    NET --> RQ1
    NET --> RQ2
    NET --> RQ3
    NET --> ENP

    %% Networking maps API responses to Domain Models
    NET -->|"maps_to"| DM

    %% Shared Extensions & Utilities are used by UI and Networking Layers
    EXT --- U1
    EXT --- U2
    EXT --- U3
    EXT --- U4
    EXT --- U5
    EXT --- NET

    %% Widget Module interactions
    WID -->|"reads"| DM
    WID -->|"uses"| EXT
    DI -->|"configures"| WID

    %% Styles
    classDef appCore fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef ui fill:#ADFF2F,stroke:#333,stroke-width:2px;
    classDef viewModel fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef network fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef domain fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef extension fill:#EEE8AA,stroke:#333,stroke-width:2px;
    classDef di fill:#AFEEEE,stroke:#333,stroke-width:2px;
    classDef widget fill:#98FB98,stroke:#333,stroke-width:2px;

    %% Click Events
    click AC1 "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/AppDelegate.swift"
    click AC2 "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/SceneDelegate.swift"
    click U1 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Characters"
    click VM1 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Characters"
    click U2 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Episodes"
    click VM2 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Episodes"
    click U3 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Locations"
    click VM3 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Locations"
    click U4 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Character Detail"
    click U5 "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Screens/Main App"
    click NET "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Core/Networking"
    click RQ1 "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/Core/Networking/Requests/CharactersRequest.swift"
    click RQ2 "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/Core/Networking/Requests/EpisodesRequest.swift"
    click RQ3 "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/Core/Networking/Requests/LocationsRequest.swift"
    click ENP "https://github.com/alperen23230/rick-and-morty-ios-app/blob/main/RickAndMortyiOS/RickAndMortyiOS/Core/Networking/Core/Endpoint.swift"
    click DM "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Core/Entity"
    click EXT "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyiOS/Core/Extensions"
    click WID "https://github.com/alperen23230/rick-and-morty-ios-app/tree/main/RickAndMortyiOS/RickAndMortyWidget"
```
