HUNCH Architecture Documentation

System Overview

HUNCH is a decentralized prediction markets platform built with a modern web3 architecture that combines frontend React application, Supabase backend services, and Ethereum smart contracts.

High-Level Architecture

graph TB
    subgraph "User Layer"
        U1[Web Users]
        U2[Mobile Users]
        U3[API Users]
    end
    
    subgraph "Frontend Layer"
        FE[React Frontend]
        WC[Web3 Connectors]
        UI[UI Components]
    end
    
    subgraph "Backend Layer"
        SB[Supabase]
        DB[(PostgreSQL)]
        EF[Edge Functions]
        RT[Realtime]
    end
    
    subgraph "Blockchain Layer"
        SC[Smart Contracts]
        ETH[Ethereum Network]
        POL[Polygon Network]
    end
    
    subgraph "External Services"
        WCP[WalletConnect]
        IF[Infura/Alchemy]
        OR[Oracle Services]
    end
    
    U1 --> FE
    U2 --> FE
    U3 --> SB
    
    FE --> WC
    FE --> UI
    FE --> SB
    
    WC --> SC
    SC --> ETH
    SC --> POL
    
    SB --> DB
    SB --> EF
    SB --> RT
    
    WC --> WCP
    SC --> IF
    EF --> OR

Component Architecture

Frontend Architecture

Smart Contract Architecture

Data Flow Architecture

Trading Flow

Market Creation Flow

Database Schema

Core Tables

Network Architecture

Supported Networks

Security Architecture

Access Control

Security Layers

Performance Architecture

Caching Strategy

Load Balancing

Scalability Architecture

Horizontal Scaling

Monitoring Architecture

Observability Stack

Deployment Architecture

Multi-Environment Setup

Integration Architecture

External Service Integration

This architecture documentation provides a comprehensive view of HUNCH's system design, showing how all components work together to create a scalable, secure, and performant prediction markets platform.

Last updated