# reown-com/reown-kotlin architecture

> Architecture diagram of the GitHub repository reown-com/reown-kotlin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/reown-com/reown-kotlin
- Repository: https://github.com/reown-com/reown-kotlin

## Overview

##### Main Components

a. Core Layer:
- Core Android Module (foundation of the SDK)
- Crypto Services
- Network Communication
- Storage Systems (SQLDelight)
- Common Utilities

b. Protocol Layer:
- Sign Protocol
- Notify Protocol
- Authentication Services

c. Product Layer:
- WalletKit (wallet functionality)
- AppKit (UI components and app integration)

d. Foundation Layer:
- Base networking
- Relay services
- Crypto foundations

##### Key Relationships

a. Dependency Flow:
**Product Layer (WalletKit, AppKit)**
- ↓
**Protocol Layer (Sign, Notify)**
- ↓
**Core Layer (Android Core)**
- ↓
**Foundation Layer**

b. Data Flow:
- Communication between wallet apps and dApps
- Authentication flow
- Demonstrate message relay system

##### Architectural Patterns to Highlight

- Clean Architecture pattern (visible in module structure)
- Repository Pattern (for data management)
- MVVM Pattern (in UI components)
- Dependency Injection (using Koin)

##### Technical Components

a. Database:
- SQLDelight implementation
- Storage repositories
- Migration system

b. Network:
- Relay client
- API services
- WebSocket connections

c. Security:
- Crypto services
- Key management
- Authentication systems

##### Integration Points

- External service connections
- Blockchain interaction points
- Wallet integration interfaces

**┌─────────────────────────────────────────────────────┐**
- Application Layer                   │
- ┌─────────────┐            ┌──────────────┐       │
- AppKit    │            │  WalletKit   │       │
- ┘            └──────────────┘       │
- ┤
- Protocol Layer                      │
- ┌─────────────┐            ┌──────────────┐       │
- Sign     │            │    Notify    │       │
- ┘            └──────────────┘       │
- ┤
- Core Layer                       │
- ┌─────────────────────────────────────────┐       │
- Android Core                │       │
- ┌─────────┐  ┌─────────┐  ┌─────────┐ │       │
- Crypto  │  │ Network │  │ Storage │ │       │
- ┘  └─────────┘  └─────────┘ │       │
- ┘       │
- ┤
- Foundation Layer                     │
- ┌─────────────────────────────────────────┐       │
- Base Network & Crypto Services    │       │
- ┘       │
- ┘

- Blue: Core components
- Green: Protocol implementations
- Orange: Product modules
- Gray: Foundation services

- Database operations
- Network communications
- Security features
- External integrations

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#597FBF', 'primaryBorderColor': '#73A9D8', 'secondaryColor': '#73D892', 'tertiaryColor': '#F5A352', 'defaultLinkColor': '#5C7194'}}}%%

flowchart TB
    %% Style Definitions
    classDef core fill:#597FBF,stroke:#333,stroke-width:2px,color:white
    classDef protocol fill:#73D892,stroke:#333,stroke-width:2px
    classDef product fill:#F5A352,stroke:#333,stroke-width:2px
    classDef foundation fill:#808080,stroke:#333,stroke-width:2px
    classDef database fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#B19CD9,stroke:#333,stroke-width:2px

    subgraph ProductLayer["Product Layer"]
        WalletKit["WalletKit"]:::product
        AppKit["AppKit"]:::product
    end

    subgraph ProtocolLayer["Protocol Layer"]
        SignProtocol["Sign Protocol"]:::protocol
        NotifyProtocol["Notify Protocol"]:::protocol
        Auth["Authentication Services"]:::protocol
    end

    subgraph CoreLayer["Core Layer"]
        CoreAndroid["Core Android Module"]:::core
        subgraph CoreServices["Core Services"]
            direction TB
            Crypto["Crypto Services"]:::core
            Network["Network Communication"]:::core
            Storage["Storage Systems"]:::core
            Utils["Common Utilities"]:::core
            DB[(SQLDelight DB)]:::database
        end
        CoreClient["Core Client"]:::infrastructure
        CoreInterface["Core Interface"]:::infrastructure
    end

    subgraph FoundationLayer["Foundation Layer"]
        BaseNetwork["Base Networking"]:::foundation
        RelayServices["Relay Services"]:::foundation
        CryptoFoundation["Crypto Foundations"]:::foundation
    end

    %% Relationships
    WalletKit --> SignProtocol
    WalletKit --> NotifyProtocol
    AppKit --> SignProtocol
    AppKit --> NotifyProtocol

    SignProtocol --> CoreAndroid
    NotifyProtocol --> CoreAndroid
    Auth --> CoreAndroid

    CoreAndroid --> CoreServices
    Storage --> DB
    CoreServices --> CoreClient
    CoreClient --> CoreInterface
    CoreInterface --> FoundationLayer

    BaseNetwork --> RelayServices
    BaseNetwork --> CryptoFoundation

    %% Click Events
    click WalletKit "https://github.com/reown-com/reown-kotlin/tree/develop/product/walletkit/"
    click AppKit "https://github.com/reown-com/reown-kotlin/tree/develop/product/appkit/"
    click SignProtocol "https://github.com/reown-com/reown-kotlin/tree/develop/protocol/sign/"
    click NotifyProtocol "https://github.com/reown-com/reown-kotlin/tree/develop/protocol/notify/"
    click Auth "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/kotlin/com/reown/android/verify/"
    click CoreAndroid "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/"
    click Crypto "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/kotlin/com/reown/android/internal/common/crypto/"
    click Network "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/kotlin/com/reown/android/internal/common/connection/"
    click Storage "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/kotlin/com/reown/android/internal/common/storage/"
    click Utils "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/kotlin/com/reown/android/internal/common/"
    click DB "https://github.com/reown-com/reown-kotlin/tree/develop/core/android/src/main/sqldelight/"
    click BaseNetwork "https://github.com/reown-com/reown-kotlin/tree/develop/foundation/src/main/kotlin/com/reown/foundation/network/"
    click RelayServices "https://github.com/reown-com/reown-kotlin/tree/develop/foundation/src/main/kotlin/com/reown/foundation/network/"
    click CryptoFoundation "https://github.com/reown-com/reown-kotlin/tree/develop/foundation/src/main/kotlin/com/reown/foundation/crypto/"
    click CoreClient "https://github.com/reown-com/reown-kotlin/blob/develop/core/android/src/main/kotlin/com/reown/android/CoreClient.kt"
    click CoreInterface "https://github.com/reown-com/reown-kotlin/blob/develop/core/android/src/main/kotlin/com/reown/android/CoreInterface.kt"
```
