<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajae</title>
    <description>The latest articles on DEV Community by Rajae (@rajae_50b20d691ae7bb48d11).</description>
    <link>https://dev.to/rajae_50b20d691ae7bb48d11</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3896717%2F615b9e2b-7deb-48bf-9210-d89fccf48186.png</url>
      <title>DEV Community: Rajae</title>
      <link>https://dev.to/rajae_50b20d691ae7bb48d11</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajae_50b20d691ae7bb48d11"/>
    <language>en</language>
    <item>
      <title>Building C24 Club: The Architecture Behind a Rewards-Powered Video Chat Platform!</title>
      <dc:creator>Rajae</dc:creator>
      <pubDate>Fri, 24 Apr 2026 21:53:07 +0000</pubDate>
      <link>https://dev.to/rajae_50b20d691ae7bb48d11/building-c24-club-the-architecture-behind-a-rewards-powered-video-chat-platform-52mh</link>
      <guid>https://dev.to/rajae_50b20d691ae7bb48d11/building-c24-club-the-architecture-behind-a-rewards-powered-video-chat-platform-52mh</guid>
      <description>&lt;p&gt;Random video chat looks simple from the outside!&lt;/p&gt;

&lt;p&gt;click a button, meet a stranger. But the moment you add a live rewards economy, gender-aware matchmaking, AI moderation, and a global concurrent user base**, the engineering challenge becomes very different from a basic Omegle clone.&lt;/p&gt;

&lt;p&gt;In this post, we walk through the high-level architecture powering C24 Club a browser-based video chat platform where users earn real, redeemable rewards for every minute they spend connecting with strangers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqogoyvhztk4felfxt7of.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqogoyvhztk4felfxt7of.jpg" alt="c24club logo" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is C24 Club?
&lt;/h2&gt;

&lt;p&gt;C24 Club is a browser-based random video chat platform with one major twist: every minute you talk earns reward minutes that can be redeemed for gift cards, designer products, and PayPal cash.&lt;/p&gt;

&lt;p&gt;The platform is built around four pillars:&lt;/p&gt;

&lt;p&gt;⚡ Sub-second matchmaking during scheduled call windows&lt;br&gt;
🔒 End-to-end encrypted P2P video (DTLS-SRTP, no server in the media path)&lt;br&gt;
💰 A real-time rewards economy with atomic earning, gifting, and cash-out&lt;br&gt;
🛡️ Client-side AI moderation that protects users without storing video&lt;/p&gt;

&lt;h2&gt;
  
  
  High-Level Architecture
&lt;/h2&gt;

&lt;p&gt;C24 Club follows a serverless-first, edge-native architecture. Instead of running long-lived Node servers, almost every backend operation is a Supabase Edge Function (Deno) deployed close to the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Design Principles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Serverless edge compute no idle infrastructure costs&lt;/li&gt;
&lt;li&gt;Database as the source of truth Postgres + RLS replaces a custom auth layer&lt;/li&gt;
&lt;li&gt;Polling over WebSockets for matchmaking reliability (more on this below)&lt;/li&gt;
&lt;li&gt;Peer-to-Peer (P2P) media backend never touches video or audio&lt;/li&gt;
&lt;li&gt;Atomic database functions for any value-changing operation (earnings, gifts, cash-out)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tech Stack Breakdown
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1️⃣ Frontend: React + Vite, Built for Speed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The entire user-facing app is a single-page React application optimized for the video call hot path.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React 18 + Vite 5 + TypeScript 5 instant HMR in dev, tiny production bundles&lt;/li&gt;
&lt;li&gt;Tailwind CSS + shadcn/ui semantic design tokens (HSL-based) drive consistent theming across light/dark&lt;/li&gt;
&lt;li&gt;TanStack Query caching layer that keeps Discover feeds, leaderboards, and minute balances fresh without hammering the database&lt;/li&gt;
&lt;li&gt;React Router preserves the active WebRTC connection across navigation to Reward Store, Profile, and Discover (a critical UX requirement — leaving the page would drop the call)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Client-Side Intelligence
&lt;/h2&gt;

&lt;p&gt;We do as much work in the browser as possible to protect privacy and reduce server cost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NSFWJS runs locally on remote video frames with a 0.75 nudity threshold to flag policy violations no video ever leaves the peer connection.&lt;/li&gt;
&lt;li&gt;Black-screen detection runs locally to prevent users from gaming the rewards system.&lt;/li&gt;
&lt;li&gt;Pre-blur shield hides the partner feed for the first second of every match, preventing flash exposures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2️⃣ Backend: Lightweight Edge Signaling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our backend never touches a single video frame. Its job is coordination, persistence, and money.&lt;/p&gt;

&lt;p&gt;Supabase Edge Functions (Deno)&lt;/p&gt;

&lt;p&gt;We have ~70 edge functions handling everything from videocall-match (the matchmaking brain) to gift-minutes (Stripe-backed gifting) to nsfw-ban (automatic enforcement). Each function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Boots cold in &amp;lt;100 ms&lt;/li&gt;
&lt;li&gt;Reads only the secrets it needs&lt;/li&gt;
&lt;li&gt;Authenticates via Supabase JWT&lt;/li&gt;
&lt;li&gt;Returns in well under 1 second for the user-facing hot paths.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;PostgreSQL + Row-Level Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Postgres is the single source of truth. RLS policies enforce per-user access at the database layer, so the frontend can query directly without a custom API server in front.&lt;/p&gt;

&lt;p&gt;Sensitive operations incrementing minutes, claiming rewards, processing wagers are wrapped in atomic SQL functions (atomic_increment_minutes, redeem_reward_atomic) to prevent race conditions and double-spends.&lt;/p&gt;

&lt;p&gt;Storage &amp;amp; Auth&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supabase Storage for profile selfies, gift card images, and challenge proof screenshots (all behind RLS)&lt;/li&gt;
&lt;li&gt;Supabase Auth with Google, Apple, and email/password — JWT sessions shared across the app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3️⃣ Real-Time Layer: Why We Chose Polling Over WebSockets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the most counter-intuitive decision in our stack. We originally built matchmaking on Supabase Realtime (WebSockets), but at concurrency we hit reliability issues silent disconnects, missed events, ghost matches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4️⃣ Video: Pure P2P with WebRTC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once two users are matched, the backend steps out of the way entirely.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebRTC offer/answer exchanged through a single Edge Function (videocall-match)&lt;/li&gt;
&lt;li&gt;ICE candidates trickled through the same channel&lt;/li&gt;
&lt;li&gt;Mandatory DTLS-SRTP encryption neither C24 Club nor any ISP can decrypt the stream&lt;/li&gt;
&lt;li&gt;Specific role enforcement: in random match the queue-joiner is always Offerer, the queue-finder is always Answerer (this single rule eliminated the vast majority of our connection failures)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How a Match Happens (End-to-End)
&lt;/h2&gt;

&lt;p&gt;Here is what actually happens when a user clicks START:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1️⃣ Pre-flight (client)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selfie gate verifies the user has uploaded a Discover photo&lt;/li&gt;
&lt;li&gt;Camera permission is requested&lt;/li&gt;
&lt;li&gt;Local NSFW model and black-screen detector spin up&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2️⃣ Queue join (edge)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;videocall-match inserts the user into the matchmaking queue with their gender and preferences&lt;/li&gt;
&lt;li&gt;Atomic DB function returns the partner row if a complementary peer is already waiting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3️⃣ Signaling (edge)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Both clients receive each other's user IDs&lt;/li&gt;
&lt;li&gt;Offerer creates SDP offer → POSTed to Edge Function → delivered to Answerer via short-poll&lt;/li&gt;
&lt;li&gt;Answer + ICE candidates flow back through the same channel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4️⃣ P2P established&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebRTC connection upgrades to direct browser-to-browser&lt;/li&gt;
&lt;li&gt;Backend has zero involvement in audio/video from this point&lt;/li&gt;
&lt;li&gt;Local moderation models begin scanning the remote stream&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5️⃣ Earning loop&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every full minute, client calls atomic_increment_minutes RPC&lt;/li&gt;
&lt;li&gt;Server-side function validates session integrity and awards minutes (with female bonus rates, VIP multipliers, Power Hour boosts, and freeze-state checks all applied atomically)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6️⃣ Disconnect &amp;amp; re-queue&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User clicks NEXT → P2P torn down → user re-enters queue in &amp;lt;500 ms&lt;/li&gt;
&lt;li&gt;Skip-penalty rule deducts 2 minutes if a non-VIP user skips inside 5 seconds (prevents farming).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Rewards Economy
&lt;/h2&gt;

&lt;p&gt;This is the part most random-chat clones don't have, and it's where the architecture gets interesting.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calling minutes vs. gifted minutes decoupled balances so receiving a gift can't be cashed out without earning your own minutes too&lt;/li&gt;
&lt;li&gt;Gift checkout via Stripe opens in a new tab so the live call stays connected&lt;/li&gt;
&lt;li&gt;Atomic redemption redeem_reward_atomic deducts minutes and creates the redemption row in a single transaction; out-of-stock items trigger automatic refunds&lt;/li&gt;
&lt;li&gt;Anchor program  female users earn cash payouts on top of minutes, settled via PayPal through anchor-earning and cashout-minutes&lt;/li&gt;
&lt;li&gt;Lucky Spin &amp;amp; Wage micro-games funded by a configurable daily cap, with prize weighting handled by a Postgres function for verifiable fairness.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cost Optimization at Edge Scale
&lt;/h2&gt;

&lt;p&gt;Running serverless can get expensive fast if you're not careful. Two architectural choices keep our cloud bill flat as we grow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Polling intervals are tuned per surface, not global DM badges every 10 s is fine; matchmaking needs 1 s&lt;/li&gt;
&lt;li&gt;Edge Functions for hot writes only read-heavy queries (Discover feed, leaderboard) hit Postgres directly with RLS, bypassing the function layer entirely&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Privacy &amp;amp; Safety by Design
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No video storage. Ever. Streams are P2P-encrypted; we couldn't store them if we tried&lt;/li&gt;
&lt;li&gt;Client-side moderation NSFWJS runs in the user's browser, only flags (not frames) reach the server&lt;/li&gt;
&lt;li&gt;IP-based ban enforcement at the database level bans take effect on the next request&lt;/li&gt;
&lt;li&gt;CSAE compliance dedicated reporting flow, automatic underage ban with appeal path&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;C24 Club's architecture is the product of a deliberate trade-off: boring, reliable infrastructure for the parts that matter (money, matchmaking, moderation) combined with bleeding-edge browser tech for the parts users feel (P2P video, instant matching, on-device AI).&lt;/p&gt;

&lt;p&gt;If you're building a real-time platform with money attached gifts, payouts, in-app economies the lessons we'd repeat are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use atomic database functions for every value-changing path&lt;/li&gt;
&lt;li&gt;Pick polling over realtime sockets when reliability beats latency&lt;/li&gt;
&lt;li&gt;Never put your backend in the media path&lt;/li&gt;
&lt;li&gt;Run moderation on the client and trust the database, not the network&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Try the platform: &lt;a href="https://c24club.com" rel="noopener noreferrer"&gt;c24club&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 Questions about the stack? Drop them in the comments we love nerding out about edge-native architecture.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>react</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
