# Technical architecture

## Infrastructure Overview

{% code fullWidth="true" expandable="true" %}

```
┌─────────────────────────────────────────────────────────────┐ │ Frontend │ │ React + Vite + TailwindCSS │ └─────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ Lovable Cloud │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Database │ │ Edge Functions│ │ Storage │ │ │ │ PostgreSQL │ │ Deno │ │ Files │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ └─────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ Solana Network │ │ Fast, low-cost blockchain transactions │ └─────────────────────────────────────────────────────────────┘
```

{% endcode %}

## Technology Stack

| Layer     | Technology                            |
| --------- | ------------------------------------- |
| Frontend  | React 18, TypeScript, Vite            |
| Styling   | TailwindCSS, shadcn/ui                |
| State     | TanStack Query, Zustand               |
| Backend   | Supabase (PostgreSQL, Edge Functions) |
| Auth      | Supabase Auth + Wallet Adapter        |
| Payments  | Solana Web3.js, Phantom SDK           |
| Streaming | HLS.js, native video                  |

## Edge Functions

Serverless backend functions for:

| Function                | Purpose                      |
| ----------------------- | ---------------------------- |
| `check-premium-access`  | Verify content access rights |
| `verify-donation`       | Validate on-chain donations  |
| `process-bounty-reward` | Handle bounty payouts        |
| `verify-share`          | Validate social shares       |
| `youtube-import`        | Fetch YouTube metadata       |
| `social-preview`        | Generate OG meta tags        |
| `support-chat`          | AI assistant backend         |

## Database Schema

Key tables:

* `profiles` - User accounts and metadata
* `wutch_videos` - Video content
* `short_videos` - Short-form content
* `livestreams` - Live streaming data
* `x402_purchases` - Premium content purchases
* `donations` - Tip transactions
* `sharing_campaigns` - Share & Earn campaigns
* `stream_bounties` - Bounty configurations

## Security Features

* Row Level Security (RLS) on all tables
* JWT authentication
* Wallet signature verification
* Rate limiting
* Input validation
* CORS protection

## Solana Integration

| Component        | Description                     |
| ---------------- | ------------------------------- |
| **RPC**          | Helius for reliable node access |
| **Escrow**       | Platform wallet for payouts     |
| **Verification** | On-chain transaction validation |
| **Signatures**   | Cryptographic proof of payments |
