Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.wizpay.xyz/llms.txt

Use this file to discover all available pages before exploring further.

System Architecture

WizPay is a monorepo containing a NestJS backend, a Next.js frontend, and shared contract artifacts. All payment logic — validation, queuing, execution, settlement — lives in the backend.

Component Topology

┌─────────────────────────────────────────────────────────────────────┐
│                          Frontend (Next.js)                        │
│  Composes payloads · Polls task status · Manages wallet sessions   │
└────────────────────────────┬────────────────────────────────────────┘
                             │ HTTP
┌────────────────────────────▼────────────────────────────────────────┐
│                     TaskController (/tasks/*)                       │
├─────────────────────────────────────────────────────────────────────┤
│                       OrchestratorService                           │
│  handleTask() ─── creates task, enqueues to BullMQ                 │
│  executeTask() ── called by workers, routes to agent               │
├──────────────┬──────────────┬───────────────────────────────────────┤
│  TaskService │ QueueService │ ExecutionRouterService                │
│  (state)     │ (enqueue)    │ (W3S vs PASSKEY dispatch)            │
├──────────────┴──────┬───────┴───────────────────────────────────────┤
│                     │ BullMQ (Redis)                                │
│    ┌────────────────▼─────────────────┐                            │
│    │ Workers (payroll/swap/bridge/    │                            │
│    │          tx_poll)                │                            │
│    └────────────────┬─────────────────┘                            │
│                     │                                              │
│    ┌────────────────▼─────────────────┐                            │
│    │ Agents                           │                            │
│    │ PayrollAgent · BridgeAgent       │                            │
│    │ SwapAgent · FxAgent · Liquidity  │                            │
│    └────────────────┬─────────────────┘                            │
│                     │                                              │
│    ┌────────────────▼─────────────────┐                            │
│    │ Adapters                         │                            │
│    │ CircleService · BlockchainSvc    │                            │
│    │ SolanaService · DexService       │                            │
│    │ CircleBridgeService              │                            │
│    └──────────────────────────────────┘                            │
├─────────────────────────────────────────────────────────────────────┤
│                    PostgreSQL (Prisma ORM)                          │
│  Task · TaskUnit · TaskTransaction · TaskLog                       │
└─────────────────────────────────────────────────────────────────────┘

Component Responsibilities

Frontend (Next.js)

  • Composes payment payloads from user input
  • Calls backend HTTP endpoints to create tasks
  • Polls GET /tasks/:id for progress and renders status
  • Manages wallet sessions (W3S userToken / passkey)
  • In PASSKEY mode: signs and broadcasts transactions client-side
The frontend never constructs raw blockchain transactions in W3S mode, calls Circle APIs directly, or manages task state.

Orchestrator

  • OrchestratorService.handleTask() — HTTP entry point. Creates task, sets status to assigned, enqueues to BullMQ.
  • OrchestratorService.executeTask() — Worker entry point. Idempotency guard → status to in_progress → route to agent → finalize.
  • Bridge payload normalization and validation happen here.

Task Module

ServiceResponsibility
TaskServiceCRUD facade, status transitions, delegation to sub-services
TaskUnitServiceUnit reporting, task status recomputation
TaskTransactionServiceTransaction record CRUD, terminal-state aggregation
TaskLogServiceAppend-only audit log, duplicate step detection
TaskMapperServicePrisma model → domain object mapping

Execution Layer

  • ExecutionRouterService — Reads walletMode from task payload. Routes to AgentRouterService (W3S) or PasskeyEngineService (PASSKEY).
  • PasskeyEngineService — Handles bridge intents, EVM payroll via treasury key, Solana unsigned intents, swap preparation.

Agents

Each agent implements the TaskAgent interface:
interface TaskAgent {
  execute(task: TaskDetails): Promise<AgentExecutionResult>;
}
AgentOperationSettlement
PayrollAgentBatch ERC-20/SPL transfers via CircleAsync (tx_poll)
BridgeAgentCCTP burn+mint via Circle Bridge KitSync
SwapAgentToken swapSync
FxAgentUSDC ↔ EURC trade via Circle, polls until settledSync
LiquidityAgentAdd/remove liquiditySync

Adapters

AdapterTargetProtocol
CircleServiceCircle W3S APIREST (wallets, transfers, FX trades)
CircleBridgeServiceCircle CCTP Bridge KitSDK
BlockchainServiceEVM chainsviem (ARC-TESTNET, ETH-SEPOLIA)
SolanaServiceSolana@solana/web3.js (SOLANA-DEVNET)
DexServiceDEX protocolsChain-agnostic swap prep

Queue

QueueWorkerConcurrencyPurpose
payrollPayrollWorker5Payroll batch execution
swapSwapWorker1Swap, FX, Liquidity
bridgeBridgeWorker1CCTP bridge execution
tx_pollTxPollWorker1Transaction status polling

Trust Boundaries

┌──────────────────────────────────────────────────┐
│ UNTRUSTED                                        │
│  Frontend (user input, wallet sessions)          │
├──────────────────────────────────────────────────┤
│ TRUSTED (backend perimeter)                      │
│  TaskController — validates via class-validator   │
│  OrchestratorService — enforces state machine     │
│  Agents — execute with backend credentials        │
├──────────────────────────────────────────────────┤
│ EXTERNAL (third-party)                           │
│  Circle API — wallet ops, transfers, bridges     │
│  EVM RPCs — transaction submission               │
│  Solana RPC — transaction submission             │
└──────────────────────────────────────────────────┘
  • All user input crosses the trust boundary at TaskController and is validated before reaching the orchestrator.
  • Backend signing keys (Circle entity secret, BACKEND_PRIVATE_KEY) never leave the backend process.
  • In PASSKEY mode, the backend has no signing authority over the user’s wallet. The trust model shifts — the backend produces unsigned intents, the client signs.

Infrastructure

ComponentTechnologyDeployment
BackendNestJSDocker container
FrontendNext.jsDocker container
DatabasePostgreSQLDocker container
QueueRedisDocker container
Reverse ProxyNginxRoutes /api → backend, / → frontend
OrchestrationDocker ComposeAll services in docker-compose.yml