# mobilenativefoundation/store architecture

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

- Interactive diagram: https://gitdiagram.com/mobilenativefoundation/store
- Repository: https://github.com/mobilenativefoundation/store

## Overview

##### Main Components

a) Core Components (Primary Layer):
- Store Module (Central Component)
- Cache Module
- Multicast Module
- Paging Module
- RX2 Module

b) Key Architectural Elements:
- Fetcher (Data Source)
- SourceOfTruth (Persistence Layer)
- Bookkeeper (State Management)
- Store Builder
- Memory Policy Handler

**┌─────────────────────── Client Applications ───────────────────────┐**

- Store5 Core ─────────────────────────┐  │

- ┌─────────────┐    ┌──────────────┐    ┌────────────────┐   │  │
- Fetcher   │──▶│    Store     │◀──▶│ SourceOfTruth  │   │  │
- ┘    └──────────────┘    └────────────────┘   │  │
- ▲                                    │  │

- ┌─────────────┐    ┌──────────────┐    ┌────────────────┐   │  │
- Bookkeeper  │◀──▶│MemoryPolicy  │    │   Validator    │   │  │
- ┘    └──────────────┘    └────────────────┘   │  │

- ┘  │

- Support Modules ────────────────────────┐  │

- ┌─────────────┐    ┌──────────────┐    ┌────────────────┐    │  │
- Cache    │    │   Multicast  │    │     Paging     │    │  │
- ┘    └──────────────┘    └────────────────┘    │  │

- ┌─────────────┐                                              │  │
- RX2     │                                              │  │
- ┘                                              │  │

- ┘  │

- ┘

##### Data Flow Indicators
- Data fetch flow from Fetcher to Store
- Persistence flow between Store and SourceOfTruth
- State management flow with Bookkeeper
- Cache interactions
- Multicast broadcasting paths

##### Important Implementation Details to Highlight

a) Core Functionality:
- CRUD operations support
- Multiplatform nature (Android/JVM)
- Caching mechanism
- Reactive streams support

b) Integration Points:
- How clients integrate with the Store
- Extension points for custom implementations
- Optional module integration paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef support fill:#e8f5e9,stroke:#1b5e20
    classDef client fill:#fff3e0,stroke:#e65100
    classDef optional fill:#f5f5f5,stroke:#424242

    %% Client Layer
    subgraph ClientApps["Client Applications"]
        Client1["Android Apps"]
        Client2["JVM Apps"]
    end

    %% Core Layer
    subgraph CoreLayer["Store5 Core"]
        Store["Store"]:::core
        Fetcher["Fetcher"]:::core
        SourceOfTruth["SourceOfTruth"]:::core
        Bookkeeper["Bookkeeper"]:::core
        MemoryPolicy["Memory Policy"]:::core
        StoreBuilder["Store Builder"]:::core
        Validator["Validator"]:::core

        %% Core Component Relationships
        Fetcher --> Store
        Store <--> SourceOfTruth
        Store <--> Bookkeeper
        Bookkeeper <--> MemoryPolicy
        StoreBuilder --> Store
        Validator --> Store
    end

    %% Support Modules Layer
    subgraph SupportModules["Support Modules"]
        Cache["Cache Module"]:::support
        Multicast["Multicast Module"]:::support
        Paging["Paging Module"]:::support
        RX2["RX2 Module"]:::support

        %% Support Module Relationships
        Cache --> Store
        Multicast --> Store
        Paging --> Store
        RX2 --> Store
    end

    %% Cross-Layer Relationships
    Client1 & Client2 --> Store

    %% Click Events
    click Store "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/Store.kt"
    click Cache "https://github.com/MobileNativeFoundation/Store/blob/main/cache/src/commonMain/kotlin/org/mobilenativefoundation/store/cache5/Cache.kt"
    click Multicast "https://github.com/MobileNativeFoundation/Store/blob/main/multicast/src/commonMain/kotlin/org/mobilenativefoundation/store/multicast5/Multicaster.kt"
    click Paging "https://github.com/MobileNativeFoundation/Store/blob/main/paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStore.kt"
    click RX2 "https://github.com/MobileNativeFoundation/Store/blob/main/rx2/src/main/kotlin/org/mobilenativefoundation/store/rx2/RxStore.kt"
    click Fetcher "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/Fetcher.kt"
    click SourceOfTruth "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/SourceOfTruth.kt"
    click Bookkeeper "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/Bookkeeper.kt"
    click StoreBuilder "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreBuilder.kt"
    click MemoryPolicy "https://github.com/MobileNativeFoundation/Store/blob/main/store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/MemoryPolicy.kt"

    %% Legend
    subgraph Legend
        CoreComponent["Core Component"]:::core
        SupportComponent["Support Module"]:::support
        ClientComponent["Client Component"]:::client
        OptionalComponent["Optional Component"]:::optional
    end
```
