# bidrohi/rewalled architecture

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

## Overview

##### Main Architecture Components

The system should be represented as a Clean Architecture with the following key components:

a. Presentation Layer (UI)
- Compose UI components (shared/library/src/commonMain/.../ui)
- Platform-specific implementations (Android, iOS, Desktop)
- ViewModels (e.g., SubRedditViewModel)

b. Domain Layer
- Models (shared/model)
- Use Cases (implicit from the structure)

c. Data Layer
- Repository (SubredditFeedRepository)
- Cache (SQLDelight database)
- Network (Reddit Service)

**┌─ Presentation Layer ─────────────────────┐**
- ┌─ Platform UI ──┐  ┌─ Shared UI ─────┐ │
- Android        │  │ Common Compose   │ │
- iOS           │←─│ Components       │ │
- Desktop       │  │ ViewModels       │ │
- ┘  └─────────────────┘ │
- ┬─────────────┘
- ↓
**┌─ Domain Layer ────────────────────────────┐**
- ┌─ Models ────────┐  ┌─ Use Cases ─────┐ │
- Feed           │  │ Wallpaper        │ │
- SubReddit      │←─│ Management      │ │
- Wallpaper      │  │                 │ │
- ┘  └─────────────────┘ │
- ┬─────────────┘
- ↓
**┌─ Data Layer ─────────────────────────────┐**
- ┌─ Repository ─┐ ┌─ Local ─┐ ┌─ Remote ┐│
- Subreddit   │ │ SQLite  │ │ Reddit  ││
- Feed        │→│ Cache   │ │ API     ││
- Repository  │ │         │ │ Service ││
- ┘ └─────────┘ └─────────┘│
- ┘

##### Important Architectural Details to Highlight

a. Multiplatform Support:
- Shared code modules
- Platform-specific implementations
- Common business logic

b. Data Flow:
- Reddit API integration
- Local caching mechanism
- Repository pattern implementation

c. Dependency Injection:
- AppGraph implementations for different platforms
- Platform-specific factories

##### Notes for Implementation Details

Annotations for:
- Kotlin Multiplatform specific features
- SQLDelight database implementation
- Compose Multiplatform UI
- Platform-specific considerations

Remember to emphasize the shared code modules and how they interact with platform-specific implementations, as this is a key aspect of the Kotlin Multiplatform project structure.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef platform fill:#a8d1f0,stroke:#333
    classDef shared fill:#90EE90,stroke:#333
    classDef data fill:#FFE5B4,stroke:#333
    classDef external fill:#FFB6C1,stroke:#333
    classDef cache fill:#DDA0DD,stroke:#333

    %% Platform UI Layer
    subgraph PlatformUI["Platform-Specific UI Layer"]
        Android["Android UI"]:::platform
        iOS["iOS UI"]:::platform
        Desktop["Desktop UI"]:::platform
    end

    %% Shared Library Layer
    subgraph SharedLib["Shared Library Layer"]
        UIComponents["Shared UI Components"]:::shared
        ViewModels["View Models"]:::shared
        Screens["Screen Definitions"]:::shared
        Theme["Theme Management"]:::shared
        PlatformCoord["Platform Coordinators"]:::shared
        DI["Dependency Injection"]:::shared
    end

    %% Core Components
    subgraph Core["Core Components"]
        Network["Network Module"]:::shared
        Models["Model Layer"]:::shared
        RedditService["Reddit Service"]:::shared
    end

    %% Data Layer
    subgraph DataManagement["Data Management"]
        DataLayer["Data Repositories"]:::data
        CacheLayer["Cache Layer"]:::cache
    end

    %% External Services
    Reddit["Reddit API"]:::external

    %% Relationships
    Android & iOS & Desktop --> UIComponents
    UIComponents --> ViewModels
    ViewModels --> Screens
    ViewModels --> Theme
    ViewModels --> PlatformCoord
    ViewModels --> DI
    DI --> Network
    DI --> DataLayer
    Network --> RedditService
    RedditService --> Models
    RedditService --> Reddit
    DataLayer --> CacheLayer
    DataLayer --> Models

    %% Click Events
    click Android "https://github.com/bidrohi/rewalled/tree/main/app/src/androidMain/kotlin/com/bidyut/tech/rewalled"
    click iOS "https://github.com/bidrohi/rewalled/tree/main/app/ios/iosApp"
    click Desktop "https://github.com/bidrohi/rewalled/tree/main/app/src/desktopMain/kotlin"
    click UIComponents "https://github.com/bidrohi/rewalled/tree/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/ui"
    click ViewModels "https://github.com/bidrohi/rewalled/tree/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/ui/screen"
    click Screens "https://github.com/bidrohi/rewalled/blob/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/ui/Route.kt"
    click Theme "https://github.com/bidrohi/rewalled/tree/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/ui/theme"
    click Network "https://github.com/bidrohi/rewalled/tree/main/shared/core/network/src/commonMain/kotlin/com/bidyut/tech/rewalled/core/network"
    click Models "https://github.com/bidrohi/rewalled/tree/main/shared/model/src/commonMain/kotlin/com/bidyut/tech/rewalled/model"
    click RedditService "https://github.com/bidrohi/rewalled/tree/main/shared/service/reddit/src/commonMain/kotlin/com/bidyut/tech/rewalled/service/reddit"
    click DataLayer "https://github.com/bidrohi/rewalled/tree/main/shared/wallpaper/data/src/commonMain/kotlin/com/bidyut/tech/rewalled/data"
    click CacheLayer "https://github.com/bidrohi/rewalled/tree/main/shared/wallpaper/cache/src/commonMain/kotlin/com/bidyut/tech/rewalled/cache"
    click PlatformCoord "https://github.com/bidrohi/rewalled/blob/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/ui/PlatformCoordinator.kt"
    click DI "https://github.com/bidrohi/rewalled/tree/main/shared/library/src/commonMain/kotlin/com/bidyut/tech/rewalled/di"

    %% Legend
    subgraph Legend
        P["Platform-Specific"]:::platform
        S["Shared Code"]:::shared
        D["Data Layer"]:::data
        E["External Services"]:::external
        C["Cache"]:::cache
    end
```
