# alexisl61/rpc_express architecture

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

- Interactive diagram: https://gitdiagram.com/alexisl61/rpc_express
- Repository: https://github.com/alexisl61/rpc_express

## Overview

##### Project Type & Purpose
- This is an open‐source, cross-platform client application built with Flutter. Its main function is to allow users to manually select in-game activities (for games like Sea of Thieves, Helldivers 2, and The Finals) so that rich presence information is displayed on their Discord profiles.
- The README emphasizes that it does not auto-detect game activities; instead, users choose activities and groups via the app’s UI, which then communicates with Discord.

##### Main Components
a. User Interface (Frontend):
– Represent the Flutter UI layer that spans multiple platforms (Android, iOS, web, macOS, Windows, Linux).
– Highlight the separation into sub-modules/pages for each game:
- Helldivers UI (e.g., activity selection, difficulty, planet selection)
- Sea of Thieves UI (e.g., activity, ship selection, company logos)
- The Finals UI (e.g., gamemode and group selection)
– Include common UI components (atoms, molecules, organisms) as part of the MVVM architecture; these are visible in directories (lib/components).

b. Business Logic & MVVM Structure:
– Show the MVVM (Model-View-ViewModel) pattern used throughout the project.
– Identify key modules:
- ViewModels – pages/view models for home screens, activity selections, etc.
- Models – classes for game activities, translations, user data, and groups.
- View Events & Event Observers – modules to handle navigation and dialogs based on user interactions.

c. Data Access Layer:
– Repositories: Represent the API repository classes which abstract the data fetching logic.
– API Services: Components for handling remote or local API data (refer to files under lib/services and api/v1) that supply updated activity lists and translations.
– Transformers: Show the existence of transformation classes converting raw data from JSON into the application’s model classes.

d. Assets & External Resources:
– Represent the static assets (images, fonts, SVGs) that provide the visual content for different game UIs present under the assets directory.
– API JSON files: Note that there are local JSON files for activities and translations inside the “api” directory, which serve as sources for in-app data.
– Discord Integration: Include a component that represents the Discord Rich Presence update functionality, which uses an external Discord RPC integration service.

e. Platform-Specific Native Code:
– For each supported platform, show a node representing the native integration. The “rpc_express” directory contains Android, iOS, macOS, Windows, Linux, and web folders. These components handle platform-specific configuration and integration (such as launching the Flutter engine and handling native plugins).

##### Relationships & Data Flows
– From the user interacting with the UI (View) to the corresponding ViewModel.
– From ViewModels to Services and Repositories that fetch or cache data (activities, translations).
– Show transformers processing API JSON data before feeding it into Models.
– Connect the processed data to UI components for rendering.
– Illustrate the pathway from user actions leading to API Service calls that update Discord’s status through the Discord integration.
- That configuration and build scripts (such as GitHub workflows and platform-specific build files) support continuous integration/deployment.

##### Architectural Patterns & Key Technologies
- MVVM Pattern: Emphasize separation via model, view-model, and view.
- Flutter: Central technology behind the cross-platform user interface.
- JSON-based API Data: Local JSON files (under api/v1) for activities & translations.
- Repository Pattern: Abstracts the data access and retrieval via API services.
- Integration with Discord RPC: External service for updating rich presence.
- Usage of version control and CI/CD via GitHub workflows.

- A block for “User Interface” (with subcomponents for each game and common UI elements).
- A block for “ViewModels & Business Logic” (representing the MVVM layer).
- A block for “Repositories & Services” (including API service calls, Discord service, and transformation layers).
- A block for “Data Sources” (representing local JSON files found under api/v1 and assets directories).
- A block for “Platform-Specific Wrapper/Native Layer” (covering Android, iOS, web, etc.).
- Notes on how GitHub workflows and configuration files support automated builds and releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User Interaction"]:::extern

    %% User Interface Layer
    subgraph "User Interface (Flutter UI)"
        UI1["Common UI Components"]:::ui
        UI2["Helldivers UI Components"]:::ui
        UI3["Sea of Thieves UI Components"]:::ui
        UI4["The Finals UI Components"]:::ui
    end

    %% Business Logic & MVVM Layer
    subgraph "Business Logic & MVVM"
        MVVM_Core["MVVM Core Components & ViewModels"]:::mvvm
        MVVM_H["Helldivers Page/ViewModel"]:::mvvm
        MVVM_ST["Sea of Thieves Page/ViewModel"]:::mvvm
        MVVM_TF["The Finals Page/ViewModel"]:::mvvm
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        REPO["API Repository"]:::service
        API1["Common API Service"]:::service
        API2["Helldivers API Service"]:::service
        TRANS["Data Transformers"]:::service
    end

    %% Assets & External Resources Layer
    subgraph "Assets & External Resources"
        AS_H["Helldivers Assets"]:::asset
        AS_ST["Sea of Thieves Assets"]:::asset
        AS_TF["The Finals Assets"]:::asset
        JSON["API JSON Files"]:::asset
        DS["Discord Service"]:::extern
        DUI["Discord UI Container"]:::extern
    end

    %% Platform-Specific Native Code Layer
    subgraph "Platform-Specific Native Layer"
        AND["Android Platform"]:::native
        IOS["iOS Platform"]:::native
        LNX["Linux Platform"]:::native
        MAC["macOS Platform"]:::native
        WIN["Windows Platform"]:::native
        WEB["Web Platform"]:::native
    end

    %% Data Flow Connections
    U -->|"triggers"| UI1
    U -->|"triggers"| UI2
    U -->|"triggers"| UI3
    U -->|"triggers"| UI4

    UI1 -->|"updates via MVVM"| MVVM_Core
    UI2 -->|"updates via MVVM"| MVVM_Core
    UI3 -->|"updates via MVVM"| MVVM_Core
    UI4 -->|"updates via MVVM"| MVVM_Core

    MVVM_Core -->|"communicates with"| REPO
    MVVM_Core -->|"communicates with"| API1
    MVVM_Core -->|"communicates with"| API2
    MVVM_H -->|"handles logic"| REPO
    MVVM_ST -->|"handles logic"| API1
    MVVM_TF -->|"handles logic"| API2

    REPO -->|"fetches data"| TRANS
    API1 -->|"fetches data"| TRANS
    API2 -->|"fetches data"| TRANS

    TRANS -->|"supplies data"| UI1
    TRANS -->|"supplies data"| UI2
    TRANS -->|"supplies data"| UI3
    TRANS -->|"supplies data"| UI4

    TRANS -->|"triggers updates to"| DS
    DS -->|"updates presence"| DUI

    JSON -->|"serves as data source"| TRANS

    %% Linking Platform-Specific Layer to UI
    UI1 ---|"runs on"| AND
    UI1 ---|"runs on"| IOS
    UI1 ---|"runs on"| LNX
    UI1 ---|"runs on"| MAC
    UI1 ---|"runs on"| WIN
    UI1 ---|"runs on"| WEB

    %% Click Events for User Interface
    click UI1 "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/components/common"
    click UI2 "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/components/helldivers"
    click UI3 "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/components/sea_of_thieves"
    click UI4 "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/components/the_finals"

    %% Click Events for Business Logic & MVVM
    click MVVM_Core "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/model/mvvm"
    click MVVM_H "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/pages/helldivers"
    click MVVM_ST "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/pages/sea_of_thieves"
    click MVVM_TF "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/pages/the_finals"

    %% Click Events for Data Access Layer
    click REPO "https://github.com/alexisl61/rpc_express/blob/dev/rpc_express/lib/repositories/api/api_repository.dart"
    click API1 "https://github.com/alexisl61/rpc_express/blob/dev/rpc_express/lib/services/common/api_service.dart"
    click API2 "https://github.com/alexisl61/rpc_express/blob/dev/rpc_express/lib/services/helldivers/helldivers_api_service.dart"
    click TRANS "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/lib/transformers"

    %% Click Events for Assets & External Resources
    click AS_H "https://github.com/alexisl61/rpc_express/tree/dev/assets/helldivers"
    click AS_ST "https://github.com/alexisl61/rpc_express/tree/dev/assets/sea_of_thieves"
    click AS_TF "https://github.com/alexisl61/rpc_express/tree/dev/assets/the_finals"
    click JSON "https://github.com/alexisl61/rpc_express/tree/dev/api/v1"
    click DS "https://github.com/alexisl61/rpc_express/blob/dev/rpc_express/lib/services/common/discord_service.dart"
    click DUI "https://github.com/alexisl61/rpc_express/blob/dev/rpc_express/lib/components/common/organisms/discord_container.dart"

    %% Click Events for Platform-Specific Native Code
    click AND "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/android"
    click IOS "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/ios"
    click LNX "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/linux"
    click MAC "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/macos"
    click WIN "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/windows"
    click WEB "https://github.com/alexisl61/rpc_express/tree/dev/rpc_express/web"

    %% Styling Classes
    classDef ui fill:#FAD7A0,stroke:#D68910,stroke-width:2px;
    classDef mvvm fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef service fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef asset fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef native fill:#D2B4DE,stroke:#884EA0,stroke-width:2px;
    classDef extern fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
