Docs/Architecture

Architecture

A high-level overview of the CoinRewards system architecture.

System Overview

┌─────────────────────────────────────────────────────────────┐
│                       COINREWARDS.FUN                       │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌─────────────┐     ┌─────────────┐     ┌─────────────┐   │
│  │   Website   │     │  X Bot      │     │  TG Bot     │   │
│  │  (Next.js)  │     │             │     │             │   │
│  └──────┬──────┘     └──────┬──────┘     └──────┬──────┘   │
│         │                   │                   │           │
│         └───────────────────┼───────────────────┘           │
│                             │                               │
│                    ┌────────┴────────┐                      │
│                    │   Event System  │                      │
│                    │  (lib/events)   │                      │
│                    └────────┬────────┘                      │
│                             │                               │
│         ┌───────────────────┼───────────────────┐           │
│         │                   │                   │           │
│  ┌──────┴──────┐    ┌──────┴──────┐    ┌──────┴──────┐    │
│  │  Supabase   │    │   Helius    │    │   Phala     │    │
│  │  (Storage)  │    │ (Webhooks)  │    │   (TEE)     │    │
│  └─────────────┘    └─────────────┘    └─────────────┘    │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Components

Website (Next.js)

The Dopamine Gallery frontend. Displays tokens, real-time events, and reward projections. Deployed on Vercel.

X Bot

Posts milestone announcements to Twitter/X when tokens hit significant thresholds. Rate-limited by tier.

Telegram Bot

Developer CLI interface for vault management. Commands: /status, /vault, /verify, /payout.

Event System

Central event bus for real-time updates. Powers the live feed via Server-Sent Events.

Supabase (Storage)

PostgreSQL database for persisting events, milestones, tokens, and payout history.

Helius (Webhooks)

Solana infrastructure provider. Delivers real-time transaction webhooks when deposits arrive at the vault.

Phala (TEE)

Trusted Execution Environment for secure vault key management. Proves no human can access the private key.

Data Flow

  1. 1User trades a token on pump.fun
  2. 2Creator fee (1%) is sent to CoinRewards vault
  3. 3Helius detects the transfer and sends webhook
  4. 4Webhook handler processes and stores the event
  5. 5Event system broadcasts to connected clients
  6. 6Website updates in real-time
  7. 7Milestone checker triggers X bot if threshold reached
  8. 8Daily cron job calculates and distributes rewards