Directory Layout
Core Modules
Application Package (app/)
app/__init__.py - Application Factory
app/__init__.py - Application Factory
create_app(config_object=None): Creates and configures Flask app instance- Initializes SQLAlchemy database connection
- Registers all route blueprints
- Creates upload folder if it doesn’t exist
app/__init__.py:12app/models.py - Database Models
app/models.py - Database Models
User- User accounts (optional)Session- Interview sessionsMessage- Conversation messagesFeedback- Interview feedback
app/models.pyapp/config.py - Configuration Management
app/config.py - Configuration Management
DevelopmentConfigProductionConfigTestConfig
app/exceptions.py - Custom Exceptions
app/exceptions.py - Custom Exceptions
Routes Layer (app/routes/)
Flask blueprints that handle HTTP requests. Each blueprint focuses on a specific domain.
session_routes.py - Session Management
session_routes.py - Session Management
GET /- Landing pageGET /dashboard- Dashboard with recent sessionsPOST /session/create- Create new session
app/routes/session_routes.py:29document_routes.py - File Uploads
document_routes.py - File Uploads
GET /session/<id>/upload- Upload pagePOST /session/<id>/upload-cv- Upload CV filePOST /session/<id>/upload-job- Submit job description text
- Validates file types (PDF, DOCX, TXT)
- Extracts text using
DocumentParser - Stores extracted text in
Session.cv_text
- PDF (via pdfplumber)
- DOCX (via python-docx)
- TXT (plain text)
interview_routes.py - Interview Flow
interview_routes.py - Interview Flow
GET /session/<id>/interview- Interview UIPOST /session/<id>/start- Start interview (first question)POST /session/<id>/message- Submit answer (HTMX endpoint)POST /session/<id>/complete- Finish interview and generate feedback
feedback_routes.py - Results Display
feedback_routes.py - Results Display
GET /session/<id>/feedback- View feedback results
- Interview score (1-10)
- Strengths (markdown list)
- Weaknesses (areas for improvement)
- CV optimization suggestions
Services Layer (app/services/)
Business logic and workflow orchestration.
session_service.py - Session Lifecycle
session_service.py - Session Lifecycle
- Job title must be non-empty and ≤ 200 characters
- Company name must be non-empty
app/services/session_service.py:6interview_service.py - Interview Orchestration
interview_service.py - Interview Orchestration
- User starts interview
- AI generates first question based on CV and job description
- User submits answer
- Service checks if MAX_QUESTIONS reached
- If not, AI generates follow-up question
- Repeat until 8 questions answered
app/services/interview_service.py:6document_service.py - File Processing
document_service.py - File Processing
utils.document_parser.DocumentParserfor text extractionrepositories.file_repository.FileRepositoryfor file storage
feedback_service.py - Feedback Generation
feedback_service.py - Feedback Generation
- All conversation messages
- Original CV text
- Job description
- Request for score, strengths, weaknesses, and CV tips
Repositories Layer (app/repositories/)
Data access abstractions for database operations.
session_repository.py - Session Data Access
session_repository.py - Session Data Access
- Uses
db.joinedload()for eager loading - Avoids N+1 query problems
app/repositories/session_repository.py:5message_repository.py - Message Operations
message_repository.py - Message Operations
count_messages(session_id, role='assistant')used to track interview progress
feedback_repository.py - Feedback Storage
feedback_repository.py - Feedback Storage
- Each session has at most one feedback record
- Creating second feedback for same session would overwrite (not currently handled)
AI Client (client/)
Abstraction layer for AI providers.
ai_client.py - Main AI Interface
ai_client.py - Main AI Interface
- Tries primary provider (e.g., Gemini)
- Falls back to secondary provider (e.g., OpenRouter) on failure
ai_provider.py - Provider Protocol
ai_provider.py - Provider Protocol
gemini_provider.py & openrouter_provider.py
gemini_provider.py & openrouter_provider.py
- API key authentication
- Request formatting
- Response parsing
- Retry logic with exponential backoff (via Tenacity)
Utilities (utils/)
document_parser.py - Text Extraction
document_parser.py - Text Extraction
- Gracefully handles corrupted files
- Returns empty string on parse failure
- Logs errors for debugging
prompt_templates.py - AI Prompts
prompt_templates.py - AI Prompts
- Easy to update prompts without changing code
- Consistent tone across all AI interactions
- Version control for prompt engineering
Entry Points
Development Server
Production WSGI
Docker Container
Testing Structure
Test Organization
Running Tests
Test Fixtures (conftest.py)
Configuration Files
.env.example
requirements.txt
Related Resources
- Architecture Overview - Understand the layered design
- Database Schema - Explore data models
- API Reference - HTTP endpoint documentation