How rsvedant/dial0 works
Project Type and Purpose
• DialZero is a full-stack, real-time customer service automation platform.
• The frontend is built with Next.js (App Router), React, TypeScript and Tailwind CSS.
• The backend is powered by Convex (serverless DB + functions), supplemented by Next.js API routes.
• It integrates multiple external AI and voice services: Vapi AI (voice orchestration & cloning), ElevenLabs (voice synthesis), Inkeep (knowledge base), OpenAI/Google/Anthropic (NLP models).
• Real-time features use Convex subscriptions, WebRTC and the MediaRecorder API.
File-Tree Analysis and Architectural Patterns
• app/ (Next.js “App Router”): pages + layout + global providers + API routes under app/api/…
• components/ & hooks/: reusable UI components & custom hooks for chat, calls, toasts, mobile detection
• convex/: Convex schema, serverless functions (actions), authentication config, orchestration logic
• lib/: client- and server-side helper modules for auth, Inkeep, geo, search, utilities
• public/: static assets & manifest
• scripts/: tooling (e.g., fetch voice library)
• next.config.mjs, package.json, tsconfig.json, tailwind/postcss configs
Patterns:
• BFF (Next.js API routes) for authentication, chat, call start/events, Inkeep integration
• Serverless functions (Convex actions) for database operations, orchestration and external API calls
• Pub/Sub style real-time updates via Convex live queries
• Component-driven UI with Radix and Tailwind
Key Components
a. Frontend (Next.js App)
• React UI Components (components/)
• App Router pages (app/)
• ConvexClientProvider & AutumnClientProvider (GraphQL/WebSocket clients)
• WebRTC + MediaRecorder (browser audio capture)
b. Backend Services
• Next.js API Routes (app/api/…) acting as a BFF layer
• Convex Backend
• Real-time DB (collections: Issues, Settings, ChatMessages, CallEvents, OrchestrationContexts)
• Serverless Functions (“actions” in convex/actions/)
• Auth (convex/auth.ts + auth.config.ts)
• Orchestration Engine (convex/orchestration.ts)
c. External Services
• Vapi AI: call lifecycle & webhooks (app/api/vapi)
• ElevenLabs: advanced voice synthesis via Vapi
• Inkeep: context-aware KB queries
• OpenAI / Google Generative AI / Anthropic Claude: chat completions & NLP
• Convex Webhooks: to receive real-time events from Vapi
d. Data Flow & Interactions
1. User interacts with Next.js UI → triggers BFF endpoints or Convex live mutation
2. BFF (API Route) or Convex action calls External AI/Voice services → receives response
3. Convex action writes/transforms data in real-time DB → subscriptions push updates to UI
4. Webhooks from Vapi hit API routes → Convex actions update call state and transcription
5. React UI subscribes to Convex live queries → renders new chat messages, call transcription, analytics
Architectural Patterns & Principles
• Separation of Concerns: UI vs. BFF vs. Data Layer vs. External Integrations
• Event-driven & Real-time: DB subscriptions, webhooks, WebRTC streams
• Serverless Functions: stateless, ephemeral, on-demand
• Modular Components: hooks, lib helpers, convex actions