Overview
OddsEngine is built as a modular, layered architecture that separates concerns between data presentation, business logic, external data integration, and persistence. This design enables independent development and testing of each layer while maintaining clear boundaries and responsibilities.Architectural Layers
1. Presentation Layer (Frontend)
Technology: PyQt The desktop interface is built using PyQt, providing a native application experience for users analyzing tennis betting probabilities. PyQt was chosen over web frameworks because:- Performance: Direct rendering without browser overhead
- Desktop integration: Native OS features and file system access
- Rapid prototyping: Qt Designer enables quick UI iteration
- Academic context: Aligns with Python-first technology stack
2. Application Layer (Backend)
Technology: Python + FastAPI + Uvicorn The backend serves as the orchestration layer, handling:- RESTful API endpoints for frontend communication
- Asynchronous request handling via FastAPI’s async/await support
- Business logic routing to the probability engine
- Data transformation between external APIs and internal models
- Native async/await support for non-blocking I/O
- Automatic API documentation (OpenAPI/Swagger)
- Type validation with Pydantic models
- Production-ready with Uvicorn ASGI server
3. API Integration Layer
Technology: HTTPX (async HTTP client) This layer manages all external data sources, primarily the API-Tennis service. HTTPX provides:- Async HTTP calls that don’t block the FastAPI event loop
- Connection pooling for efficient resource usage
- Timeout handling and retry logic
- Fallback to mock data when external APIs are unavailable
API Selection Rationale: API-Tennis was selected over RapidAPI and other providers because of its tennis specialization, clean JSON responses optimized for async processing, and alignment with FastAPI/HTTPX architecture. See
docs/research/tennis_api_selection.md for the complete evaluation.4. Probability Engine
Technology: Python + Pandas The core analytical component that performs:- Statistical analysis of historical match data
- Probability calculations for individual and combined bets
- Data aggregation using Pandas DataFrames
- Model evaluation and confidence scoring
- Efficient handling of tabular tennis statistics
- Built-in statistical functions for probability analysis
- Integration with Jupyter notebooks for research/exploration
- Industry-standard for data science workflows
5. Data Persistence Layer
Technology: Oracle Database Stores:- Historical match results for trend analysis
- Player statistics and performance metrics
- User bet combinations and their outcomes
- Calculated probabilities for traceability
- Academic licensing available for university projects
- Robust transaction support for data integrity
- Advanced analytics capabilities
- Industry exposure for learning objectives
Architecture Diagram
Data Flow Example
When a user analyzes a combined bet:- User Input: User selects 3 matches in PyQt interface
- API Request: Frontend sends POST to
/api/bets/analyzewith match IDs - Data Fetching: Backend uses HTTPX to fetch match statistics from API-Tennis (or mock provider)
- Probability Calculation: Pandas engine processes historical data and calculates individual + combined probabilities
- Database Logging: Results stored in Oracle for future analysis
- Response: JSON response returned to frontend with probability breakdown
- Visualization: PyQt displays probability chart and confidence score
Deployment Architecture
Containerization: Docker + Docker Compose The application runs in containerized environments with:- Backend container: FastAPI application with Uvicorn
- Database container: Oracle Database instance
- Volume mounts: Configuration files from
conf/directory - Network isolation: Services communicate via Docker network
Design Principles
Separation of Concerns
Each layer has a single responsibility and can be developed/tested independently.Async-First
All I/O operations are non-blocking to maximize throughput and responsiveness.Fail-Safe Fallbacks
Mock data providers ensure the system remains functional when external dependencies fail.Data-Driven
Decisions are based on statistical analysis, not hardcoded rules, making the system adaptable to new betting scenarios.Modular Design
Components can be replaced (e.g., API-Tennis → another provider) without rewriting the entire system.Related Documentation
- Technology Stack - Detailed technology choices and justifications
- Project Structure - Directory organization and code layout
- API Reference - Backend endpoint documentation