# uber/ribs architecture

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

- Interactive diagram: https://gitdiagram.com/uber/ribs
- Repository: https://github.com/uber/ribs

## Overview

Based on our analysis of the file tree and the README, this repository is the home of the RIBs framework – a cross‐platform mobile architecture framework primarily used for building scalable mobile apps. RIBs (Router, Interactor, Builder) encapsulate a paradigm where business logic is decoupled from the view (and even can exist without it) and where DI and reactive streams (Rx) govern interactions. The repository is organized into multiple modules (libraries), demos, tooling, and tutorials that support both Android (including Jetpack Compose support) and iOS (via a separate repository).

##### Main Components
- Core Framework Libraries: These include modules like
– rib-base (defining core abstractions: Interactor, Router, Builder, Presenter, etc.)
– rib-android-core and rib-android (providing Android-specific implementations and lifecycle hooks)
– rib-android-compose (extending support to Jetpack Compose)
– rib-coroutines and rib-router-navigator (offering additional patterns for coroutines and advanced routing)
- Compiler & Code Generation Components:
– rib-compiler-app, rib-compiler-test, and rib-coroutines-test are all responsible for compile-time checks, code generation, and testing support (e.g. verifying annotations and generating boilerplate)
- Demos & Tutorials:
– Multiple demos (compose, flipper, intellij, memory-leaks, rib-workers) show end-to-end implementations in different setups.
– Tutorials are provided as separate projects outlining how to implement RIBs-based apps.
- Tooling and IDE Integration:
– Tools such as the rib-flipper-plugin, rib-intellij-plugin, and accompanying native and utility modules provide developer productivity enhancements (code generation, static analysis, memory leak detection, etc.).
- Configurations & Conventions:
– Several directories (config, conventions, gradle, etc.) indicate standard practices and settings which underpin the build, lint, and formatting rules.

##### Component Relationships and Interactions
- A “Tooling & IDE Integration” module. This component (which contains rib-flipper-plugin, rib-intellij-plugin, and related utilities) connects to both the core libraries and demos, illustrating that tooling assists in development (e.g., code generation, runtime analysis).

##### Architectural Patterns and Design Principles
- Use of reactive streams (or Rx) where applicable—for example, between the interactor and view, or while handling events across components.

##### Elements
– Another for platform-specific or demo applications (e.g., green)
– A third for tooling and build configuration (e.g., grey or orange)

##### Detailed and Accurate Capture
- That every module present in the repository is either grouped into one of the above sections or at least mentioned as part of the overall ecosystem.
- Avoid oversimplification: include as many components as possible since the architecture is meant to scale for large teams. It’s better to separate the system into the maximum number of components (i.e., core, demos, tooling, configurations) to fully represent the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Framework Libraries Subgraph
    subgraph "Core Framework Libraries"
        ParentRIB["Parent RIB"]:::core
        CB["rib-base (Core)"]:::core
        ChildRIB["Child RIB Builder"]:::core
        ACore["rib-android-core"]:::core
        A["rib-android"]:::core
        ACmp["rib-android-compose"]:::core
        Cor["rib-coroutines"]:::core
        RN["rib-router-navigator"]:::core
    end

    %% Compiler & Code Generation Subgraph
    subgraph "Compiler & Code Generation"
        RCApp["rib-compiler-app"]:::compiler
        RCTest["rib-compiler-test"]:::compiler
        RCTest2["rib-coroutines-test"]:::compiler
    end

    %% Tooling & IDE Integration Subgraph
    subgraph "Tooling & IDE Integration"
        Flipper["rib-flipper-plugin"]:::tooling
        Intellij["rib-intellij-plugin"]:::tooling
        Utils["Additional Utilities"]:::tooling
    end

    %% Demos & Tutorials Subgraph
    subgraph "Demos & Tutorials"
        Demos["Demos"]:::demo
        Tutorials["Tutorial Projects"]:::demo
    end

    %% Build & Configuration Node
    BuildConfig["Build & Configuration"]:::config

    %% DI Flow within Core
    ParentRIB -->|"DIFlow"| ChildRIB

    %% Relationships within Core Framework Libraries
    CB -->|"providesInterfaces"| ACore
    CB -->|"providesInterfaces"| ACmp
    CB -->|"integratesWith"| Cor
    CB -->|"enablesRouting"| RN
    ACore -->|"extends"| A

    %% Compiler & Code Generation -> Core
    RCApp -->|"generatesCodeFor"| CB
    RCTest -->|"verifiesAnnotations"| CB
    RCTest2 -->|"testsCoroutines"| Cor

    %% Tooling & IDE Integration -> Core & Demos
    Flipper -->|"integratesWith"| CB
    Intellij -->|"integratesWith"| CB
    Flipper ---|"assistsDevelopment"| Demos
    Intellij ---|"assistsDevelopment"| Demos
    Utils -->|"providesUtilitiesFor"| Intellij

    %% Demos & Tutorials -> Core
    Demos -->|"usesInterfaces"| CB
    Tutorials -->|"guidesUsageOf"| CB

    %% Build & Configuration applies to all modules
    BuildConfig -->|"enforcesSettings"| CB
    BuildConfig -->|"enforcesSettings"| ACore
    BuildConfig -->|"enforcesSettings"| ACmp
    BuildConfig -->|"enforcesSettings"| Cor
    BuildConfig -->|"enforcesSettings"| RN
    BuildConfig -->|"enforcesSettings"| RCApp
    BuildConfig -->|"enforcesSettings"| Demos
    BuildConfig -->|"enforcesSettings"| Tutorials
    BuildConfig -->|"enforcesSettings"| Flipper
    BuildConfig -->|"enforcesSettings"| Intellij

    %% Click Events for Core Framework Libraries
    click CB "https://github.com/uber/ribs/tree/main/libraries/rib-base"
    click ACore "https://github.com/uber/ribs/tree/main/libraries/rib-android-core"
    click A "https://github.com/uber/ribs/tree/main/libraries/rib-android"
    click ACmp "https://github.com/uber/ribs/tree/main/libraries/rib-android-compose"
    click Cor "https://github.com/uber/ribs/tree/main/libraries/rib-coroutines"
    click RN "https://github.com/uber/ribs/tree/main/libraries/rib-router-navigator"

    %% Click Events for Compiler & Code Generation
    click RCApp "https://github.com/uber/ribs/tree/main/libraries/rib-compiler-app"
    click RCTest "https://github.com/uber/ribs/tree/main/libraries/rib-compiler-test"
    click RCTest2 "https://github.com/uber/ribs/tree/main/libraries/rib-coroutines-test"

    %% Click Events for Demos & Tutorials
    click Demos "https://github.com/uber/ribs/tree/main/demos"
    click Tutorials "https://github.com/uber/ribs/tree/main/tutorials"

    %% Click Events for Tooling & IDE Integration
    click Flipper "https://github.com/uber/ribs/tree/main/tooling/rib-flipper-plugin"
    click Intellij "https://github.com/uber/ribs/tree/main/tooling/rib-intellij-plugin"
    click Utils "https://github.com/uber/ribs/tree/main/tooling/utils/intellij-broadcast-core"

    %% Click Event for Build & Configuration
    click BuildConfig "https://github.com/uber/ribs/tree/main/config"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef compiler fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef tooling fill:#FFD700,stroke:#FF8C00,stroke-width:2px;
    classDef demo fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef config fill:#FFA07A,stroke:#CD5C5C,stroke-width:2px;
```
