Flask Application Overview
The backend is a Flask application with Socket.IO WebSocket support, organized into specialized modules for different AI processing tasks.Project Structure
Core Module: app.py
app.py is the central orchestrator (3500+ lines) that initializes all services and handles routing.
Key Responsibilities
- Application Initialization
- Database Setup
- WebSocket Event Handling
- HTTP API Routes
- Real-time Audio Processing
Application Setup
Path Configuration
Class: SpeechMetrics
Location:app.py:73-88
Tracks research-grade speech timing metrics:
- Tracks speaking vs. silence time
- Counts long pauses (> 2 seconds)
- Calculates effective speaking rate
- Stored in
InterviewSession.speech_metricsas JSON
Database Models (models.py)
User Model
InterviewSession Model
UserMastery Model
Location:models.py:62-100
Purpose: Tracks user’s topic-level mastery with concept-level granularity
StudyActionPlan Model
AI Engines
1. rag.py - RAG Pipeline
Size: 27KB | Purpose: Retrieval-Augmented Generation for context-aware questions Key Functions:generate_rag_question()
evaluate_answer_with_rag()
2. interview_analyzer.py - Signal Processing
Size: 51KB | Purpose: Research-grade audio and speech analysis Key Components:Voice Activity Detector
Fast Chunk Analysis
Running Statistics Class
Semantic Similarity
3. mock_interview_engine.py
Size: 21KB | Purpose: Mock interview question generation Key Function:4. coding_engine.py
Size: 6KB | Purpose: Coding problem generation and evaluationAgent System
The agent system implements adaptive learning by tracking user performance and adjusting question difficulty.adaptive_controller.py
Size: 40KB | Purpose: Main orchestration agent Key Methods:adaptive_analyzer.py
Size: 24KB | Purpose: Analyzes answer qualityadaptive_question_bank.py
Size: 63KB | Purpose: Stores 500+ questions across topics/difficultiessubtopic_tracker.py
Size: 20KB | Purpose: Tracks concept-level masteryExternal Services
assemblyai_websocket_stream.py
Size: 15KBresume_processor.py
Size: 6KBAPI Routes Organization
Authentication Routes
Interview Routes
Resume Routes
WebSocket Events
Configuration (config.py)
Performance Optimizations
- FAISS Indexing: O(log n) vector search instead of O(n) linear scan
- Welford’s Algorithm: O(1) memory for running statistics
- YIN Pitch Detection: Optimized for real-time processing
- Database Indexing: Composite indexes on
(user_id, topic) - WebSocket Pooling: One connection per user session
Next Steps
Frontend Structure
Explore the React application architecture