A comprehensive monitoring and analytics dashboard for your AI fraud detection agent, featuring real-time metrics, transaction monitoring, and model management capabilities.
- Live Metrics: Transaction volume, fraud detection rates, success rates, and response times
- System Health: CPU usage, memory consumption, uptime monitoring
- Risk Distribution: Visual breakdown of transaction risk levels
- Model Performance: Real-time model accuracy and latency tracking
- Interactive Testing: Test individual transactions with real-time risk assessment
- Batch Processing: Analyze multiple transactions simultaneously
- Transaction History: View recent transactions with risk scores
- Real-time Alerts: Instant notifications for high-risk transactions
- Time-based Analysis: Hourly and daily transaction patterns
- Customer Analysis: Risk profiles and behavior patterns
- Model Comparison: Performance metrics across different models
- Trend Analysis: Historical performance tracking
- Model Information: Detailed view of loaded models and parameters
- Performance Metrics: Accuracy, precision, recall, and F1 scores
- Model Health: System resource usage and response times
- Retraining: Background model retraining capabilities
- Real-time Alerts: System alerts for high-risk transactions and performance issues
- System Logs: Detailed transaction processing logs
- Alert Management: Configurable alert thresholds and notifications
The dashboard consists of three main components:
-
FastAPI Backend (
src/api_server.py)- RESTful API endpoints for real-time data
- Transaction processing and prediction
- System metrics and health monitoring
- Model management endpoints
-
Streamlit Dashboard (
src/dashboard.py)- Interactive web-based dashboard
- Real-time visualizations and metrics
- Transaction testing interface
- Model performance monitoring
-
React Frontend (
frontend/)- Modern, responsive web interface
- Advanced charts and visualizations
- Real-time data updates
- Professional UI/UX design
- Python 3.8+
- Node.js 16+ (for React frontend)
- npm or yarn
-
Install Python Dependencies
pip install -r requirements.txt
-
Start All Components
python run_dashboard.py --install-deps
-
Access Dashboards
- FastAPI Server: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Streamlit Dashboard: http://localhost:8501
- React Frontend: http://localhost:3000
# Install dependencies
pip install -r requirements.txt
# Start FastAPI server
uvicorn src.api_server:app --host 0.0.0.0 --port 8000 --reload
# Start Streamlit dashboard
streamlit run src/dashboard.py --server.port 8501# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm startpython run_dashboard.py# Start only FastAPI and Streamlit
python run_dashboard.py --components api streamlit
# Start only React frontend
python run_dashboard.py --components reactpython run_dashboard.py --install-deps- View live transaction metrics and system health
- Monitor fraud detection rates and success metrics
- Track model performance in real-time
- Test individual transactions with the interactive form
- View transaction history and risk assessments
- Analyze batch transactions for patterns
- Explore time-based transaction patterns
- Analyze customer risk profiles
- Compare model performance metrics
- View loaded models and their parameters
- Monitor model health and performance
- Initiate model retraining
- Monitor system alerts and notifications
- View detailed transaction logs
- Configure alert thresholds
The FastAPI server provides the following endpoints:
GET /health- System health checkGET /metrics- Comprehensive system metricsGET /models- Model information
POST /predict- Single transaction predictionPOST /predict/batch- Batch transaction predictionGET /transactions/recent- Recent transaction history
GET /analytics/hourly- Hourly transaction analyticsGET /analytics/daily- Daily transaction analytics
GET /alerts- System alertsPOST /models/retrain- Retrain models
# API Configuration
REACT_APP_API_URL=http://localhost:8000
# Dashboard Configuration
STREAMLIT_SERVER_PORT=8501
STREAMLIT_SERVER_ADDRESS=0.0.0.0
# Model Configuration
MODEL_PATH=models/bank_fraud_detector.pkl- Modify
src/api_server.pyto add new endpoints - Update
frontend/src/services/api.jsto include new API calls - Add visualizations in the dashboard components
- Configure alert thresholds in
src/api_server.py - Add alert types in the
get_recent_alerts()method - Update frontend components to display new alerts
- Ensure your model is saved in the
models/directory - Update the model path in
src/api_server.py - Test the integration through the dashboard
- Real-time Metrics: Live transaction and fraud detection metrics
- Interactive Charts: Plotly-based visualizations
- Transaction Testing: Form-based transaction analysis
- Model Management: Model information and controls
- Modern UI: Material-UI based interface
- Real-time Updates: WebSocket-based live data
- Advanced Charts: Recharts-based visualizations
- Responsive Design: Mobile-friendly interface
- RESTful API: Standard HTTP endpoints
- Real-time Processing: Async transaction handling
- System Monitoring: Health checks and metrics
- Model Management: Model loading and prediction
# Check what's using the port
lsof -i :8000
lsof -i :8501
lsof -i :3000
# Kill the process
kill -9 <PID># Reinstall Python dependencies
pip install -r requirements.txt
# Reinstall React dependencies
cd frontend && npm install# Train the model first
python train_model.py
# Check model path
ls -la models/# Check if FastAPI server is running
curl http://localhost:8000/health
# Check CORS settings in api_server.py# In src/api_server.py
logging.basicConfig(level=logging.DEBUG)streamlit run src/dashboard.py --logger.level debug- Open browser developer tools
- Check Console tab for errors
- Check Network tab for API calls
- Use HTTPS for all communications
- Implement authentication and authorization
- Configure CORS properly for production domains
- Use environment variables for sensitive configuration
- Implement rate limiting for API endpoints
- Ensure transaction data is properly anonymized
- Implement data retention policies
- Use secure storage for model files
- Log only necessary information
- Use connection pooling for database connections
- Implement caching for frequently accessed data
- Use async processing for batch operations
- Monitor memory usage and implement garbage collection
- Implement lazy loading for components
- Use React.memo for expensive components
- Optimize chart rendering with proper data structures
- Implement proper error boundaries
- Create a feature branch
- Implement the feature with tests
- Update documentation
- Submit a pull request
- Follow PEP 8 for Python code
- Use ESLint for JavaScript/React code
- Add type hints for Python functions
- Write comprehensive docstrings
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the troubleshooting section
- Review the API documentation at http://localhost:8000/docs
- Open an issue in the project repository
Happy Monitoring! π‘οΈπ