# team-toyou/toyou-android architecture

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

- Interactive diagram: https://gitdiagram.com/team-toyou/toyou-android
- Repository: https://github.com/team-toyou/toyou-android

## Overview

##### Main Components
- User Interface/Presentation Layer:
- This layer includes all your Activity/Fragment files, ViewModels, and related UI resources. Notice the “presentation” folder (subfolders for fragments, viewmodels, and base) that houses all UI logic.
- Domain Layer:
- This layer encapsulates your business logic and repository interfaces. It’s located in the “domain” package (with subpackages for create, home, notice, record, social) to abstract data operations.
- Data Layer:
- Found in the “data” package, with submodules (create, emotion, home, mypage, notice, onboarding, record, and social) also containing DTOs, entities, and service classes.
- Network Module:
- The “network” package holds Retrofit configuration, API modules, custom responses and modules to facilitate communication with external APIs (e.g., Kakao Open API, Firebase).
- FCM Module:
- Contains FCM message handling logic (service, domain, dto) for push notifications.
- Models & Utilities:
- “model” holds various data models (including calendar and local data) and “utils” contains helper classes, token management, calendar utilities, or custom binding adapters.
- Android Resources and Configuration:
- The “res” folder resources along with Gradle build scripts are essential for UI theming, graphics, and project configuration.

##### Relationships and Interactions
- The presentation layer interacts with the domain layer via ViewModels to retrieve or send user data.
- The domain layer interfaces with the data layer, which handles network and local database operations (Room is used, as hinted by the presence of UserDatabase/UserDao and Room libraries).
- The network module provides the bridge to external services (Retrofit/OkHttp integration, third-party APIs like Kakao or Firebase) and supplies data to the data layer.
- The FCM submodule listens for incoming push notifications and interacts with the domain and network layers as needed.
- Utility classes are consumed anywhere in the code to support common functions (e.g., calendar handling, token storage).

##### Architectural Patterns and Design Principles
- MVVM: Indicated by a clear separation of UI (Fragments, Activities, ViewModels) and domain/data logic.
- Clean Architecture: A separation of concerns is presented between domain, data, and presentation layers.
- Repository Pattern: Present in “domain” where repositories provide an abstraction between data sources and business logic.
- Single-Activity Architecture with multiple Fragments: Based on the navigation component implementation and fragment usage.
- Dependency Injection (implied): Although not specified here in a DI framework, there’s a structure that allows for DI (e.g., separate modules for network, repositories, viewmodel factories).

##### Final Elements

– The Presentation Layer (activities, fragments, viewmodels) drives the UI.
– The Domain Layer insulates business logic and abstracts repository patterns.
– The Data Layer interacts with both local persistence (Room) and remote services (Retrofit, external APIs).
– There’s a dedicated FCM module for handling notifications.
– Utility classes and models support all layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        P1["MainActivity"] 
        P2["Fragments (Onboarding,Home,Mypage,Notice,Record,Social,Tutorial)"]
        P3["ViewModels"]
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D1["Repository Interfaces (Create,Home,Notice,Record,Social)"]
        D2["Business Logic"]
    end

    %% Data Layer
    subgraph "Data Layer"
        DT1["Data Services (DTOs,Entities)"]
        DT2["Room Database"]
    end

    %% Network Module
    subgraph "Network Module"
        N1["Retrofit Instance"]
        N2["AuthNetworkModule"]
        N3["External APIs (Kakao,Firebase)"]
    end

    %% FCM Module
    subgraph "FCM Module"
        F1["MyFirebaseMessagingService"]
    end

    %% Models & Utilities
    subgraph "Models & Utilities"
        M1["Data Models"]
        U1["Utility Classes"]
    end

    %% Android Resources & Config
    subgraph "Android Resources & Config"
        R1["Resources & Gradle Config"]
    end

    %% Connections between layers
    P3 -->|"RepositoryCall"| D1
    D1 -->|"DataRequest"| DT1
    D1 -->|"DBQuery"| DT2
    DT1 -->|"APIRequest"| N1
    N1 -->|"APIResponse"| DT1
    N2 -->|"AuthSupport"| DT1
    F1 -->|"PushUpdates"| D2
    F1 -->|"MessageUpdate"| N2

    %% Connections to Models & Utilities and Resources
    P1 -->|"Uses"| U1
    D1 -->|"Uses"| U1
    DT1 -->|"Uses"| U1
    P2 -->|"UsesResources"| R1

    %% Class Definitions for color coding
    classDef presentation fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef domain fill:#A9DFBF,stroke:#000,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef network fill:#D2B4DE,stroke:#000,stroke-width:2px;
    classDef fcm fill:#D7BDE2,stroke:#000,stroke-width:2px;
    classDef utils fill:#F5B7B1,stroke:#000,stroke-width:2px;
    classDef resources fill:#D5D8DC,stroke:#000,stroke-width:2px;

    %% Assign classes to nodes
    class P1,P2,P3 presentation;
    class D1,D2 domain;
    class DT1,DT2 data;
    class N1,N2,N3 network;
    class F1 fcm;
    class M1,U1 utils;
    class R1 resources;

    %% Click Events for component mappings
    click P1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/presentation"
    click D1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/domain"
    click DT1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/data"
    click N1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/network"
    click F1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/fcm"
    click M1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/model"
    click U1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/java/com/toyou/toyouandroid/utils"
    click R1 "https://github.com/team-toyou/toyou-android/tree/master/app/src/main/res"
```
