# babylonlabs-io/simple-staking architecture

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

- Interactive diagram: https://gitdiagram.com/babylonlabs-io/simple-staking
- Repository: https://github.com/babylonlabs-io/simple-staking

## Overview

##### Component Relationships

- User → Frontend Components → Wallet Integration
- Frontend → API Layer → Backend Services
- Wallet Integration → Bitcoin Network
- Backend Services → Babylon Network

**┌─ User Interface Layer**
- Staking Components
- Delegation Management
- Wallet Connection UI

- Business Logic Layer
- Hooks & Services
- State Management
- API Integration

- Integration Layer
- Wallet Connectors
- RPC Providers
- API Wrappers

##### Technical Details

- Next.js App Router architecture
- API endpoint structure
- Wallet integration points
- State management flow
- Error handling pathways

##### Security boundaries and authentication flows

Keep the abstraction level focused on the main architectural components while providing enough detail to understand the system's core functionality around Bitcoin staking operations.

Remember to indicate the development environment configuration points (as specified in the .env.example file) and their impact on the system's behavior.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[User Interface Layer]
        BLL[Business Logic Layer]
        IL[Integration Layer]
        
        subgraph UIComponents
            SC[Staking Components]:::frontend
            DM[Delegation Management]:::frontend
            WC[Wallet Connection UI]:::frontend
        end
        
        subgraph BusinessLogic
            HS[Hooks & Services]:::logic
            SM[State Management]:::logic
            AH[API Hooks]:::logic
        end
        
        subgraph IntegrationLayer
            WI[Wallet Integration]:::integration
            RPC[RPC Services]:::integration
            AW[API Wrappers]:::integration
        end
    end
    
    subgraph ExternalServices
        BTC[Bitcoin Network]:::external
        BBN[Babylon Network]:::external
        MEM[Mempool.space API]:::external
    end
    
    subgraph BackendServices
        API[API Services]:::backend
        EH[Error Handling]:::backend
        LS[Local Storage]:::backend
        NC[Network Config]:::backend
    end
    
    UI --> UIComponents
    UIComponents --> BLL
    BLL --> IL
    IL --> ExternalServices
    IL --> BackendServices
    
    WI --> BTC
    WI --> BBN
    AW --> MEM
    
    %% Component Mappings
    click SC "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/components/Staking"
    click DM "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/components/Delegations"
    click WC "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/components/Wallet"
    click HS "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/hooks/services"
    click SM "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/state"
    click AH "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/hooks"
    click WI "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/context/wallet"
    click RPC "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/context/rpc"
    click API "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/api"
    click EH "https://github.com/babylonlabs-io/simple-staking/tree/main/src/app/context/Error"
    click LS "https://github.com/babylonlabs-io/simple-staking/tree/main/src/utils/local_storage"
    click NC "https://github.com/babylonlabs-io/simple-staking/tree/main/src/config/network"
    click BTC "https://github.com/babylonlabs-io/simple-staking/blob/main/src/app/context/tomo/BTCConnector.tsx"
    click BBN "https://github.com/babylonlabs-io/simple-staking/blob/main/src/app/context/tomo/BBNConnector.tsx"
    
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef logic fill:#4CAF50,stroke:#2E7D32,color:white
    classDef integration fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef backend fill:#607D8B,stroke:#37474F,color:white
    
    %% Legend
    subgraph Legend
        F[Frontend Components]:::frontend
        L[Logic Components]:::logic
        I[Integration Components]:::integration
        E[External Services]:::external
        B[Backend Services]:::backend
    end
```
