Dash-based web interface for testing the Gym AI Helper backend API.
web-dashboard/
├── dash-server/ # Main application code
│ ├── app.py # Application entry point
│ ├── pages/ # Page layouts
│ ├── templates/ # Reusable UI components
│ ├── settings/ # Configuration management
│ ├── tools/ # API client utilities
│ ├── utils/ # Helper functions
│ ├── locales/ # Internationalization
│ └── assets/ # Static assets (CSS)
├── tests/ # Test suite
├── requirements.txt # Production dependencies
├── dev-requirements.txt # Development dependencies
├── pyproject.toml # Tool configurations
├── Dockerfile # Container image
└── config.example.yaml # Configuration template
- Image Upload: Drag-and-drop or click to upload gym equipment images
- Real-time Preview: See uploaded image before analysis
- Health Check: Monitor backend API and AI provider status
- Analysis Results: View equipment name, muscles worked, instructions, and video links
- Performance Metrics: See processing time and cache status
# From project root
docker-compose up dashboard
# Access at http://localhost:8050# Create virtual environment (requires Python 3.13+)
python3.13 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set backend URL
export BACKEND_URL=http://localhost:8000
# Run dashboard
python -m dash-server.app
# Or with options:
python -m dash-server.app --debug --port 8100# Install development dependencies (includes pre-commit)
pip install -r dev-requirements.txt
# Install pre-commit hooks
pre-commit install
# (Optional) Run pre-commit on all files
pre-commit run --all-files# Backend API URL
BACKEND_URL=http://backend:8000
# Enable/disable debug mode
DASH_DEBUG=trueThe dashboard is pre-configured in docker-compose.yml:
dashboard:
build: ./test-dashboard
environment:
- BACKEND_URL=http://backend:8000
ports:
- "8050:8050"
depends_on:
- backendThe dashboard automatically checks backend health on load. You should see:
- Green: Backend and AI provider are healthy
- Yellow: Backend running but AI provider degraded
- Red: Cannot connect to backend
Option A: Drag and Drop
- Drag an image file from your computer
- Drop it in the upload area
Option B: File Selector
- Click "Select an Image"
- Choose file from file browser
Supported Formats: JPG, JPEG, PNG, WebP
Maximum Size: 10MB (configured in backend)
After upload, the image preview appears on the right side. Verify it's the correct image before analysis.
Click the "Analyze Image" button. The dashboard will:
- Send image to backend API
- Show loading spinner
- Display results when complete
The results card shows:
- Equipment Name: Identified equipment
- Category: Primary muscle group
- Confidence: AI confidence score (0-100%)
- Muscles Worked: List of targeted muscles
- Instructions: Step-by-step usage guide
- Common Mistakes: Form errors to avoid
- Tutorial Videos: Links to instructional content
- Cache Status: Whether result came from cache
- Processing Time: API response time in milliseconds
The dashboard communicates with these backend endpoints:
GET /api/v1/health
Returns backend and AI provider status.
POST /api/v1/analyze
Content-Type: multipart/form-data
{
"image": <file>
}
Returns equipment analysis with instructions.
Symptom: Red alert showing "Cannot connect to backend"
Solutions:
-
Verify backend is running:
docker-compose ps backend
-
Check backend logs:
docker-compose logs backend
-
Verify
BACKEND_URLis correct:docker-compose exec dashboard env | grep BACKEND_URL
Symptom: Error after clicking "Analyze Image"
Solutions:
- Check image file size (must be < 10MB)
- Verify image format (JPG, PNG, WebP only)
- Check backend logs for validation errors
Symptom: Long processing time (>10 seconds)
Possible Causes:
- First request (AI model loading)
- Using CLIP/LLaVA without GPU
- Large image requiring preprocessing
- OpenAI API rate limits
Solutions:
- Wait for model to load (first request)
- Enable GPU for CLIP/LLaVA:
# docker-compose.yml backend: deploy: resources: reservations: devices: - capabilities: [gpu]
Symptom: Loading spinner doesn't stop
Solutions:
- Check browser console for JavaScript errors
- Verify backend returned valid JSON
- Increase timeout in
app.py:response = httpx.post(API_ENDPOINT, files=files, timeout=60.0)
Edit app.py to use different Bootstrap theme:
app = dash.Dash(
__name__,
external_stylesheets=[dbc.themes.DARKLY], # or FLATLY, CERULEAN, etc.
title="Gym AI Helper"
)Create assets/custom.css:
.custom-header {
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 10px;
}Dash automatically loads files from assets/ directory.
The layout is defined in app.py using Dash Bootstrap Components. Key sections:
- Header: Title and description
- Health Status: API connectivity indicator
- Upload Section: File upload and analyze button
- Preview Section: Image preview
- Results Section: Analysis output
DASH_DEBUG=true python app.pyChanges to app.py will automatically reload the app.
Download sample gym equipment images:
mkdir -p test-images
wget -O test-images/bench_press.jpg "https://example.com/bench.jpg"For testing without backend, modify the analyze_image callback to return mock data:
# Mock response for testing
mock_data = {
"equipment_name": "Test Equipment",
"category": "chest",
"confidence": 0.95,
...
}
return create_results_card(mock_data), ""-
Disable Debug Mode:
DASH_DEBUG=false
-
Add Authentication (optional):
import dash_auth VALID_USERNAME_PASSWORD_PAIRS = { 'admin': 'secure_password' } auth = dash_auth.BasicAuth( app, VALID_USERNAME_PASSWORD_PAIRS )
-
Use HTTPS: Deploy behind reverse proxy (Nginx/Caddy) with SSL certificate.
-
Rate Limiting: Implement rate limiting to prevent abuse.
-
Enable Caching:
from flask_caching import Cache cache = Cache(app.server, config={ 'CACHE_TYPE': 'redis', 'CACHE_REDIS_URL': 'redis://redis:6379' })
-
Optimize Images: Compress uploaded images before sending to backend.
-
Use CDN: Serve static assets (CSS, JS) from CDN.
For issues or questions:
- Check backend logs:
docker-compose logs backend - Check dashboard logs:
docker-compose logs dashboard - Review main documentation