Architecture Overview
Verriflo has evolved from a live streaming platform into a comprehensive education infrastructure with multiple integrated services.
Service Architectureβ
Verriflo consists of several microservices, all accessible through a unified Server API:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your Application β
β (Dashboard, Mobile App, Web App, etc.) β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β
β HTTPS / REST API
β
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β Server API (api.verriflo.com) β
β β’ Authentication & Authorization β
β β’ Request Routing & Proxying β
β β’ Rate Limiting & Security β
β β’ Usage Tracking & Billing β
βββββββββ¬ββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββ
β β β β
β β β β
βββββΌββββ βββββΌββββ βββββββΌββββββ ββββββΌβββββ
β Live β β AI β β AI API β β CDN β
βStream β β Tutor β β(voice- β β & Media β
β β β β β agent) β β β
βββββββββ βββββββββ βββββββββββββ βββββββββββ
Core Servicesβ
1. Server API (server/)β
Purpose: Central API gateway and orchestration layer
Responsibilities:
- Single entry point for all external requests
- Authentication and authorization (VF-ORG-ID header)
- Request routing and proxying to internal services
- Rate limiting and security
- Usage tracking and billing aggregation
- Database operations (MongoDB)
- Webhook management
Key Endpoints:
/v1/room/*- Room management/v1/ai-agent/*- AI API (proxies to voice-agent)/v1/ai-tutor/*- AI Tutor (proxies to teacher-agent)/v1/cdn/*- CDN operations/v1/billing/*- Billing and credits/v1/health/*- Health checks
Technology: Express.js, TypeScript, MongoDB
2. Live Streaming (live/)β
Purpose: Web-based classroom interface and iframe embedding
Responsibilities:
- Live classroom UI (iframe embeddable)
- LiveKit client integration
- Participant management UI
- Recording controls
- AI Tutor UI integration
Technology: Next.js, React, LiveKit Client SDK
3. AI Tutor (teacher-agent/)β
Purpose: Real-time AI assistant for students during live classes
Responsibilities:
- Student Q&A during live classes
- Context-aware responses (aware of current class topic)
- Multi-modal support (text, voice)
- Class summary generation
- Usage tracking per room
Key Endpoints:
POST /api/ai-tutor/chat- Send messagePOST /api/ai-tutor/chat/stream- Stream responses (SSE)GET /api/ai-tutor/summary/:roomId- Get class summaryGET /api/ai-tutor/usage/:roomId- Get usage stats
Technology: Express.js, LiveKit Agents
Access: Via Server API at /v1/ai-tutor/*
4. AI API (voice-agent/)β
Purpose: Conversational AI service (branded as "AI API")
Responsibilities:
- General-purpose conversational AI
- Text, voice, and image input/output
- Knowledge base management
- Chat history management
- Streaming responses (NDJSON)
Key Endpoints:
POST /api/v1/generate- Send messagePOST /api/v1/generate/stream- Stream responses (NDJSON)- Knowledge CRUD operations
Technology: Express.js, Redis
Access: Via Server API at /v1/ai-agent/*
5. CDN & Media (Verriflo-CDN/)β
Purpose: Video transcoding, storage, and delivery
Responsibilities:
- Video transcoding and optimization
- Cloud storage management
- Recording file management
- Stream proxy and delivery
Technology: Python, FFmpeg, Cloud Storage
Access: Via Server API at /v1/cdn/*
Request Flow Examplesβ
Example 1: AI Chat from Dashboardβ
Dashboard β Next.js API Route β Server API β voice-agent
β β β β
User sends /api/v1/ai- /v1/ai-agent/ /api/v1/
message agent/chat/ chat/stream generate/stream
stream
- User sends message in dashboard
- Dashboard calls Next.js API route (
/api/v1/ai-agent/chat/stream) - Next.js route adds
VF-ORG-IDheader and proxies to Server API - Server API validates and proxies to voice-agent with dispatch secret
- voice-agent processes the request and streams response back
- Response flows back through the chain to the user
Example 2: Student Asks AI Tutorβ
Live UI β Next.js API Route β Server API β teacher-agent
β β β β
Student /api/v1/ai- /v1/ai-tutor/ /api/ai-tutor/
asks tutor/chat/ chat/stream chat/stream
question stream
- Student asks question in live classroom
- Live UI calls Next.js API route
- Next.js route proxies to Server API
- Server API proxies to teacher-agent
- teacher-agent processes with class context
- Response streams back to student
Example 3: Create Classroomβ
Your Backend β Server API β LiveKit β Live UI
β β β β
POST /v1/ Create room Generate Return
room/create in MongoDB token iframe URL
Authentication Flowβ
All services use a unified authentication model:
- External Requests: Require
VF-ORG-IDheader - Internal Service Communication: Uses
X-Dispatch-Secretheader - Token-Based Auth: JWT tokens for user sessions (dashboard)
Data Flowβ
Live Streamingβ
- Media: WebRTC β LiveKit SFU β Students
- Signaling: WebSocket β LiveKit Server
- Metadata: REST API β Server β MongoDB
AI Servicesβ
- Requests: REST/SSE β Server β AI Service
- Responses: Stream back through same path
- Storage: Chat history in Redis, usage in MongoDB
CDNβ
- Upload: Client β Server β CDN Service β Cloud Storage
- Download: Cloud Storage β CDN Service β Client
Deployment Architectureβ
All services are containerized and can be deployed:
- Kubernetes: Recommended for production
- Docker Compose: For local development
- Individual Services: Can run independently
Service Communicationβ
Internal Servicesβ
- Use
X-Dispatch-Secretfor authentication - Communicate via HTTP/REST
- Service URLs configured via environment variables
External Accessβ
- All external access goes through Server API
- Server API handles authentication, routing, and proxying
- Users never directly access internal services
Benefits of This Architectureβ
- Single API: Users only integrate with one API (Server API)
- Scalability: Each service can scale independently
- Security: Internal services not exposed to internet
- Maintainability: Clear separation of concerns
- Flexibility: Services can be updated independently
Next Stepsβ
- API Overview - Complete API reference
- AI Agent API - AI API documentation
- AI Tutor API - AI Tutor documentation
- Quick Start - Get started in 5 minutes