Skip to content

Architecture Overview

CloudBank is a decentralized prediction market platform on BNB Smart Chain (BSC). The system enables users to trade on the outcomes of real-world events using binary (YES/NO) and multi-outcome markets, with AI-powered settlement and gasless transactions.

System Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Frontend Layer                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐   │
│  │  Web App  │  │  Admin   │  │ Presale  │  │   Docs   │   │
│  │ React 19  │  │ Ant Dsn  │  │ Next.js  │  │VitePress │   │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └──────────┘   │
│       │              │              │                        │
├───────┼──────────────┼──────────────┼────────────────────────┤
│       │         Backend Layer       │                        │
│       ▼              ▼              ▼                        │
│  ┌──────────────────────────────────────┐                   │
│  │       Custodial Wallet Service       │                   │
│  │        Go + Gin + GORM + JWT         │                   │
│  │   ┌─────────┐  ┌────────────────┐    │                   │
│  │   │Orderbook│  │  Signing/Auth  │    │                   │
│  │   │ Engine  │  │  EIP-191/712   │    │                   │
│  │   └─────────┘  └────────────────┘    │                   │
│  └──────────┬───────────────────────────┘                   │
│             │                                                │
├─────────────┼────────────────────────────────────────────────┤
│             │        Smart Contract Layer                    │
│             ▼                                                │
│  ┌──────────────────────────────────────┐                   │
│  │         BSC (BNB Smart Chain)        │                   │
│  │  ┌──────────┐  ┌────────────────┐    │                   │
│  │  │ Factory  │  │  Optimistic    │    │                   │
│  │  │ Registry │  │  Controller    │    │                   │
│  │  └──────────┘  └────────────────┘    │                   │
│  │  ┌──────────┐  ┌────────────────┐    │                   │
│  │  │ Binary   │  │  Sora Oracle   │    │                   │
│  │  │  CPMM    │  │  + Adapters    │    │                   │
│  │  └──────────┘  └────────────────┘    │                   │
│  │  ┌──────────┐  ┌────────────────┐    │                   │
│  │  │  Gnosis  │  │  Verifying     │    │                   │
│  │  │   CTF    │  │  Paymaster     │    │                   │
│  │  └──────────┘  └────────────────┘    │                   │
│  └──────────────────────────────────────┘                   │
│                                                              │
├──────────────────────────────────────────────────────────────┤
│                    Indexing Layer                             │
│  ┌──────────────────────────────────────┐                   │
│  │    The Graph (Goldsky hosted)        │                   │
│  │    AssemblyScript mappings           │                   │
│  │    GraphQL API                       │                   │
│  └──────────────────────────────────────┘                   │
└──────────────────────────────────────────────────────────────┘

Technology Stack

LayerTechnologyPurpose
Smart ContractsSolidity ^0.8.19, FoundryMarket logic, AMM, oracle, paymaster
BackendGo 1.23, Gin, GORMCustodial wallet, orderbook engine, signing
FrontendReact 19, Vite, TanStackTrading UI, admin panel
PresaleNext.js 16, wagmiNode presale application
DatabaseMySQL (GORM), RedisUser data, sessions, rate limiting
IndexingThe Graph, Goldsky, AssemblyScriptOn-chain event indexing, GraphQL API
InfrastructureGitHub Actions, Cloudflare Pages, EC2CI/CD, static hosting, backend deployment
Walletwagmi, viem, EIP-191/712Wallet connection, signing
AAERC-4337, EntryPoint v0.6Account Abstraction for gasless transactions

Module Map

Data Flow

A complete trading flow from user action to settlement:

User Action                    Backend                     Blockchain
────────────                   ───────                     ──────────
1. Connect Wallet         →
2. Sign EIP-191 message   →  Verify signature
3. Receive JWT            ←  Issue JWT token
4. Place order            →  Validate + match
5. Submit transaction     →  Sign with custodial key  →  Execute on BSC
6. Confirm                ←                           ←  Tx receipt
7. Position updated       ←  Subgraph indexes event
                              ...
8. Market expires                                     →  Oracle resolves
9. AI verifies result     →  Sora Keeper proposes     →  OptimisticController
10. Settlement            ←                           ←  CTF reports payouts
11. Redeem positions      →                           →  CTF.redeemPositions

External Dependencies

DependencyPurposeIntegration
Gnosis CTFERC-1155 conditional tokensPosition minting, splitting, merging, redemption
ERC-4337 EntryPoint v0.6Account AbstractionUserOperation validation, gas sponsorship
GoldskySubgraph hostingGraphQL API for indexed on-chain data
AlchemyRPC providerBSC node access (primary)
Cloudflare PagesStatic hostingFrontend deployment