A FastAPI-based backend application for an interactive tutoring system with WebSocket support.
Interactive Tutor Backend powers real-time, AI-assisted learning experiences. It manages users, sessions, courses, dashboards, and orchestrates WebSocket-based tutoring flows. Optional integrations for language and speech services are available via modules in app/resources (OpenAI, ElevenLabs, Deepgram).
Frontend: The companion React frontend lives in the interactive-tutor-v3 codebase.
Watch a short walkthrough of the experience: Loom demo.
- FastAPI web framework
- WebSocket support for real-time communication
- CORS configuration for localhost development
- Modular structure with separate routes and logic folders
- Learning interface WebSocket endpoint
interactive-tutor-be/
├── main.py # Main application entry point
├── requirements.txt # Python dependencies
├── routes/ # API routes
│ ├── __init__.py
│ └── websocket_routes.py # WebSocket routes
├── logic/ # Business logic
│ ├── __init__.py
│ ├── websocket_manager.py # WebSocket connection management
│ └── learning_interface.py # Learning interface logic
└── README.md
- Install dependencies:
pip install -r requirements.txt- Run the application:
python main.pyOr using uvicorn directly:
uvicorn main:app --reload --host 0.0.0.0 --port 8000GET /- Root endpointGET /health- Health check endpoint
WS /learning-interface- Main learning interface WebSocket
The /learning-interface WebSocket endpoint supports the following message types:
- Ping
{
"type": "ping"
}- Learning Request
{
"type": "learning_request",
"topic": "mathematics",
"difficulty": "beginner"
}- User Response
{
"type": "user_response",
"content": "user input text",
"session_id": "session_123"
}- Session Start
{
"type": "session_start",
"session_id": "session_123",
"user_name": "John Doe"
}- Session End
{
"type": "session_end",
"session_id": "session_123"
}The server responds with appropriate JSON messages based on the request type, including error handling and timestamps.
The application is configured to allow CORS requests from:
- http://localhost:3000
- http://localhost:3001
- http://localhost:8000
- http://127.0.0.1:3000
- http://127.0.0.1:3001
- http://127.0.0.1:8000
To run in development mode with auto-reload:
uvicorn main:app --reloadThe application will be available at http://localhost:8000