# aa12gq/yug-app architecture

> Architecture diagram of the GitHub repository aa12gq/yug-app, 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/aa12gq/yug-app
- Repository: https://github.com/aa12gq/yug-app

## Overview

##### Main Components
- Frontend/UI: The Flutter “pages” directory (with submodules such as ai, home, island, moments, msg, my, system, etc.) contains the screens and view logic. The “lib/common/components”, “widgets”, and “style” directories encapsulate reusable UI elements and design systems.
- Business Logic & Services: Modules in “lib/common/services”, “routers”, and “utils” provide business logic, navigation, and utility functions.
- Networking Layer: The “lib/common/net/grpcs” directory is central for gRPC communication. It holds the proto definitions (generated code), API service classes, and interceptors. This layer encapsulates calls to external backend services.
- Configuration & Global Settings: The “config” directory (with gRPC channel configurations) and “global.dart” indicate centralized configuration management.
- Multi-Platform Builders: The existence of platform-specific folders (android, ios, linux, macos, windows, web) underscores the project’s cross-platform nature. These folders contain platform-specific configurations, native code hooks, and resource definitions needed to run the app on various operating systems.

##### Relationships & Interactions
- The UI components (pages, widgets) interact with controllers and bindings (found within each page module) to handle user actions.
- The gRPC client communicates with external backend servers via the defined proto interfaces. This channel should be clearly depicted.
- Global configuration (from “config” and “global.dart”) and utility functions support multiple layers of the application.
- Routing components in “lib/common/routers” manage navigation flows between different UI screens.
- Platform-specific modules (android, ios, etc.) serve as bootstrapping layers to initialize the multi-platform Flutter runtime. Although these aren’t tightly coupled with the business logic, they provide the native integration layer.

##### Architectural Patterns and Design Principles
- The project clearly emphasizes modularization by separating UI, business logic, and network layers.
- An MVC/MVVM inspiration can be observed: UI pages (View), controllers (Controller/ViewModel) and services (Model/network/data).
- Clean separation of concerns: UI components, network communications, configurations and utilities are all isolated.
- Use of gRPC for network communications suggests a design geared toward high performance, scalable and strongly typed service interactions.

##### Technologies and Frameworks Highlight
- Flutter & Dart are the primary frameworks for the front-end and overall app structure.
- gRPC is employed for robust network communication, with protoc-generated Dart code based on the protobuf definitions.
- The build system and tooling include Makefile, pubspec.yaml, and platform-specific build configuration files.
- Additional elements such as internationalization (lib/common/i18n) and theming (lib/common/style and pages/my/theme) provide enhanced user experience.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Multi-Platform Launchers
    subgraph "Multi-Platform Launchers"
        MP1("Android"):::multi
        MP2("iOS"):::multi
        MP3("Linux"):::multi
        MP4("macOS"):::multi
        MP5("Windows"):::multi
        MP6("Web"):::multi
    end

    %% Client Layer (UI Module)
    subgraph "Client Layer (UI Module)"
        UI1("Pages & Views"):::ui
        UI2("Reusable UI Components"):::ui
        UI3("Widgets"):::ui
        UI4("Style & Theme"):::ui
    end

    %% Business Logic & Services
    subgraph "Business Logic & Services"
        BL1("Service Classes"):::business
        BL2("Navigation & Routing"):::business
        BL3("Utilities"):::business
    end

    %% Networking Layer
    subgraph "Networking Layer"
        NL1("gRPC Client"):::network
    end

    %% Configuration & Global Settings
    subgraph "Configuration & Global Settings"
        CG1("Config Files"):::config
        CG2("Global Initialization"):::config
    end

    %% External Backend
    External("External Backend"):::external

    %% Connections between layers
    MP1 -->|"bootstraps"| UI1

    UI1 -->|"composes"| UI2
    UI1 -->|"composes"| UI3
    UI1 -->|"styledBy"| UI4

    UI1 -->|"userAction"| BL1
    BL2 -->|"navigation"| UI1
    BL3 -->|"support"| BL1

    BL1 -->|"apiCall"| NL1
    NL1 -->|"gRPCCall"| External

    CG1 -->|"config"| BL1
    CG2 -->|"init"| UI1

    %% Click Events
    click UI1 "https://github.com/aa12gq/yug-app/tree/main/lib/pages"
    click UI2 "https://github.com/aa12gq/yug-app/tree/main/lib/common/components"
    click UI3 "https://github.com/aa12gq/yug-app/tree/main/lib/common/widgets"
    click UI4 "https://github.com/aa12gq/yug-app/tree/main/lib/common/style"
    
    click BL1 "https://github.com/aa12gq/yug-app/tree/main/lib/common/services"
    click BL2 "https://github.com/aa12gq/yug-app/tree/main/lib/common/routers"
    click BL3 "https://github.com/aa12gq/yug-app/tree/main/lib/common/utils"
    
    click NL1 "https://github.com/aa12gq/yug-app/tree/main/lib/common/net/grpcs"
    
    click CG1 "https://github.com/aa12gq/yug-app/tree/main/lib/config"
    click CG2 "https://github.com/aa12gq/yug-app/blob/main/lib/global.dart"
    
    click MP1 "https://github.com/aa12gq/yug-app/tree/main/android"
    click MP2 "https://github.com/aa12gq/yug-app/tree/main/ios"
    click MP3 "https://github.com/aa12gq/yug-app/tree/main/linux"
    click MP4 "https://github.com/aa12gq/yug-app/tree/main/macos"
    click MP5 "https://github.com/aa12gq/yug-app/tree/main/windows"
    click MP6 "https://github.com/aa12gq/yug-app/tree/main/web"

    %% Styles
    classDef ui fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef business fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef network fill:#f94144,stroke:#333,stroke-width:2px;
    classDef config fill:#577590,stroke:#fff,stroke-width:2px;
    classDef multi fill:#277da1,stroke:#fff,stroke-width:2px;
    classDef external fill:#bdbdbd,stroke:#333,stroke-dasharray: 5 5,stroke-width:2px;
```
