How get-convex/convex-demos works
Project Type & Purpose
• This is a monorepo of standalone demo applications (“Convex Demos”) illustrating how to build full-stack web apps using Convex as a serverless backend.
• Each demo directory (e.g., args-validation, file-storage, nextjs-app-router, etc.) is a self-contained full-stack project comprised of:
• A frontend (React + Vite or Next.js)
• A backend “convex” folder containing serverless functions, schema definitions, and generated API bindings
High-Level File Structure Patterns
For each demo folder (except Next.js apps which follow the Next.js convention):
• index.html – entry point for Vite
• package.json, tsconfig.json, vite.config.mts – build & tooling
• src/ – React application code (App.tsx, main.tsx, CSS, hooks)
• convex/ – backend code
– schema.ts, messages.ts – data model & subscriptions
– *.ts/.js files implementing serverless functions
– _generated/ – code-generated API & dataModel bindings
For Next.js demos:
• app/ or pages/ – Next.js routes & components
• convex/ – same structure as above
• next.config.js, tsconfig.json, package.json
Core Architectural Components
A. Frontend Client
– React/Vite or Next.js application
– UI components binding to reactive Convex hooks or fetch calls
B. Convex Serverless Backend
– Convex functions (queries, mutations, cron jobs, auth hooks, etc.)
– Schema + messages defining data model & real-time update channels
– Generated API layer ( _generated/api.js/d.ts )
C. Convex Database & Real-Time Sync
– Automatic storage & caching managed by Convex
– WebSocket or HTTP transport for live updates
D. Build & Deployment
– Vite bundler or Next.js build
– Convex CLI / serverless deploy pipelines (not shown but implied)
Relationships & Interactions
• The Frontend calls generated API functions, which invoke Convex serverless functions.
• Convex functions read/write from the Convex database; subscriptions push real-time updates back to the client.
• Build tools watch local code, regenerate API bindings, and redeploy serverless functions seamlessly.
Architectural Patterns & Principles
• Full-stack separation: clear divide between UI layer and backend functions
• Reactive data flow: UI subscribes to Convex query results, auto-updates on data change
• Code-generation: type-safe API bindings to backend
• Serverless functions: each independent function deployed on demand (includes cron jobs in cron-jobs demo)
• Modular demos: each directory isolates a single use case