# kaiju-no-9/sol_lite architecture

> Architecture diagram of the GitHub repository kaiju-no-9/sol_lite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaiju-no-9/sol_lite
- Repository: https://github.com/kaiju-no-9/sol_lite

## Overview

##### What this project is (type + purpose)
This is a **mobile client (Expo / React Native + TypeScript)** that **connects to a Solana wallet, retrieves wallet-related data (balances/tokens) and displays transaction history**. The README describes a “mobile app that retrieve data from your solana wallet and display it along with transition history.”

There is **no backend service** visible in the file tree (no server folder, no API routes, no database). Architecturally, it’s a **client-only app** that likely talks directly to:
- **Solana RPC** (for on-chain account/transaction data)
- Possibly **3rd-party Solana indexing APIs** (e.g., Solscan-like explorers) if used for richer history/token metadata (not explicit in README, but the app naming suggests this might exist)

##### Routing / Screens (Expo Router)
The `app/` directory indicates **expo-router** routing:
- `app/_layout.tsx` and `app/(tabs)/_layout.tsx` define navigation layout (root stack + tab navigator)
- `app/(tabs)/index.tsx`, `explorer.tsx`, `swap.tsx`, `settings.tsx` are **tab screens**
- `app/orders.tsx` is a non-tab route (likely pushed from a tab)
- `app/token/[mint].tsx` is a **dynamic route** for viewing a specific token by mint address

##### Shared app logic
- `src/store/wallet.ts` is a **wallet state management module** (connection state, selected wallet/account, public key, etc.)
- `src/lib/lib.tsx` is a **library/util layer** (usually: RPC calls, formatting, helpers, Solana SDK wrappers)
- `src/components/FavButton.tsx` is a reusable UI component (favoriting tokens/addresses/items)

##### Duplicate top-level trees
You have two parallel app roots:
- `SolScan/...`
- and also the same structure at repository root (`app/`, `assets/`, `package.json`, etc.)

##### What to capture
Because there’s no backend, the “system” is primarily:
- **Mobile App (UI + navigation)**
- **State layer (wallet store)**
- **Data access layer (Solana RPC / external APIs)**
- Optional: OS-level secure storage / deep links (not shown, but common in wallet apps—only include if truly present in code)

**Goal:** Show user, the app, and external dependencies.

- **User**
- **Sol_lite Mobile App (iOS/Android)**
- **Solana Blockchain** (conceptual)
- **Solana RPC Provider** (QuickNode/Helius/Alchemy/public RPC — name unknown; label generically as “RPC endpoint”)
- **Swap/DEX Aggregator (optional)** (because there is a `swap.tsx` tab; include as “Swap Quote/Swap API” if it exists in code)

- User → Mobile App: “view wallet, browse tokens, view tx history”
- Mobile App → RPC Provider: “get account info, token accounts, transactions”
- RPC Provider → Solana Blockchain: “RPC queries / reads”
- (Optional) Mobile App → Indexing API: “enhanced tx history, token metadata”
- (Optional) Mobile App → Swap API: “quotes, routes, build tx”

**Notes to label:**
- “Client-only; no dedicated backend in repo”
- “Reads on-chain state via RPC; may supplement with indexing”

**Goal:** Show the internal “containers” even if they’re all inside a mobile app.

**Containers inside the Mobile App:**
##### Navigation / Router (expo-router)
- Routes from `app/` (`_layout.tsx`, `(tabs)/_layout.tsx`, screens)
##### UI Screens (React components)
- Tabs: `index`, `explorer`, `swap`, `settings`
- Routes: `orders`, `token/[mint]`
##### State Management (Wallet Store)
- `src/store/wallet.ts`
##### Data / Service Layer (Lib)
- `src/lib/lib.tsx` (RPC calls, formatting, helpers, adapters)
##### Shared UI Components
- `src/components/FavButton.tsx` (and future components)

**External containers:**
- **Solana RPC Endpoint**
- (Optional) **Indexing/Explorer API**
- (Optional) **Swap API**

- Screens → Wallet Store: “read/write wallet state”
- Screens → Lib: “load balances/tx history/token details”
- Lib → RPC Endpoint: “fetch on-chain data”
- Wallet Store → Lib or RPC (depending on code): “publicKey triggers reload”

**Goal:** Make it “code-shaped” so it matches what’s in this tree.

##### Components to include (map directly to folders/files)
**Routing / Layout**
- `app/_layout.tsx` (root navigation shell)
- `app/(tabs)/_layout.tsx` (tab navigator)

**Tab Screens**
- `app/(tabs)/index.tsx` — likely wallet overview (balances summary)
- `app/(tabs)/explorer.tsx` — explore addresses/tokens/tx
- `app/(tabs)/swap.tsx` — swapping flow (quote/build/sign/send)
- `app/(tabs)/settings.tsx` — app settings + wallet settings

**Non-tab Screens**
- `app/orders.tsx` — orders/history view (swap orders or tx orders; label neutrally as “Orders screen”)
- `app/token/[mint].tsx` — token detail screen (mint as route param)

**State**
- `src/store/wallet.ts` — wallet connection/session state, selected account/publicKey, etc.

**Lib**
- `src/lib/lib.tsx` — Solana client helpers, RPC wrappers, formatting, etc.

**UI Component**
- `src/components/FavButton.tsx` — favorites toggling (likely stored locally or in store)

##### Architectural patterns/design principles evident here
- **Client-side, layered architecture**:
- Presentation (screens/components)
- State management (`src/store`)
- Services/utilities (`src/lib`)
- External integrations (RPC / APIs)
- **Route-as-module** with expo-router: each file in `app/` is a routable component

- **Clear labels** with file/folder mapping, e.g.
“Token Detail Screen (`app/token/[mint].tsx`)”
- Blue rectangles: UI screens/routes
- Green hexagon: External services (RPC, indexing, swap)
- **Boundaries**:
- One boundary for “Mobile Device (Expo App)”
- Separate boundary for “External Services”
- Optional boundary for “Solana Network” behind RPC provider

##### Practical “don’t overthink it” component breakdown (max separation, minimal assumptions)
- `app/_layout.tsx`
- `app/(tabs)/_layout.tsx`
- `app/(tabs)/index.tsx`
- `app/(tabs)/explorer.tsx`
- `app/(tabs)/swap.tsx`
- `app/(tabs)/settings.tsx`
- `app/orders.tsx`
- `app/token/[mint].tsx`
- `src/store/wallet.ts`
- `src/lib/lib.tsx`
- `src/components/FavButton.tsx`
- External: “Solana RPC Endpoint”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% Diagram A: System Context
    %% =========================
    subgraph "System Context"
        direction TB
        User(("User")):::external

        App(("Sol_lite Mobile App\n(Expo / React Native + TypeScript)")):::app

        subgraph "External Services"
            direction TB
            RPC{{"Solana RPC Endpoint\n(public/hosted provider)"}}:::externalSvc
            IDX{{"Indexing / Explorer API\n(optional; only if used)"}}:::externalSvc
            SWAPAPI{{"Swap Quote / Swap API\n(optional; only if used)"}}:::externalSvc
        end

        subgraph "Solana Network"
            direction TB
            Solana[("Solana Blockchain")]:::solana
        end

        User -->|"viewWallet/tokens/txHistory"| App
        App -->|"getAccountInfo/getTokenAccounts/getTransactions"| RPC
        RPC -->|"RPCreads"| Solana

        App -.->|"enhancedHistory/tokenMetadata(optional)"| IDX
        App -.->|"quotes/routes/buildTx(optional)"| SWAPAPI
    end

    Note1["Note: Client-only app;\nno dedicated backend in repo."]:::note
    App --- Note1

    %% ======================================
    %% Diagram B/C: Container + Component View
    %% ======================================
    subgraph "Mobile Device (iOS/Android) — Expo App"
        direction TB

        AppConfig["Expo App Config"]:::config

        subgraph "Navigation / Router (expo-router)"
            direction TB
            RootLayout["Root Layout\n(app/_layout.tsx)"]:::router
            TabsLayout["Tabs Layout\n(app/(tabs)/_layout.tsx)"]:::router
            RootLayout -->|"hostsTabs"| TabsLayout
        end

        subgraph "UI Screens (Routes)"
            direction TB
            subgraph "Tab Screens"
                direction TB
                WalletOverview["Wallet Overview\n(app/(tabs)/index.tsx)"]:::screen
                Explorer["Explorer\n(app/(tabs)/explorer.tsx)"]:::screen
                Swap["Swap\n(app/(tabs)/swap.tsx)"]:::screen
                Settings["Settings\n(app/(tabs)/settings.tsx)"]:::screen
            end

            subgraph "Non-tab Routes"
                direction TB
                Orders["Orders\n(app/orders.tsx)"]:::screen
                TokenDetail["Token Detail (dynamic)\n(app/token/[mint].tsx)"]:::screen
            end
        end

        subgraph "State Management"
            direction TB
            WalletStore[("Wallet Store\n(src/store/wallet.ts)")]:::store
        end

        subgraph "Data / Service Layer"
            direction TB
            Lib["Lib / RPC Helpers + Formatting\n(src/lib/lib.tsx)"]:::lib
        end

        subgraph "Shared UI Components"
            direction TB
            FavButton["FavButton\n(src/components/FavButton.tsx)"]:::component
        end

        subgraph "Static Assets"
            direction TB
            Assets["assets/"]:::assets
        end

        %% Router -> screens
        TabsLayout -->|"routeTo"| WalletOverview
        TabsLayout -->|"routeTo"| Explorer
        TabsLayout -->|"routeTo"| Swap
        TabsLayout -->|"routeTo"| Settings
        RootLayout -->|"pushRoute"| Orders
        RootLayout -->|"pushRoute"| TokenDetail

        %% Screens -> Store / Lib
        WalletOverview -->|"readWalletPublicKey"| WalletStore
        Explorer -->|"readWalletPublicKey"| WalletStore
        Swap -->|"readWalletPublicKey"| WalletStore
        Settings -->|"updateWalletPrefs"| WalletStore
        Orders -->|"readWalletState"| WalletStore
        TokenDetail -->|"readWalletState"| WalletStore

        WalletOverview -->|"loadBalances/tokens"| Lib
        Explorer -->|"loadAccountInfo/txHistory"| Lib
        Orders -->|"loadHistory/orders"| Lib
        TokenDetail -->|"fetchTokenByMint"| Lib
        Swap -->|"quote/build/submit"| Lib

        %% Store -> screens (subscriptions)
        WalletStore -.->|"stateChanged"| WalletOverview
        WalletStore -.->|"stateChanged"| Explorer
        WalletStore -.->|"stateChanged"| Swap
        WalletStore -.->|"stateChanged"| Settings
        WalletStore -.->|"stateChanged"| Orders
        WalletStore -.->|"stateChanged"| TokenDetail

        %% Shared component usage
        FavButton -.->|"usedBy"| WalletOverview
        FavButton -.->|"usedBy"| Explorer
        FavButton -.->|"usedBy"| TokenDetail

        %% Assets used by UI
        Assets -.->|"icons/images"| WalletOverview
        Assets -.->|"icons/images"| Explorer
        Assets -.->|"icons/images"| Swap
        Assets -.->|"icons/images"| Settings
    end

    %% External calls from Lib
    Lib -->|"RPCreads"| RPC
    Lib -.->|"optionalHTTP"| IDX
    Lib -.->|"optionalHTTP"| SWAPAPI

    %% =========================
    %% Duplicate / Legacy Folder
    %% =========================
    subgraph "Duplicate / Legacy App Root (parallel structure)"
        direction TB
        Legacy["SolScan/"]:::legacy
        LegacyRoot["SolScan Root Layout\n(SolScan/app/_layout.tsx)"]:::legacyNode
        LegacyTabs["SolScan Tabs Layout\n(SolScan/app/(tabs)/_layout.tsx)"]:::legacyNode
        LegacyScreens["SolScan Tab Screens\n(SolScan/app/(tabs)/*)"]:::legacyNode
        LegacyOrders["SolScan Orders\n(SolScan/app/orders.tsx)"]:::legacyNode
        LegacyToken["SolScan Token Detail\n(SolScan/app/token/[mint].tsx)"]:::legacyNode
        LegacyAssets["SolScan/assets/"]:::legacyNode

        Legacy --> LegacyRoot --> LegacyTabs --> LegacyScreens
        LegacyRoot --> LegacyOrders
        LegacyRoot --> LegacyToken
        Legacy --> LegacyAssets
    end

    %% Relationship: legacy mirrors main
    Legacy -.->|"parallelCopy"| App

    %% ========
    %% Legend
    %% ========
    subgraph "Legend"
        direction TB
        L1["Blue: UI Screens / Routes"]:::screen
        L2["Teal: Router / Navigation"]:::router
        L3["Purple: State Store"]:::store
        L4["Gray: Shared Components / Lib"]:::lib
        L5["Green: External Services"]:::externalSvc
        L6["Solid arrow: call/dependency"]:::note
        L7["Dashed arrow: event/subscription/optional"]:::note
    end

    %% ============
    %% Click Events
    %% ============
    click AppConfig "https://github.com/kaiju-no-9/sol_lite/blob/main/app.json"
    click RootLayout "https://github.com/kaiju-no-9/sol_lite/blob/main/app/_layout.tsx"
    click TabsLayout "https://github.com/kaiju-no-9/sol_lite/blob/main/app/(tabs)/_layout.tsx"
    click WalletOverview "https://github.com/kaiju-no-9/sol_lite/blob/main/app/(tabs)/index.tsx"
    click Explorer "https://github.com/kaiju-no-9/sol_lite/blob/main/app/(tabs)/explorer.tsx"
    click Swap "https://github.com/kaiju-no-9/sol_lite/blob/main/app/(tabs)/swap.tsx"
    click Settings "https://github.com/kaiju-no-9/sol_lite/blob/main/app/(tabs)/settings.tsx"
    click Orders "https://github.com/kaiju-no-9/sol_lite/blob/main/app/orders.tsx"
    click TokenDetail "https://github.com/kaiju-no-9/sol_lite/blob/main/app/token/[mint].tsx"
    click WalletStore "https://github.com/kaiju-no-9/sol_lite/blob/main/src/store/wallet.ts"
    click Lib "https://github.com/kaiju-no-9/sol_lite/blob/main/src/lib/lib.tsx"
    click FavButton "https://github.com/kaiju-no-9/sol_lite/blob/main/src/components/FavButton.tsx"
    click Assets "https://github.com/kaiju-no-9/sol_lite/tree/main/assets/"

    click Legacy "https://github.com/kaiju-no-9/sol_lite/tree/main/SolScan/"
    click LegacyRoot "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/_layout.tsx"
    click LegacyTabs "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/(tabs)/_layout.tsx"
    click LegacyScreens "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/(tabs)/index.tsx"
    click LegacyOrders "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/orders.tsx"
    click LegacyToken "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/token/[mint].tsx"
    click LegacyAssets "https://github.com/kaiju-no-9/sol_lite/tree/main/SolScan/assets/"
    click LegacyScreens "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/(tabs)/explorer.tsx"
    click LegacyScreens "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/(tabs)/swap.tsx"
    click LegacyScreens "https://github.com/kaiju-no-9/sol_lite/blob/main/SolScan/app/(tabs)/settings.tsx"

    %% ======
    %% Styles
    %% ======
    classDef app fill:#0B5FFF,stroke:#073B9A,color:#FFFFFF,stroke-width:2px
    classDef config fill:#1D4ED8,stroke:#0B2F8A,color:#FFFFFF,stroke-width:2px
    classDef router fill:#14B8A6,stroke:#0F766E,color:#062A28,stroke-width:2px
    classDef screen fill:#2563EB,stroke:#1E3A8A,color:#FFFFFF,stroke-width:2px
    classDef store fill:#7C3AED,stroke:#4C1D95,color:#FFFFFF,stroke-width:2px
    classDef lib fill:#6B7280,stroke:#374151,color:#FFFFFF,stroke-width:2px
    classDef component fill:#9CA3AF,stroke:#4B5563,color:#111827,stroke-width:2px
    classDef assets fill:#334155,stroke:#0F172A,color:#FFFFFF,stroke-width:2px
    classDef external fill:#111827,stroke:#000000,color:#FFFFFF,stroke-width:2px
    classDef externalSvc fill:#22C55E,stroke:#15803D,color:#05210D,stroke-width:2px
    classDef solana fill:#10B981,stroke:#047857,color:#05210D,stroke-width:2px
    classDef legacy fill:#F59E0B,stroke:#B45309,color:#1F1300,stroke-width:2px
    classDef legacyNode fill:#FBBF24,stroke:#B45309,color:#1F1300,stroke-width:2px
    classDef note fill:#E5E7EB,stroke:#9CA3AF,color:#111827,stroke-width:1px
```
