Loading video player...
š Clerk (Auth + Billing): https://go.clerk.com/sonny š Join the Zero to OpenClaw Hero waitlist š https://www.papareact.com/ztoh-form Episode 3 of our new Series 'Code with AI the Right Way' is here! ā and this time, we're vibe coding a Multi-Tenant B2B Chat Messenger App LIVE from scratch! No pre-built code, no shortcuts. You'll watch the entire process unfold in real-time as we build a full team messaging platform with Clerk Organizations, Role-Based Access Control, real-time chat, and Billing ā all powered by AI. Whether you're just starting out or leveling up, this episode shows you how to architect a true B2B multi-tenant SaaS app where every user belongs to an organization. šÆ What You'll Get From This Episode: š¢ Multi-Tenant Architecture We build a B2B-only app where every user must belong to an organization ā no personal accounts. Each workspace is completely isolated with its own members, channels, messages, and billing plan. š Clerk Organizations & Billing Watch us implement the full Clerk stack ā org creation, member invitations, org switching, role-based access (admin vs member), and billing with Free vs Pro plans using PricingTable and the Show component. š¬ Real-Time Messaging Channels, real-time chat, and message history ā all scoped per organization with proper multi-tenant data isolation. š§ What You'll Learn Along the Way: ⢠How to enforce B2B-only auth ā no personal workspaces allowed ⢠Clerk Organizations ā create, switch, invite members ⢠Onboarding flows for org creators AND invited users ⢠RBAC with has() ā gating UI and API routes by role ⢠Clerk Billing ā Free vs Pro plans with feature gating ⢠Using the Show component and PricingTable for upgrade flows ⢠Feature gates: member limits, channel limits, message history ⢠Multi-tenant data isolation ā org-scoped queries ⢠Middleware & route protection at the edge ⢠Debugging live ā because things WILL break, and that's the lesson This is a LIVE build ā mistakes, debugging, and all. That's the point. You learn more watching someone solve real problems in real-time than from a polished, pre-recorded tutorial. š£ Timestamps: 0:00:00 Intro 0:00:45 What We're Building - Multi-Tenant B2B Chat App 0:01:19 App Concept 0:03:10 Authentication with Clerk 0:04:23 Multi-Tenancy & Organizations Explained 0:08:01 Membership Options in Clerk 0:09:20 Organization Billing Setup 0:11:06 Tech Stack Overview (Clerk, Convex, Next.js 16) 0:12:24 How Organizations Work 0:15:10 IDE Choice - Cursor 0:15:52 AI Development Team Reveal 0:17:08 MCP & Skills for AI Agents 0:21:57 Project Setup with PNPM & Convex 0:24:14 Clerk + Convex Sync Layer 0:24:54 Cursor Plugins Walkthrough 0:29:41 Convex Team & Project Config 0:36:23 Choosing Frontier Model (Opus 4.6) 0:36:59 Plan Mode - Always Start Here 0:37:38 Writing the Build Prompt 0:41:45 AI Planning Session Begins 0:48:33 Reviewing the AI Plan 0:55:28 Environment Variables in Convex 0:56:18 Permissions in Clerk Dashboard 0:63:05 Enabling Billing in Clerk 1:04:33 Plans & Features (Free vs Pro) 1:06:56 Webhook Endpoint Setup 1:13:56 Creating First Organization 1:17:00 Second User Testing 1:19:18 Permission Testing 1:25:26 Stripe Test Card Flow 1:27:10 Channel Creation Testing 1:35:44 UI Redesign Phase 1:38:03 Design Direction 1:43:57 Executing the Build Plan 1:45:21 Clerk Pricing Breakdown 1:48:04 Adding Threads, Reactions & Images 1:52:20 Plan Mode Token Savings 2:00:39 Sanity Checks When Vibe Coding 2:09:34 Testing Real-Time Messaging 2:15:53 Never Use "any" in TypeScript 2:20:22 Clerk Dashboard - Orgs & Revenue 2:30:42 Deploying to Vercel 2:33:30 Separating Dev & Prod Databases 2:41:40 Production Webhook Config 2:45:59 When AI Breaks Your UI 2:50:19 Cross-Org Security Testing 2:54:17 Organization-Scoped Access Control 2:57:29 Refactoring Plan Overview 3:04:03 Always Question AI-Generated Code 3:09:36 Manual Code Review Session 3:20:13 Org Isolation Final Test 3:32:56 Final Summary 3:39:09 Outro āāā š Want to become an AI Next-gen developer? Check out my course & community here: https://www.papareact.com/course Learn to vibe code the RIGHT way with Cursor and AI ā build real-world SaaS apps from scratch, join thousands of developers in the community, and land your dream job. āāāš± Follow me across socials: Twitter/X: https://x.com/sonnysangha Instagram: https://instagram.com/sonnysangha LinkedIn: https://linkedin.com/in/sonnysangha TikTok: https://tiktok.com/@sonnysangha Discord: https://discord.gg/papafam DISCLAIMER: This video is sponsored by Clerk. This video is made for informational and educational purposes only. Copyright Disclaimer under section 107 of the Copyright Act 1976, allowance is made for "fair use" of this video for education purposes.