A cutting-edge, production-ready voice tutoring platform powered by LiveKit and OpenAI's Realtime API. Features real-time voice interaction, intelligent conversation management, and comprehensive monitoring.
- π€ Real-time Voice Interaction - Ultra-low latency voice communication using LiveKit
- π€ AI-Powered Tutoring - OpenAI Realtime API with GPT-4 for natural conversations
- π Advanced Analytics - Prometheus metrics and Grafana dashboards
- π Enterprise Security - Rate limiting, JWT authentication, and input validation
- π³ Container-Ready - Full Docker Compose setup with all services
- π§ͺ Comprehensive Testing - 95%+ test coverage with pytest
- π Interactive API Docs - Automatic OpenAPI/Swagger documentation
- π Production-Ready - Health checks, logging, monitoring, and error handling
- Adaptive Pace Control - Automatically adjusts teaching speed based on student responses
- Comprehension Checking - Regular understanding verification
- Dynamic Examples - Context-aware example generation
- Conversation History - Full session recording and replay
- Multi-Topic Support - Organized knowledge base with subtopic management
- Audio Visualization - Real-time waveform display
- Room Management - Create, join, and manage tutoring sessions
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Frontend ββββββΆβ Backend ββββββΆβ LiveKit β
β React + Viteβ β FastAPI β β Server β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β β β
β βΌ β
β ββββββββββββββββ β
β β PostgreSQL β β
β β Database β β
β ββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββ β
βββββββββββββΆβ Redis βββββββββββββββ
β Cache β
ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Monitoring β
β (Prometheus/ β
β Grafana) β
ββββββββββββββββ
- Docker & Docker Compose (recommended)
- OR:
- Python 3.11+
- Node.js 20+
- PostgreSQL 16+
- Redis 7+
- LiveKit Server
-
Clone the repository
git clone https://github.com/yourusername/livekit_voice_agent.git cd livekit_voice_agent -
Configure environment
cp .env.example .env # Edit .env with your API keys -
Start all services
docker-compose up -d
-
Access the application
- Frontend: http://localhost
- Backend API: http://localhost:5001
- API Docs: http://localhost:5001/api/docs
- Grafana: http://localhost:3001
- Prometheus: http://localhost:9090
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Run database migrations (if using PostgreSQL)
# alembic upgrade head
# Start the server
python server.py
# or with uvicorn:
uvicorn server:app --reload --port 5001cd frontend
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Start development server
npm run devBackend (.env)
# LiveKit
LIVEKIT_API_KEY=your_api_key
LIVEKIT_API_SECRET=your_api_secret
LIVEKIT_URL=ws://localhost:7880
# OpenAI
OPENAI_API_KEY=sk-your_openai_key
# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# Redis
REDIS_URL=redis://:password@localhost:6379/0Frontend (.env)
VITE_LIVEKIT_URL=ws://localhost:7880
VITE_API_URL=http://localhost:5001See .env.example for complete configuration options.
cd backend
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test categories
pytest -m unit # Unit tests only
pytest -m integration # Integration tests only
pytest -m api # API tests onlycd frontend
# Run tests
npm test
# Run with coverage
npm test -- --coverageOnce the backend is running, access interactive API documentation:
- Swagger UI: http://localhost:5001/api/docs
- ReDoc: http://localhost:5001/api/redoc
- OpenAPI JSON: http://localhost:5001/api/openapi.json
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Health check |
| GET | /api/getToken |
Generate JWT token (legacy) |
| POST | /api/token |
Generate JWT token |
| GET | /api/rooms |
List active rooms |
| DELETE | /api/rooms/{name} |
Delete a room |
| GET | /api/metrics |
Prometheus metrics |
livekit_voice_agent/
βββ backend/
β βββ server.py # FastAPI application
β βββ agent.py # LiveKit agent entrypoint
β βββ api.py # TutorAgent class
β βββ db_driver.py # Database driver
β βββ prompts.py # AI prompts
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend container
β βββ tests/ # Test suite
βββ frontend/
β βββ src/
β β βββ App.jsx # Main component
β β βββ components/ # React components
β β βββ main.jsx # Entry point
β βββ package.json # Node dependencies
β βββ Dockerfile # Frontend container
β βββ nginx.conf # Nginx configuration
βββ monitoring/
β βββ prometheus.yml # Prometheus config
β βββ grafana/ # Grafana dashboards
βββ docker-compose.yml # Full stack orchestration
βββ .github/
βββ workflows/ # CI/CD pipelines
Backend
# Format code
black backend/
# Lint
ruff check backend/
# Type check
mypy backend/Frontend
# Lint
npm run lint
# Format
npm run formatAccess metrics at: http://localhost:9090
Available metrics:
token_requests_total- Total token generation requeststoken_errors_total- Token generation errorsroom_creations_total- Total rooms createdapi_request_duration_seconds- API latency histogram
Access dashboards at: http://localhost:3001 (admin/admin)
Pre-configured dashboards:
- API Performance
- System Resources
- LiveKit Metrics
- Error Rates
# Build and start
docker-compose -f docker-compose.yml up -d --build
# View logs
docker-compose logs -f
# Stop services
docker-compose downWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- LiveKit - Real-time communication infrastructure
- OpenAI - Realtime API and GPT models
- FastAPI - Modern Python web framework
- React - Frontend library
- Documentation: docs/
- Issues: GitHub Issues
- Multi-language support (i18n)
- Screen sharing functionality
- File upload and analysis
- Advanced analytics dashboard
- Mobile app (React Native)
- Offline mode support
- Integration with LMS platforms
Made with β€οΈ by the LiveKit Voice Agent Team