# gdsc-konkuk/24-25-proj-seoulmate-client architecture

> Architecture diagram of the GitHub repository gdsc-konkuk/24-25-proj-seoulmate-client, 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/gdsc-konkuk/24-25-proj-seoulmate-client
- Repository: https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client

## Overview

##### Main Components
- Application Layer: Represented by the “SeoulMate/ApplicationSM” directory. This is where iOS-specific resources reside – your AppDelegate, SceneDelegate, resources (storyboards, assets, Info.plist), etc.
- Presentation Layer: Found in “SeoulMate/PresentationSM”. This layer holds various view controllers for different features (e.g., Login, Map, AIChat, MyPage) and likely handles user interface and navigation.
- Domain Layer: Under “SeoulMate/DomainSM”, you have business logic elements such as RepositoryProtocols and use cases (e.g., LoginUseCase). This layer abstracts business rules and orchestrates application interactions.
- Data Layer: Located in “SeoulMate/DataSM”. It breaks down further into:
- Data Storage (DataStorageSM) with protocols and an implementation using Keychain for token storage.
- External Services (ExternalServicesSM), which currently includes a GoogleAuthService.
- Network (NetworkSM): Providing the network abstraction via service and utilities (HTTP methods, error handling).
- Repository Implementation (RepositorySM): Contains classes like AuthRepository that likely bridge Domain actions to the Data/services.

##### Relationships and Interactions
- The Application Layer initiates the UI load (via AppDelegate and SceneDelegate).
- The Presentation Layer (UI/Controllers) interacts with the Domain Layer to invoke use cases (for example, LoginUseCase when handling user login).
- The Domain Layer uses protocols defined in DomainSM (like the AuthRepositoryProtocol) to interact with the Data Layer.
- The Data Layer implements these protocols (e.g., AuthRepository) and manages interactions with lower-level services:
- It uses NetworkSM to communicate with the backend.
- It uses DataStorageSM for secure persistence (i.e., KeychainTokenStorage).
- It leverages ExternalServicesSM as needed for integrated functionalities such as Google authentication.

##### Architectural Patterns and Design Principles
- Layered (Clean) Architecture: Each layer (Presentation, Domain, Data) has clearly defined responsibilities. The Domain layer acts as the central point that the UI layer depends on, while the Data layer is used by the Domain for external interactions.
- Dependency Inversion: Interfaces or protocols such as those in DomainSM ensure that higher-level modules do not directly depend on lower-level details, but on abstractions.
- Separation of Concerns: UI components are separated from business logic and service integrations.

##### Relevant Technologies and Frameworks
- Swift and Xcode (with the Xcode project files and storyboards) for the iOS client.
- iOS-related frameworks for UI, resources, and application lifecycle management.
- External libraries or services (e.g., GoogleAuthService) which integrate third-party authentication.

##### Essential Elements to be Included
- Component labels: Each major block should have text labels (e.g., “Presentation – Login Module”, “Domain – LoginUseCase”, “Data – AuthRepository”).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Application Layer
    A["Application Layer"]:::app

    %% Presentation Layer Container
    P["Presentation Layer"]:::present

    %% Domain Layer Container
    D["Domain Layer"]:::domain

    %% Data Layer Container
    X["Data Layer"]:::data

    %% Subgraphs for Presentation Modules
    subgraph "Presentation Modules"
        LV["LoginViewController"]:::present
        MV["MapViewController"]:::present
        AC["AIChatViewController"]:::present
        MP["MyPageViewController"]:::present
        TB["TabBarController"]:::present
    end

    %% Subgraph for Domain Components
    subgraph "Domain Components"
        LU["LoginUseCase"]:::domain
        ARP["AuthRepositoryProtocol"]:::domain
    end

    %% Subgraph for Data Components
    subgraph "Data Components"
        subgraph "Data Storage"
            DS1["TokenStorageProtocol"]:::data
            DS2["KeychainTokenStorage"]:::data
        end
        subgraph "External Services"
            ES["GoogleAuthService"]:::data
        end
        subgraph "Network"
            NW1["NetworkService"]:::data
            NW2["NetworkServiceProtocol"]:::data
            NWU["HTTPMethod & NetworkError"]:::data
        end
        subgraph "Repository Implementation"
            AR["AuthRepository"]:::data
        end
    end

    %% Relationships between Layers
    A --> P
    P --> D
    D --> X

    %% Relationships within Presentation Layer
    P --> LV
    P --> MV
    P --> AC
    P --> MP
    P --> TB

    %% Communication Flow: Presentation to Domain
    LV -->|"calls"| LU

    %% Communication Flow: Domain to Domain/Data
    LU -->|"uses"| ARP
    ARP -->|"implementedBy"| AR

    %% Communication Flow: Data Component Interactions
    AR -->|"usesNW"| NW1
    AR -->|"storesToken"| DS2
    AR -->|"callsGoogleAuth"| ES
    NW1 -->|"utilizes"| NWU

    %% Click Events for Application Layer
    click A "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/tree/main/SeoulMate/ApplicationSM"

    %% Click Events for Presentation Layer and Modules
    click P "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/tree/main/SeoulMate/PresentationSM"
    click LV "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/PresentationSM/Login/LoginViewController.swift"
    click MV "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/PresentationSM/Map/MapViewController.swift"
    click AC "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/PresentationSM/AIChat/AIChatViewController.swift"
    click MP "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/PresentationSM/MyPage/MyPageViewController.swift"
    click TB "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/PresentationSM/Common/TabBarController.swift"

    %% Click Events for Domain Layer
    click D "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/tree/main/SeoulMate/DomainSM"
    click LU "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DomainSM/UseCase/LoginUseCase.swift"
    click ARP "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DomainSM/RepositoryProtocol/AuthRepositoryProtocol.swift"

    %% Click Events for Data Layer and its Components
    click X "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/tree/main/SeoulMate/DataSM"
    click DS1 "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/DataStorageSM/Protocols/TokenStorageProtocol.swift"
    click DS2 "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/DataStorageSM/TokenStorage/KeychainTokenStorage.swift"
    click ES "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/ExternalServicesSM/GoogleAuthService.swift"
    click NW1 "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/NetworkSM/NetworkService.swift"
    click NW2 "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/NetworkSM/Protocols/NetworkServiceProtocol.swift"
    click NWU "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/NetworkSM/Utils/HTTPMethod.swift"
    click AR "https://github.com/gdsc-konkuk/24-25-proj-seoulmate-client/blob/main/SeoulMate/DataSM/RepositorySM/AuthRepository.swift"

    %% Styling for Layers
    classDef app fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef present fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef domain fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef data fill:#ffa07a,stroke:#333,stroke-width:2px;
```
