Source: docs/guides/CONTINUOUS_IMPROVEMENT.md
Continuous Deployment & Improvement System
Overview
This system provides automated continuous deployment, testing, and improvement for the AltSports platform. It simultaneously runs frontend and backend services while monitoring for errors and suggesting improvements.
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Continuous Improvement Orchestrator β
β β
β ββββββββββββββββ βββββββββββββββββββ β
β β Backend β β Frontend β β
β β (FastAPI) βββββββββββββββΊβ (Streamlit) β β
β β Port: 8080 β β Port: 8501 β β
β ββββββββββββββββ βββββββββββββββββββ β
β β β β
β βΌ βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Service Monitor & Analyzer β β
β β β’ Health checks every 30 seconds β β
β β β’ Log scanning for errors β β
β β β’ Pattern recognition β β
β β β’ Improvement suggestions β β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Iteration Reports (JSON) β β
β β output/continuous-improvement/ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββQuick Start
Option 1: Using the Shell Script (Recommended)
./run_continuous_improvement.shThis will:
- Check and install required dependencies
- Start backend on port 8080
- Start frontend on port 8501
- Begin continuous monitoring loop
Option 2: Direct Python Execution
python continuous_deploy_test_improve.pyOption 3: Custom Configuration
# Check every 60 seconds instead of 30
python continuous_deploy_test_improve.py --interval 60
# Run for exactly 10 iterations then stop
python continuous_deploy_test_improve.py --max-iterations 10
# Combine both
python continuous_deploy_test_improve.py --interval 45 --max-iterations 20What It Does
1. Service Management
Backend Service:
- Starts FastAPI server on port 8080
- Loads from
apps/backend/server.py - Auto-reload enabled for development
- Logs to
apps/backend/backend.log
Frontend Service:
- Starts Streamlit UI on port 8501
- Loads from
clients/streamlit-000-league-questionnaire-to-contract-termsheet-maged-with-backend/streamlit_app.py - Connects to backend at
http://localhost:8080 - Logs to
clients/.../streamlit_app.log
2. Health Monitoring
Every interval (default: 30 seconds):
- β HTTP health checks to both services
- π Response time tracking
- π Log file scanning for errors
- π§ Pattern recognition for common issues
3. Error Detection
Automatically detects:
- Connection failures
- Module import errors
- Timeout issues
- HTTP errors (404, 500, etc.)
- Rate limiting problems
- Exception tracebacks
4. Improvement Suggestions
For each error detected, provides:
- Issue: What went wrong
- Context: Error message and timestamp
- Suggested Fix: Actionable recommendation
- Service: Which service (frontend/backend)
5. Iteration Reports
Each iteration generates a detailed JSON report:
{
"iteration": 1,
"timestamp": "2025-10-01T10:30:00",
"monitoring": {
"backend_health": {
"status": "healthy",
"status_code": 200,
"response_time": 0.045
},
"frontend_health": {
"status": "healthy",
"status_code": 200,
"response_time": 0.123
},
"backend_errors": [],
"frontend_errors": []
},
"improvements": []
}Reports saved to: output/continuous-improvement/iteration_XXX.json
Common Error Patterns & Auto-Fixes
| Error Pattern | Detected Issue | Suggested Fix |
|---|---|---|
connection refused | Service not responding | Check if service is running and port is correct |
module not found | Missing dependency | Install missing Python package |
timeout | Request timeout | Increase timeout or optimize performance |
rate limit | API rate limiting | Add authentication token or implement backoff |
500 | Server error | Check backend logs for detailed error |
404 | Endpoint not found | Verify API endpoint paths |
Output Files
output/continuous-improvement/
βββ continuous_deploy.log # Main orchestrator log
βββ iteration_001.json # First iteration report
βββ iteration_002.json # Second iteration report
βββ iteration_XXX.json # Subsequent iterations
apps/backend/
βββ backend.log # Backend service log
clients/streamlit-000-league-questionnaire-to-contract-termsheet-maged-with-backend/
βββ streamlit_app.log # Frontend service logAccessing the Services
While running:
-
Frontend UI: http://localhost:8501 (opens in a new tab)
- Interactive Streamlit interface
- Document upload and processing
- Results visualization
-
Backend API: http://localhost:8080 (opens in a new tab)
- RESTful API endpoints
- Health check: http://localhost:8080/health (opens in a new tab)
- API docs: http://localhost:8080/docs (opens in a new tab)
Stopping the System
Press Ctrl+C to gracefully shutdown:
- All services will be terminated
- Final cleanup performed
- No orphaned processes
Advanced Usage
Environment Variables
# Custom backend URL (if not using localhost)
export BACKEND_URL="https://your-backend.run.app"
# Run with custom settings
./run_continuous_improvement.shDebugging
# Check if services are running
ps aux | grep "uvicorn\|streamlit"
# View live logs
tail -f apps/backend/backend.log
tail -f clients/streamlit-*/streamlit_app.log
# Check iteration reports
cat output/continuous-improvement/iteration_001.json | jqIntegration with CI/CD
# Run 5 iterations as smoke test
python continuous_deploy_test_improve.py --max-iterations 5
# Exit code 0 = success, non-zero = failures detected
echo $?Troubleshooting
Backend won't start
# Check backend dependencies
cd apps/backend
pip install -r requirements.txt
# Test backend manually
cd apps/backend
uvicorn server:app --port 8080Frontend won't start
# Check frontend dependencies
cd clients/streamlit-000-league-questionnaire-to-contract-termsheet-maged-with-backend
pip install -r requirements.txt
# Test frontend manually
cd clients/streamlit-000-league-questionnaire-to-contract-termsheet-maged-with-backend
streamlit run streamlit_app.pyPort already in use
# Find process using port 8080 or 8501
lsof -i :8080
lsof -i :8501
# Kill the process
kill -9 <PID>Development Workflow
- Start the continuous system:
./run_continuous_improvement.sh - Make changes to frontend or backend code
- Services auto-reload (FastAPI reload + Streamlit watching)
- Monitor logs in terminal for detected errors
- Review iteration reports for improvement suggestions
- Apply fixes based on suggestions
- Repeat until all errors resolved
Benefits
β Automated Testing: Continuous health checks without manual intervention β Error Detection: Catches issues immediately as they occur β Actionable Insights: Specific suggestions for each error type β Historical Tracking: JSON reports for trend analysis β Zero Downtime: Services stay running during monitoring β Development Friendly: Auto-reload on code changes
Future Enhancements
- Automated fix application
- Integration with deployment pipeline
- Slack/Discord notifications
- Metrics dashboard (Grafana/Prometheus)
- Load testing integration
- Multi-environment support (dev/staging/prod)
License
Internal tool for AltSports development team.