Deposit Flow Architecture¶
Overview¶
Deposits are processed via Crypto2B API integration with webhook callbacks.
sequenceDiagram
participant User as User
participant UserApp as User App
participant API as Backend API
participant Crypto2B as Crypto2B API
participant Database as PostgreSQL
Note over User,Database: Step 1: Get Deposit Address
User->>UserApp: Request deposit address
UserApp->>API: GET /user/deposit-address
API->>Crypto2B: GetDepositAddress(userID)
Crypto2B->>API: Return USDC deposit address
API->>UserApp: Deposit address
UserApp->>User: Display deposit address
Note over User,Database: Step 2: User Makes Deposit
User->>User: Send USDC to address
Note over User,Database: Step 3: Webhook Callback
Crypto2B->>API: POST /webhooks/crypto2b/deposit
API->>API: Validate webhook signature
API->>Database: Create confirmed transaction
API->>Database: Update user balance
Note over User,Database: Step 4: Auto-Investment (optional)
API->>API: Check user preferences
alt Auto-invest enabled
API->>Database: Create investment record
end
API->>Crypto2B: Acknowledge webhook
Components¶
Crypto2B Integration¶
- External API for crypto deposits
- Generates unique deposit addresses per user
- Sends webhook on deposit confirmation
Webhook Handler¶
- Validates Crypto2B signature
- Creates transaction record
- Updates user balance
- Triggers auto-investment if configured
Database Updates¶
transactions- Deposit record (append-only)users.balance- Updated via BalanceService