# Platform Digital — Complete Technical Reference > Ship your agentic platform in weeks, not years. 150k+ lines of production-ready TypeScript for building AI-powered development platforms like Lovable, Replit, Bolt, and v0. ## Overview Platform Digital is a production-ready boilerplate for building agentic development platforms. It provides the complete infrastructure needed to launch a platform where users describe what they want, and AI builds it — with live preview, real-time collaboration, and one-click deployment. Building this from scratch takes 12-18 months and $300k+ in engineering. Platform Digital delivers it as a one-time purchase with full source code ownership. ## Codebase Statistics | Metric | Count | |--------|-------| | Total lines of TypeScript | 150,000+ | | API endpoints | 90 | | React components | 151 | | Database models | 24 | | Zustand state stores | 18 | | Custom hooks | 34 | | AI modes | 5 | | Test files | 20 | | Cron jobs | 3 | ## Tech Stack | Category | Technology | |----------|-----------| | Frontend Framework | Next.js (App Router), React 19, TypeScript | | Database | PostgreSQL (Neon recommended with Prisma Accelerate) | | ORM | Prisma with adapters (Neon, PostgreSQL) | | Authentication | Clerk (OAuth, SSO, 2FA) | | AI Providers | Claude Agent SDK, OpenAI, Cerebras | | Real-time Sync | Liveblocks (WebSocket-based) | | Sandbox | WebContainer API | | Payments | Stripe with webhooks | | Rate Limiting | Upstash Redis | | Monitoring | Sentry with source maps | | Styling | Tailwind CSS, Framer Motion | | State Management | Zustand (18 stores) | | Testing | Vitest, React Testing Library, MSW | | Deployment | Vercel (with cron jobs, Edge functions) | ## Core Systems ### AI Generation Pipeline 5 AI modes for different use cases: - **Default**: Standard agentic code generation with full context - **Quick Edit**: Fast, targeted modifications to existing code - **Explore**: Research and analysis mode for understanding codebases - **Plan**: Structured planning before code generation - **Ultrathink**: Deep reasoning for complex architectural decisions The pipeline follows a Research → Plan → Generate → Validate → Review → Fix workflow with streaming responses and checkpoint-based state recovery. ### Multi-Model AI Orchestration Supports three AI providers simultaneously: - **Claude Agent SDK**: Primary agent for code generation with tool use - **OpenAI**: Code review system and fallback generation - **Cerebras (Llama 3.3-70B)**: Ultra-fast consensus validation Models can be swapped, combined, or extended. The architecture supports adding new providers with minimal code changes. ### Checkpoint-Based Credit System Solves the fairness problem of charging for AI generations: 1. Credits are reserved upfront based on estimated token usage 2. GenerationCheckpoint records state every N files (default 5) 3. On success: actual cost is confirmed, balance is deducted 4. On failure: reserved credits are automatically refunded 5. Status fields prevent race conditions in concurrent requests Includes: - CreditBalance tracking (current balance, lifetime totals) - CreditTransaction ledger (PURCHASE, USAGE, REFUND, BONUS, ADJUSTMENT) - GenerationSession tracking (reserved, confirmed, final credits) - UsageRecord for detailed per-operation cost logging - Credit reconciliation cron job to detect and fix drift - Circuit breaker: per-hour cost limits ($10/hour default) ### CRDT File Synchronization Production-grade multi-client file editing: - Vector clocks on ProductFile entries for ordering - FileOperation tracks all edits with sequence numbers - Tombstone pattern for soft deletes (preserves history) - Supports multi-client sync without conflicts - Real-time bridging between WebContainer and Liveblocks ### Browser-Based Sandbox (WebContainer) Full browser-based development environment: - Live preview with complete file system access - DOM tagging: semantic tagging of UI elements for AI interaction - Browser automation: injected script for AI to click/type (HMR-aware) - Console capture: logs errors for AI debugging - Screenshot generation via Puppeteer - Template snapshot (~124MB pre-built environment, cached per browser) ### DOM Selection System Users click any element in the live preview, and the AI understands exactly what they mean: - Semantic DOM tagging for element identification - Visual highlighting of selected elements - Context extraction for AI prompts - No need to describe locations in text ### 7-Phase Specification Engine Structured planning before any code is written: 1. Vision definition 2. Audience analysis 3. User journey mapping 4. UX/UI layout design 5. Data modeling 6. Tech foundation decisions 7. Constraints and quality standards Includes auto-task generation that converts PRD build scope into actionable project tasks, and mockup generation via Replicate. ### Distributed Rate Limiting Production-grade abuse prevention via Upstash Redis: - Per-user daily generation limits (1000 default) - Per-project hourly generation limits (100 default) - Cost-based circuit breaker ($10/hour default) - Project creation throttling (10/hour) - Leaky bucket algorithm for smooth rate control ### Encrypted Secrets Vault Enterprise-grade API key management: - Per-project encrypted storage (AES) - Encryption key from environment variable - Never committed to GitHub sync - Never exposed to client bundles - User-provided OAuth tokens stored securely ## API Endpoints (90 Total) ### Products (18 endpoints) Create, read, update, delete products. Deploy to Vercel. Take screenshots via Puppeteer. Manage encrypted secrets. Sync with GitHub (two-way). Provision Supabase backends. Connect WebContainer. Create version snapshots. Stream generation status via SSE. Execute commands. ### Plans & Specification (11 endpoints) Create, read, update, delete plans. Convert plans to products. Generate 7 specification phases. Advance phase transitions. Extract session memory for context. ### Projects & Tasks (12 endpoints) Create and manage projects. CRUD for tasks with parent-child hierarchy. Regenerate failed tasks. Drag-and-drop task reordering. Activity feed tracking. Customer brief management. Link and complete plans. ### Conversations (6 endpoints) Create and list conversations. Access and update conversation state. Create and edit messages with role-based access (user, assistant, system). ### Payments & Credits (8 endpoints) Check credit balance. Calculate pricing. View usage analytics. Process Stripe webhooks. Admin usage dashboard. Admin credit grants. ### User & Auth (10 endpoints) User preference management. Clerk webhook sync. Guest-to-user conversion. Anonymous session management. Session warmup. Health checks. CSP violation logging. ### Admin & System (10 endpoints) Analytics dashboard. Data cleanup. Guest session expiry (cron). Stale generation cleanup (cron). Credit reconciliation (cron). System metrics. WebContainer snapshot serving. ### Collaboration & Sharing (7 endpoints) Liveblocks authentication tokens. Public share links. In-app support chat. Customer analytics. AI suggestions. ## Database Schema (24 Models) ### User Management - **User**: Clerk integration, GitHub/Supabase OAuth, onboarding state, preferences, admin flags - **GuestSession**: Anonymous visitors with IP/fingerprint tracking, behavioral flags, 30-day expiry ### Products - **Product**: Name, deployment status, file storage, secrets vault, GitHub/Supabase sync, custom knowledge - **ProductFile**: Virtual file system with tombstones for soft deletes, vector clocks for CRDT - **ProductSnapshot**: Versioned snapshots with GitHub commit metadata - **ProductReview**: Code review results with pass/fail scores and fix instructions ### Projects - **Project**: Plan-to-Product lifecycle wrapper with embedded specification data - **Plan**: Standalone PRD with 7-phase specification and session memory - **ProjectTask**: Auto-generated from Plans, parent-child hierarchy, status workflow - **ProjectActivity**: Activity feed tracking all project events with actor metadata - **ProjectBrief**: Per-project customer context (reason, objectives, learnings) ### Conversations - **Conversation**: Multi-turn chat per product with status tracking - **Message**: Role-based messages (user/assistant/system) with attachments - **SupportSession**: In-app support chat with batched credit tracking - **SupportMessage**: Individual support messages with code filtering ### Credits & Billing - **CreditBalance**: Current balance, lifetime totals - **CreditTransaction**: Individual transactions (PURCHASE, USAGE, REFUND, BONUS, ADJUSTMENT) - **GenerationSession**: Checkpoint-based tracking (reserved, confirmed, final credits) - **GenerationCheckpoint**: Per-checkpoint credit snapshots during generation - **UsageRecord**: Detailed per-operation cost logging (tokens, provider, duration) ### Infrastructure - **Customer**: Reusable customer profile (name, industry, vision, challenges, insights) - **Folder**: User-created folders for organizing products - **FileOperation**: CRDT vector clocks for distributed file sync - **SystemAsset**: Binary storage for WebContainer snapshots ## Real-Time Collaboration Powered by Liveblocks: - Multi-user presence and cursor awareness - Agent context sharing with summarized state - File sync bridging between WebContainer and collaboration layer - Conflict-free data synchronization ## Deployment Pipeline - **Vercel one-click deploy**: Deploy user projects to *.yourapp.example subdomains - **GitHub two-way sync**: Auto-push generated code, pull external changes - **Supabase integration**: OAuth-based backend provisioning - **Deployment status tracking**: NONE → PENDING → BUILDING → DEPLOYED → FAILED ## Guest Mode & Onboarding - Anonymous trial access with temporary guest users - Guest-to-user conversion with credit migration - Multi-step guided onboarding flow - Behavioral tracking for spam detection (session count, IP, fingerprint) ## Code Review System - Multi-dimensional review: Security, Performance, Accessibility, UX, DX - Auto-fix generation and application - Configurable review iterations (default 3) - Non-blocking async review flow ## Security - Clerk authentication with SSO and 2FA - Content Security Policy with violation reporting - Encrypted secrets vault (AES, per-project) - Distributed rate limiting (Upstash Redis) - Strict CSP headers with WebContainer WASM exceptions - Secrets never leaked to GitHub sync or client bundles ## Monitoring & Observability - Sentry error tracking (client, server, edge) - Source map uploads for readable stack traces - Structured logging with severity levels - System metrics endpoint - Usage analytics dashboard ## Testing - Vitest with jsdom environment - React Testing Library for component tests - MSW for API mocking - V8 coverage provider with HTML reports - 20 test files covering stores, hooks, API routes ## CI/CD - GitHub Actions deployment workflow - Vercel automatic deployments on push to main - Preview deployments per PR - 3 Vercel cron jobs: - Stale generation cleanup (every 5 min) - Guest session expiry (every 30 min) - Credit reconciliation (every 5 min) ## Use Cases ### Launch a SaaS Skip the first 18 months of infrastructure. Go straight to the product that matters. All the billing, auth, AI orchestration, and deployment infrastructure is ready. ### Internal Dev Platform Give your engineering team an AI-powered builder without building the builder. Full sandbox environment, code generation, and deployment pipeline included. ### Catch Up to Competition Competitors have a year-long head start. You have their entire stack — ready to fork. DOM selection, planning mode, live preview — the features users expect. ### Agency White-Label Reskin it, rebrand it, ship it to clients. One purchase, unlimited projects. Full source code ownership means complete control over branding and features. ### AI Coding Workflows Code generation, agentic pipelines, sandboxed execution — the plumbing is done. Add your own models, tune prompts, extend the workflow. ### Design-to-Code Tools Visual editing, live preview, DOM selection — ship the creative workflow your users want. WebContainer sandbox provides a complete browser-based IDE. ## Purchase - $199 (30% off, normally $285) - One-time payment, no subscription - Full source code ownership - Instant access after purchase - No vendor lock-in, no attribution required - Deploy anywhere: your cloud, your data center, air-gapped if needed Purchase: https://shop.platform-digital.com/b/eVqbJ1eU5bMW8Dn0wHfQI03 Website: https://www.platform-digital.com Documentation: https://www.platform-digital.com/docs