# rohit-deogharkar/userbot architecture

> Architecture diagram of the GitHub repository rohit-deogharkar/userbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohit-deogharkar/userbot
- Repository: https://github.com/rohit-deogharkar/userbot

## Overview

userDexBot is a web app for linking a login to MetaMask, creating and funding a smart account, and enabling a permission-limited server-side trading bot. The browser presents the workflow and verifies permission transactions; the API coordinates authentication and wallet actions, while the strategy runner initiates automatic trades. README capabilities include deposits, withdrawals, stopping, test trades, on-chain permission rules, and KMS-backed bot signing. Some frontend and backend relationships are supported by the SOURCE INDEX or README rather than inspected source excerpts.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/App.jsx) (App workflow), [`backend/src/wallets.js`](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/wallets.js) (Account actions), [`backend/src/chain.js`](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/chain.js) (Chain clients), [`backend/src/db.js`](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/db.js) (Application records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser app"]
  node_app["App workflow<br/>[App.jsx]"]
  node_forms["Wallet forms<br/>[AmountForm.jsx]"]
  node_onboarding["Login onboarding<br/>[Onboarding.jsx]"]
  node_activity["Activity view<br/>[Activity.jsx]"]
  node_walletlib["Wallet client<br/>[wallet.js]"]
  node_safety["Permission verifier<br/>[verifyMetaMask.js]"]
end

subgraph group_api["API and accounts"]
  node_api["HTTP API<br/>[api.js]"]
  node_routes["API routes<br/>[routes.js]"]
  node_auth["Login and linking<br/>[auth.js]"]
  node_wallets["Account actions<br/>[wallets.js]"]
  node_permissions["Smart account rules<br/>[metamask.js]"]
end

subgraph group_trading["Trading runtime"]
  node_runner["Strategy runner<br/>[runner.js]"]
  node_strategy["Trade decisions<br/>[strategy.js]"]
  node_swaps["Quotes and swaps<br/>[bot.js]"]
end

subgraph group_infra["Chain and persistence"]
  node_config["Network and limits<br/>[config.js]"]
  node_chain["Chain clients<br/>[chain.js]"]
  node_kms["Bot key signer<br/>[kms.js]"]
  node_database[("Application records<br/>[db.js]")]
end

node_user(("User"))
node_metamask{{"MetaMask"}}
node_mongo[("MongoDB")]
node_bnb{{"BNB Chain"}}
node_pancake{{"PancakeSwap v3"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_onboarding
node_app -->|"renders"| node_forms
node_app -->|"renders"| node_activity
node_app -->|"requests"| node_api
node_app -->|"uses"| node_walletlib
node_app -->|"checks permissions"| node_safety
node_app -->|"requests signatures"| node_metamask
node_safety -->|"verifies transactions"| node_metamask
node_api -->|"calls"| node_routes
node_routes -->|"authenticates"| node_auth
node_routes -->|"dispatches actions"| node_wallets
node_routes -->|"reads records"| node_database
node_auth -->|"reads and writes"| node_database
node_auth -->|"checks signatures"| node_chain
node_wallets -->|"builds executions"| node_permissions
node_wallets -->|"stores actions"| node_database
node_wallets -->|"executes trades"| node_swaps
node_runner -->|"requests decisions"| node_strategy
node_runner -->|"trades for users"| node_wallets
node_runner -->|"loads enabled users"| node_database
node_swaps -->|"encodes calls"| node_permissions
node_swaps -->|"submits transactions"| node_chain
node_chain -->|"configures clients"| node_config
node_chain -->|"creates signer"| node_kms
node_database -->|"stores records"| node_mongo
node_chain -->|"reads and submits"| node_bnb
node_swaps -->|"quotes and swaps"| node_pancake
node_permissions -->|"enforces delegation"| node_bnb

click node_app "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/App.jsx"
click node_forms "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/AmountForm.jsx"
click node_onboarding "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/Onboarding.jsx"
click node_activity "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/Activity.jsx"
click node_walletlib "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/wallet.js"
click node_safety "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/verifyMetaMask.js"
click node_api "https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/api.js"
click node_routes "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/routes.js"
click node_auth "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/auth.js"
click node_wallets "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/wallets.js"
click node_permissions "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/metamask.js"
click node_runner "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/strategy/runner.js"
click node_strategy "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/strategy/strategy.js"
click node_swaps "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/bot.js"
click node_config "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/config.js"
click node_chain "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/chain.js"
click node_kms "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/kms.js"
click node_database "https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/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_app,node_forms,node_onboarding,node_activity,node_walletlib,node_safety,node_user toneBlue
class node_api,node_routes,node_auth,node_wallets,node_permissions,node_mongo toneAmber
class node_runner,node_strategy,node_swaps toneMint
class node_config,node_chain,node_kms,node_database toneRose
class node_metamask,node_bnb,node_pancake toneIndigo
```

## Components

### Browser app

- [App workflow](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Wallet forms](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/AmountForm.jsx): `frontend/src/components/AmountForm.jsx`
- [Login onboarding](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/Onboarding.jsx): `frontend/src/components/Onboarding.jsx`
- [Activity view](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/components/Activity.jsx): `frontend/src/components/Activity.jsx`
- [Wallet client](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/wallet.js): `frontend/src/lib/wallet.js`
- [Permission verifier](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/verifyMetaMask.js): `frontend/src/lib/verifyMetaMask.js`

### API and accounts

- [HTTP API](https://github.com/rohit-deogharkar/userbot/blob/master/frontend/src/lib/api.js): `frontend/src/lib/api.js`
- [API routes](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/routes.js): `backend/src/routes.js`
- [Login and linking](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/auth.js): `backend/src/auth.js`
- [Account actions](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/wallets.js): `backend/src/wallets.js`
- [Smart account rules](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/metamask.js): `backend/src/metamask.js`

### Trading runtime

- [Strategy runner](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/strategy/runner.js): `backend/src/strategy/runner.js`
- [Trade decisions](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/strategy/strategy.js): `backend/src/strategy/strategy.js`
- [Quotes and swaps](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/bot.js): `backend/src/bot.js`

### Chain and persistence

- [Network and limits](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/config.js): `backend/src/config.js`
- [Chain clients](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/chain.js): `backend/src/chain.js`
- [Bot key signer](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/kms.js): `backend/src/kms.js`
- [Application records](https://github.com/rohit-deogharkar/userbot/blob/master/backend/src/db.js): `backend/src/db.js`

### Other components

- **User**
- **MetaMask**
- **MongoDB**
- **BNB Chain**
- **PancakeSwap v3**

## Connections

- User → App workflow: uses (evidence: `README.md`)
- App workflow → Login onboarding: renders (evidence: `frontend/src/App.jsx`)
- App workflow → Wallet forms: renders (evidence: `frontend/src/App.jsx`)
- App workflow → Activity view: renders (evidence: `frontend/src/App.jsx`)
- App workflow → HTTP API: requests (evidence: `frontend/src/App.jsx`)
- App workflow → Wallet client: uses (evidence: `frontend/src/App.jsx`)
- App workflow → Permission verifier: checks permissions (evidence: `frontend/src/App.jsx`)
- App workflow → MetaMask: requests signatures (evidence: `README.md`)
- Permission verifier → MetaMask: verifies transactions (evidence: `README.md`)
- HTTP API → API routes: calls
- API routes → Login and linking: authenticates (evidence: `backend/src/routes.js`)
- API routes → Account actions: dispatches actions (evidence: `backend/src/routes.js`)
- API routes → Application records: reads records (evidence: `backend/src/routes.js`)
- Login and linking → Application records: reads and writes (evidence: `backend/src/auth.js`)
- Login and linking → Chain clients: checks signatures (evidence: `backend/src/auth.js`)
- Account actions → Smart account rules: builds executions (evidence: `backend/src/wallets.js`)
- Account actions → Application records: stores actions (evidence: `backend/src/wallets.js`)
- Account actions → Quotes and swaps: executes trades (evidence: `backend/src/wallets.js`)
- Strategy runner → Trade decisions: requests decisions (evidence: `backend/src/strategy/runner.js`)
- Strategy runner → Account actions: trades for users (evidence: `backend/src/strategy/runner.js`)
- Strategy runner → Application records: loads enabled users (evidence: `backend/src/strategy/runner.js`)
- Quotes and swaps → Smart account rules: encodes calls (evidence: `backend/src/bot.js`)
- Quotes and swaps → Chain clients: submits transactions (evidence: `backend/src/bot.js`)
- Chain clients → Network and limits: configures clients (evidence: `backend/src/chain.js`)
- Chain clients → Bot key signer: creates signer (evidence: `backend/src/chain.js`)
- Application records → MongoDB: stores records (evidence: `backend/src/db.js`)
- Chain clients → BNB Chain: reads and submits (evidence: `backend/src/chain.js`)
- Quotes and swaps → PancakeSwap v3: quotes and swaps (evidence: `README.md`)
- Smart account rules → BNB Chain: enforces delegation (evidence: `README.md`)
