This directory contains the Python Flask frontend for the Code Analysis Agent.
-
Install Python 3.12+
-
Quick Start: Run
startup.shfrom the project root - it will:- Automatically create
.envfile fromsample.env.txt(if it doesn't exist) - Set up virtual environment and install dependencies
- Start the frontend service
- Automatically create
-
Manual Setup (if not using startup.sh):
- Create a virtual environment and install dependencies:
uv venv --python python3.12 source .venv/bin/activate uv pip install -r requirements.txt # requirements.txt includes: # flask, requests, markdown, pygments, python-dotenv
- Copy
sample.env.txtto.envand customize if needed:
cp sample.env.txt .env
-
Environment Variables (configured in
.envfile):BACKEND_URL=http://localhost:8000 # Backend API URL (default: http://localhost:8000) PORT=5173 # Port to run Flask app (default: 5173) DEBUG=False # Enable debug mode (default: False)
- The application uses
python-dotenvto automatically load variables from.envfile - Logging is configured to output INFO level messages with timestamps
- The application uses
Run the Flask app:
python app.pyVisit http://localhost:5173 in your browser (or the port specified in your .env file).
- File Browser: Browse and select Python files from the
data/src/directory - Code Display: Selected code is displayed with syntax highlighting using Pygments
- Code Analysis: Code is sent to the backend for analysis and narration
- Narration Display: Narration is displayed with Markdown rendering
- Audio Playback: Play the generated narration audio
- The frontend connects to the backend at
http://localhost:8000(configurable viaBACKEND_URLenvironment variable) - Files are read from
data/src/directory (relative to project root) - Code syntax highlighting uses Pygments with the "monokai" style
- Narration text is rendered as Markdown
- Environment variables are loaded from
.envfile usingpython-dotenv - Structured logging is configured with timestamps and log levels (INFO, WARNING, ERROR)
- Comprehensive error handling with user-friendly error messages displayed in the UI
- All operations (file reading, API calls, errors) are logged for debugging and monitoring
- Request timeouts are set for backend API calls (30s for analyze, 120s for narrate)
- Error messages are displayed with clear, actionable feedback for users