# rabbitio/wallet-public architecture

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

- Interactive diagram: https://gitdiagram.com/rabbitio/wallet-public
- Repository: https://github.com/rabbitio/wallet-public

## Overview

##### Project type and purpose
- This is Rabbit, a privacy-oriented, self-custodial multicurrency wallet.
- It is structured as a monorepo with three major deliverables:
- A backend API/server (in the backend folder)
- A JavaScript client-SDK (in the src folder under src/api)
- A static website (in the root public folder) for landing pages and docs

##### Top-level components
- Static Web Tier (public/landing, public/docs, error pages)
- Backend API Server (Next.js + Express custom server, controllers, routes, services)
- Client SDK Library (modules under src/api that wrap backend endpoints and external blockchain APIs)
- Database (MongoDB)
- External Services (blockchain RPCs/external-API providers, fiat-rates providers, email/notification gateways)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients" 
        direction TB
        ClientApps["Web/Mobile Apps"]:::frontend
    end

    %% SDK Layer
    subgraph "JavaScript SDK" 
        direction TB
        SDKCore["index.js"]:::frontend
        subgraph "Modules"
            direction TB
            SDKAuth["Auth Module"]:::frontend
            SDKWallet["Wallet Modules"]:::frontend
            SDKPurchases["Purchases Module"]:::frontend
            SDKNotifications["Notifications Module"]:::frontend
            SDKSupport["Support Module"]:::frontend
        end
        subgraph "Shared Utilities"
            direction TB
            SDKCommon["Common Utilities & Adapters"]:::frontend
        end
    end

    %% Static Web Tier
    subgraph "Static Web Tier" 
        direction TB
        Landing["Landing Pages"]:::frontend
        Docs["Documentation"]:::frontend
        Error404["404 Page"]:::frontend
        Error500["500 Page"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API Server" 
        direction TB
        Entry["entry: index.js"]:::backend
        subgraph "Routes"
            direction TB
            Routes["Routes Folder"]:::backend
        end
        subgraph "Controllers"
            direction TB
            Controllers["Controllers Folder"]:::backend
        end
        subgraph "Services"
            direction TB
            DomainServices["Domain Services"]:::backend
            ExternalServices["External Integrations"]:::backend
        end
        subgraph "Middlewares"
            direction TB
            Middlewares["Middlewares Folder"]:::backend
        end
        subgraph "Utilities"
            direction TB
            Utils["Utils Folder"]:::backend
            ScheduleJobs["Scheduler & Jobs"]:::backend
        end
        subgraph "Next.js Static"
            direction TB
            NextConfig["next.config.mjs"]:::backend
            Locales["i18n Assets"]:::backend
        end
    end

    %% Database
    subgraph "Database"
        direction TB
        MongoDB["MongoDB Instance"]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        BTCChain["Bitcoin RPC"]:::external
        ETHChain["Ethereum RPC"]:::external
        TRONChain["TRON RPC"]:::external
        FiatRatesAPI["Fiat Rates Providers"]:::external
        RampPayments["RampPayments Service"]:::external
        EmailSMS["Email/SMS Gateways"]:::external
        Webhooks["Webhook Receivers"]:::external
    end

    %% Data Flows
    ClientApps -->|"imports SDK"| SDKCore
    SDKCore -->|"calls Auth/Wallet/etc"| Controllers
    Controllers -->|"uses Services"| DomainServices
    DomainServices -->|"DB Queries/Updates"| MongoDB
    DomainServices -->|"calls External APIs"| BTCChain
    DomainServices -->|"calls External APIs"| ETHChain
    DomainServices -->|"calls External APIs"| TRONChain
    DomainServices -->|"calls External APIs"| FiatRatesAPI
    DomainServices -->|"calls External APIs"| RampPayments
    DomainServices -->|"sends Notifications"| EmailSMS
    DomainServices -->|"triggers Webhooks"| Webhooks
    Utils -->|"schedules"| ScheduleJobs
    ScheduleJobs -->|"refresh rates"| DomainServices
    NextConfig -->|"serves static"| Landing
    Locales -->|"serves i18n assets"| Docs

    %% Click Events
    click Landing "https://github.com/rabbitio/wallet-public/tree/main/public/landing"
    click Docs "https://github.com/rabbitio/wallet-public/tree/main/public/docs"
    click Error404 "https://github.com/rabbitio/wallet-public/tree/main/public/404"
    click Error500 "https://github.com/rabbitio/wallet-public/tree/main/public/500"
    click Entry "https://github.com/rabbitio/wallet-public/blob/main/backend/src/index.js"
    click Routes "https://github.com/rabbitio/wallet-public/tree/main/backend/src/routes/"
    click Controllers "https://github.com/rabbitio/wallet-public/tree/main/backend/src/controllers/"
    click DomainServices "https://github.com/rabbitio/wallet-public/tree/main/backend/src/services/"
    click Middlewares "https://github.com/rabbitio/wallet-public/tree/main/backend/src/middlewares/"
    click Utils "https://github.com/rabbitio/wallet-public/tree/main/backend/src/utils/"
    click ScheduleJobs "https://github.com/rabbitio/wallet-public/blob/main/backend/src/utils/scheduleRatesRetrieval.js"
    click NextConfig "https://github.com/rabbitio/wallet-public/blob/main/backend/next.config.mjs"
    click Locales "https://github.com/rabbitio/wallet-public/tree/main/backend/public/"
    click SDKCore "https://github.com/rabbitio/wallet-public/blob/main/src/api/index.js"
    click SDKAuth "https://github.com/rabbitio/wallet-public/tree/main/src/api/auth/"
    click SDKWallet "https://github.com/rabbitio/wallet-public/tree/main/src/api/wallet/"
    click SDKPurchases "https://github.com/rabbitio/wallet-public/tree/main/src/api/purchases/"
    click SDKNotifications "https://github.com/rabbitio/wallet-public/tree/main/src/api/notifications/"
    click SDKSupport "https://github.com/rabbitio/wallet-public/tree/main/src/api/support/"
    click SDKCommon "https://github.com/rabbitio/wallet-public/tree/main/src/api/common/"
    click MongoDB "https://github.com/rabbitio/wallet-public/blob/main/backend/src/utils/dbConnectionHolder.js"
    click MongoDB "https://github.com/rabbitio/wallet-public/blob/main/backend/src/utils/initDB.js"
    click DomainServices "https://github.com/rabbitio/wallet-public/blob/main/backend/src/services/external/externalBTCFiatRatesService.js"
    click DomainServices "https://github.com/rabbitio/wallet-public/blob/main/backend/src/services/data/btcFiatRates.js"
    click DomainServices "https://github.com/rabbitio/wallet-public/blob/main/backend/src/services/fiatRatesService.js"
    click DomainServices "https://github.com/rabbitio/wallet-public/blob/main/backend/src/services/rampPaymentsService.js"
    click Utils "https://github.com/rabbitio/wallet-public/blob/main/backend/src/utils/robustExternalAPICallerService.js"
    click Utils "https://github.com/rabbitio/wallet-public/blob/main/backend/src/utils/promiseRetryWrapper.js"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#333,stroke-width:1px
    classDef backend fill:#FFD0B3,stroke:#333,stroke-width:1px
    classDef db fill:#C5E1A5,stroke:#333,stroke-width:1px
    classDef external fill:#ECECEC,stroke:#333,stroke-width:1px
```
