# bidrohi/seahorse architecture

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

- Interactive diagram: https://gitdiagram.com/bidrohi/seahorse
- Repository: https://github.com/bidrohi/seahorse

## Overview

##### Main Components

a. Core Components:
- Seahorse Core Engine
- String Resource Providers
- FallbackSource (Platform-specific implementations)
- LocalStore (Different storage implementations)
- NetworkSource (Remote fetching implementations)

b. Platform-Specific Implementations:
- Android Implementation
- iOS Implementation
- JVM Implementation
- Linux Implementation
- Windows Implementation
- macOS/tvOS/watchOS Implementations

**┌─ Application Layer ─────────────────────────────────────┐**
- Android Apps   iOS Apps   Desktop Apps   Command Line  │
- ┬──────────────────────────────┘

**┌─ Seahorse Core ──────────┼──────────────────────────────┐**
- ▼                              │
- ┌─ String Resource Manager ─┐                         │
- (Seahorse.kt)        │                         │
- ┬───────────┘                         │

- ┌───────────▼─────────────┐                        │
- StringsRepository     │                        │
- ┬─────────────┘                        │

- ┌──────────▼───────────┐                          │
- Source Providers   │                          │
- ┘                          │
- ┘

**┌─ Implementation Layer ───────────────────────────────────┐**

- ┌─ Storage ─┐   ┌─ Network ─┐   ┌─ Platform ─┐        │
- SQLite    │   │ Ktor      │   │ Android    │        │
- Realm     │   │ OkHttp    │   │ iOS        │        │
- Memory    │   └──────────┘   │ Desktop    │        │
- ┘                  └──────────┘           │
- ┘

##### Component Relationships

- Data flow between components
- Dependencies between modules
- Platform-specific implementations
- Extension points

##### Important Details

a. Core Interfaces:
- FallbackSource
- LocalStore
- NetworkSource

b. Implementation Options:
**Storage:**
- SQLite
- Realm
- In-Memory

**Network:**
- Ktor
- OkHttp

**Platform:**
- ResourceFallbackSource (Android)
- NSLocalizedFallbackSource (iOS)
- Various platform-specific implementations

##### Additional Elements

- Version compatibility information
- Supported platforms with their respective badges
- Optional vs. required components

##### Key Flows to Highlight

**1. String Request Flow:**
- App → Seahorse Core → Local Store → Network Source → Fallback

**2. Cache Update Flow:**
- Network Source → Local Store → Memory Cache

**3. Platform Integration Flow:**
- Platform-Specific Implementation → Core Interface

##### Implementation Notes

- Module names from build.gradle.kts
- Version compatibility requirements

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Apps
        AndroidApp["Android Apps"]
        iOSApp["iOS Apps"]
        DesktopApp["Desktop Apps"]
        CLIApp["Command Line"]
    end

    subgraph Core
        Seahorse["Seahorse Core Engine"]:::core
        Config["SeahorseConfig"]:::core
        StringsRepo["StringsRepository"]:::core
        
        subgraph SourceProviders
            FallbackSource["FallbackSource"]:::provider
            LocalStore["LocalStore"]:::provider
            NetworkSource["NetworkSource"]:::provider
        end
    end

    subgraph PlatformImpl
        AndroidImpl["ResourceFallbackSource"]:::platform
        iOSImpl["NSLocalizedFallbackSource"]:::platform
        LinuxImpl["Linux Implementation"]:::platform
        WindowsImpl["Windows Implementation"]:::platform
    end

    subgraph Storage
        SQLite["SQLite Store"]:::storage
        Realm["Realm Store"]:::storage
        MapStore["Map Store"]:::storage
    end

    subgraph Network
        Ktor["Ktor Client"]:::network
        OkHttp["OkHttp Client"]:::network
    end

    %% Apps to Core
    AndroidApp --> Seahorse
    iOSApp --> Seahorse
    DesktopApp --> Seahorse
    CLIApp --> Seahorse

    %% Core Components
    Seahorse --> Config
    Seahorse --> StringsRepo
    StringsRepo --> FallbackSource
    StringsRepo --> LocalStore
    StringsRepo --> NetworkSource

    %% Platform Implementations
    FallbackSource --> AndroidImpl
    FallbackSource --> iOSImpl
    FallbackSource --> LinuxImpl
    FallbackSource --> WindowsImpl

    %% Storage Implementations
    LocalStore --> SQLite
    LocalStore --> Realm
    LocalStore --> MapStore

    %% Network Implementations
    NetworkSource --> Ktor
    NetworkSource --> OkHttp

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef provider fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef platform fill:#4CAF50,stroke:#388E3C,color:white
    classDef storage fill:#FF9800,stroke:#F57C00,color:white
    classDef network fill:#F44336,stroke:#D32F2F,color:white

    %% Click Events
    click Seahorse "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/Seahorse.kt"
    click Config "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/SeahorseConfig.kt"
    click StringsRepo "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/StringsRepository.kt"
    click FallbackSource "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/FallbackSource.kt"
    click LocalStore "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/LocalStore.kt"
    click NetworkSource "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/NetworkSource.kt"
    click AndroidImpl "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/androidMain/kotlin/com/bidyut/tech/seahorse/data/ResourceFallbackSource.kt"
    click iOSImpl "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/appleMain/kotlin/com/bidyut/tech/seahorse/data/NSLocalizedFallbackSource.kt"
    click LinuxImpl "https://github.com/bidrohi/seahorse/tree/main/seahorse/core/src/linuxMain/kotlin/com/bidyut/tech/seahorse/utils/"
    click WindowsImpl "https://github.com/bidrohi/seahorse/tree/main/seahorse/core/src/mingwMain/kotlin/com/bidyut/tech/seahorse/utils/"
    click SQLite "https://github.com/bidrohi/seahorse/blob/main/seahorse/sqlite/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/SqliteLocalStore.kt"
    click Realm "https://github.com/bidrohi/seahorse/blob/main/seahorse/realm/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/RealmLocalStore.kt"
    click MapStore "https://github.com/bidrohi/seahorse/blob/main/seahorse/core/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/MapLocalStore.kt"
    click Ktor "https://github.com/bidrohi/seahorse/blob/main/seahorse/ktor/src/commonMain/kotlin/com/bidyut/tech/seahorse/data/KtorNetworkSource.kt"
    click OkHttp "https://github.com/bidrohi/seahorse/blob/main/seahorse/okhttp/src/androidMain/kotlin/com/bidyut/tech/seahorse/data/OkHttpNetworkSource.kt"
```
