# stabix-protocol/stabix-pay- architecture

> Architecture diagram of the GitHub repository stabix-protocol/stabix-pay-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stabix-protocol/stabix-pay-
- Repository: https://github.com/stabix-protocol/stabix-pay-

## Overview

StabiX is a wallet and social-finance application with web/mobile-facing screens, an API backend, and blockchain workers. The user-facing flow includes account access, internal transfers and balance/history views, plus distinct deposit and withdrawal stages; deposits are detected, confirmed, credited, and swept, while withdrawals are queued and broadcast by a worker. The tree also shows chat, profiles, search, and administration features. Backend wiring is supported by the server and sampled routes; several controller and frontend internals were not sampled, so their downstream connections are left unspecified.

Main entry points: [`backend/server.js`](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/server.js) (HTTP and socket server), [`backend/config/db.js`](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/config/db.js) (Application database), [`backend/services/EVM/Ethereum/sweep/ethereumSweepWorker.js`](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/sweep/ethereumSweepWorker.js) (Deposit sweep worker), [`stabix-frontend/app`](https://github.com/stabix-protocol/stabix-pay-/tree/V165/stabix-frontend/app) (StabiX screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_frontend["StabiX screens"]
  node_theme["Theme manager<br/>[ThemeManager.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Application API"]
  node_server["HTTP and socket server<br/>[server.js]"]
  node_user_routes["User routes<br/>[userRoutes.js]"]
  node_tx_routes["Transaction routes"]
  node_deposit_routes["Deposit routes<br/>[depositRoutes.js]"]
  node_withdraw_routes["Withdrawal routes<br/>[withdrawRoutes.js]"]
  node_social_routes["Social routes"]
  node_user_controller["Account and profile<br/>[userController.js]"]
  node_tx_controller["Transaction history"]
  node_deposit_controller["Deposit requests"]
  node_withdraw_controller["Withdrawal requests"]
  node_social_features["Chat and blocks"]
  node_tx_service["Internal transfer service"]
end

subgraph group_chain["Wallet operations"]
  node_deposit_listener["Deposit listener"]
  node_deposit_scanner["Deposit scanner"]
  node_deposit_processor["Deposit processor"]
  node_credit["Deposit crediting"]
  node_sweep["Deposit sweep worker"]
  node_withdraw_worker["Ethereum withdrawal worker"]
  node_blockchain["Chain access"]
end

subgraph group_storage["Persistent state"]
  node_database[("Application database<br/>[db.js]")]
end

node_user(("Wallet user"))
node_ethereum{{"Ethereum network"}}

node_user -->|"uses"| node_frontend
node_frontend -->|"requests"| node_api_client
node_frontend -->|"applies theme"| node_theme
node_api_client -->|"calls API"| node_server
node_server -->|"dispatches"| node_user_routes
node_server -->|"dispatches"| node_tx_routes
node_server -->|"dispatches"| node_deposit_routes
node_server -->|"dispatches"| node_withdraw_routes
node_server -->|"dispatches"| node_social_routes
node_user_routes -->|"dispatches"| node_user_controller
node_tx_routes -->|"dispatches"| node_tx_controller
node_deposit_routes -->|"dispatches"| node_deposit_controller
node_withdraw_routes -->|"dispatches"| node_withdraw_controller
node_social_routes -->|"dispatches"| node_social_features
node_tx_controller -->|"invokes"| node_tx_service
node_server -->|"starts"| node_deposit_listener
node_server -->|"starts"| node_deposit_scanner
node_server -->|"starts"| node_deposit_processor
node_server -->|"starts"| node_withdraw_worker
node_server -->|"starts"| node_sweep
node_deposit_processor -->|"credits deposits"| node_credit
node_credit -->|"creates sweep job"| node_sweep
node_deposit_listener -->|"monitors"| node_ethereum
node_deposit_scanner -->|"scans"| node_ethereum
node_blockchain -->|"accesses chain"| node_ethereum
node_sweep -->|"gets provider"| node_blockchain
node_withdraw_worker -->|"gets provider"| node_blockchain
node_server -->|"checks connection"| node_database
node_user_controller -->|"queries"| node_database
node_tx_controller -->|"queries"| node_database
node_withdraw_controller -->|"updates requests"| node_database
node_credit -->|"credits balances"| node_database
node_sweep -->|"updates jobs"| node_database
node_withdraw_worker -->|"updates withdrawals"| node_database

click node_frontend "https://github.com/stabix-protocol/stabix-pay-/tree/V165/stabix-frontend/app"
click node_theme "https://github.com/stabix-protocol/stabix-pay-/blob/V165/stabix-frontend/components/ThemeManager.tsx"
click node_api_client "https://github.com/stabix-protocol/stabix-pay-/blob/V165/stabix-frontend/lib/api.ts"
click node_server "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/server.js"
click node_user_routes "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/userRoutes.js"
click node_tx_routes "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/transactionRoutes.js"
click node_deposit_routes "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/depositRoutes.js"
click node_withdraw_routes "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/withdrawRoutes.js"
click node_social_routes "https://github.com/stabix-protocol/stabix-pay-/tree/V165/backend/routes"
click node_user_controller "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/userController.js"
click node_tx_controller "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/transactionController.js"
click node_deposit_controller "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/depositController.js"
click node_withdraw_controller "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/withdrawController.js"
click node_social_features "https://github.com/stabix-protocol/stabix-pay-/tree/V165/backend/controllers"
click node_tx_service "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/transactionService.js"
click node_deposit_listener "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositListener.js"
click node_deposit_scanner "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositScanner.js"
click node_deposit_processor "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositProcessor.js"
click node_credit "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/depositCreditService.js"
click node_sweep "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/sweep/ethereumSweepWorker.js"
click node_withdraw_worker "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/withdraw/ethereumWithdrawService.js"
click node_blockchain "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/blockchainService.js"
click node_database "https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_theme,node_api_client,node_user toneBlue
class node_server,node_user_routes,node_tx_routes,node_deposit_routes,node_withdraw_routes,node_social_routes,node_user_controller,node_tx_controller,node_deposit_controller,node_withdraw_controller,node_social_features,node_tx_service toneAmber
class node_deposit_listener,node_deposit_scanner,node_deposit_processor,node_credit,node_sweep,node_withdraw_worker,node_blockchain toneMint
class node_database toneRose
class node_ethereum toneIndigo
```

## Components

### Client experience

- [StabiX screens](https://github.com/stabix-protocol/stabix-pay-/tree/V165/stabix-frontend/app): `stabix-frontend/app`
- [Theme manager](https://github.com/stabix-protocol/stabix-pay-/blob/V165/stabix-frontend/components/ThemeManager.tsx): `stabix-frontend/components/ThemeManager.tsx`
- [API client](https://github.com/stabix-protocol/stabix-pay-/blob/V165/stabix-frontend/lib/api.ts): `stabix-frontend/lib/api.ts`

### Application API

- [HTTP and socket server](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/server.js): `backend/server.js`
- [User routes](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [Transaction routes](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/transactionRoutes.js): `backend/routes/transactionRoutes.js`
- [Deposit routes](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/depositRoutes.js): `backend/routes/depositRoutes.js`
- [Withdrawal routes](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/routes/withdrawRoutes.js): `backend/routes/withdrawRoutes.js`
- [Social routes](https://github.com/stabix-protocol/stabix-pay-/tree/V165/backend/routes): `backend/routes`
- [Account and profile](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Transaction history](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/transactionController.js): `backend/controllers/transactionController.js`
- [Deposit requests](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/depositController.js): `backend/controllers/depositController.js`
- [Withdrawal requests](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/controllers/withdrawController.js): `backend/controllers/withdrawController.js`
- [Chat and blocks](https://github.com/stabix-protocol/stabix-pay-/tree/V165/backend/controllers): `backend/controllers`
- [Internal transfer service](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/transactionService.js): `backend/services/transactionService.js`

### Wallet operations

- [Deposit listener](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositListener.js): `backend/services/EVM/Ethereum/deposit/ethereumDepositListener.js`
- [Deposit scanner](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositScanner.js): `backend/services/EVM/Ethereum/deposit/ethereumDepositScanner.js`
- [Deposit processor](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/deposit/ethereumDepositProcessor.js): `backend/services/EVM/Ethereum/deposit/ethereumDepositProcessor.js`
- [Deposit crediting](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/depositCreditService.js): `backend/services/depositCreditService.js`
- [Deposit sweep worker](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/sweep/ethereumSweepWorker.js): `backend/services/EVM/Ethereum/sweep/ethereumSweepWorker.js`
- [Ethereum withdrawal worker](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/EVM/Ethereum/withdraw/ethereumWithdrawService.js): `backend/services/EVM/Ethereum/withdraw/ethereumWithdrawService.js`
- [Chain access](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/services/blockchainService.js): `backend/services/blockchainService.js`

### Persistent state

- [Application database](https://github.com/stabix-protocol/stabix-pay-/blob/V165/backend/config/db.js): `backend/config/db.js`

### Other components

- **Wallet user**
- **Ethereum network**

## Connections

- Wallet user → StabiX screens: uses
- StabiX screens → API client: requests
- StabiX screens → Theme manager: applies theme
- API client → HTTP and socket server: calls API
- HTTP and socket server → User routes: dispatches
- HTTP and socket server → Transaction routes: dispatches
- HTTP and socket server → Deposit routes: dispatches
- HTTP and socket server → Withdrawal routes: dispatches
- HTTP and socket server → Social routes: dispatches
- User routes → Account and profile: dispatches
- Transaction routes → Transaction history: dispatches
- Deposit routes → Deposit requests: dispatches
- Withdrawal routes → Withdrawal requests: dispatches
- Social routes → Chat and blocks: dispatches
- Transaction history → Internal transfer service: invokes
- HTTP and socket server → Deposit listener: starts
- HTTP and socket server → Deposit scanner: starts
- HTTP and socket server → Deposit processor: starts
- HTTP and socket server → Ethereum withdrawal worker: starts
- HTTP and socket server → Deposit sweep worker: starts
- Deposit processor → Deposit crediting: credits deposits
- Deposit crediting → Deposit sweep worker: creates sweep job
- Deposit listener → Ethereum network: monitors
- Deposit scanner → Ethereum network: scans
- Chain access → Ethereum network: accesses chain
- Deposit sweep worker → Chain access: gets provider
- Ethereum withdrawal worker → Chain access: gets provider
- HTTP and socket server → Application database: checks connection
- Account and profile → Application database: queries
- Transaction history → Application database: queries
- Withdrawal requests → Application database: updates requests
- Deposit crediting → Application database: credits balances
- Deposit sweep worker → Application database: updates jobs
- Ethereum withdrawal worker → Application database: updates withdrawals
