System Overview
Overview
The SmartRunning Training Optimization Platform is a monolithic web application built with Flask and MongoDB, following an MVC architecture with service layers. The system handles fitness data processing, performance analytics, and training plan generation.
Architecture Diagram
┌─────────────────────────────────────────────────────────────────┐
│ Client Layer │
├─────────────────────────────────────────────────────────────────┤
│ Web Browser (HTML/CSS/JS) │
│ - index.html (Main Application) │
│ - admin.html (Admin Dashboard) │
│ - training_plan_view.html (Plan Viewer) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Application Layer │
├─────────────────────────────────────────────────────────────────┤
│ Flask Web Framework │
│ ├── routes.py (API Endpoints & Controllers) │
│ ├── models.py (Data Models) │
│ └── __init__.py (App Factory) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Service Layer │
├─────────────────────────────────────────────────────────────────┤
│ Business Logic & Processing │
│ ├── file_processor.py (FIT File Processing) │
│ ├── statistics_processor.py (Metrics Calculation) │
│ ├── runner_history_processor.py (Historical Analysis) │
│ ├── training_plan_generator.py (Plan Generation) │
│ ├── session_statistics.py (Session Analysis) │
│ ├── critical_speed.py (Critical Speed Calculation) │
│ ├── heart_rate_calculator.py (HR Zone Calculation) │
│ └── job_manager.py (Background Tasks) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Data Layer │
├─────────────────────────────────────────────────────────────────┤
│ MongoDB Database │
│ ├── database.py (Connection & Basic Operations) │
│ ├── Collections (runner, sessions, statistics, etc.) │
│ └── GridFS (Binary File Storage) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ External Services │
├─────────────────────────────────────────────────────────────────┤
│ MongoDB Atlas (Cloud Database) │
└─────────────────────────────────────────────────────────────────┘
Technology Stack
Core Technologies
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | HTML5, CSS3, JavaScript | User interface |
| CSS Framework | Bootstrap | Responsive design |
| Visualization | Chart.js | Data visualization |
| Backend Framework | Flask 3.0.0 | Web application framework |
| Runtime | Python 3.11-3.13 | Core programming language |
| Database | MongoDB | NoSQL document storage |
| File Storage | GridFS | Binary file storage |
| Containerization | Docker & Docker Compose | Deployment & development |
Python Libraries
| Library | Version | Purpose |
|---|---|---|
| Flask | 3.0.0 | Web framework |
| Flask-CORS | 4.0.0 | Cross-origin resource sharing |
| pymongo | 4.5.0 | MongoDB driver |
| pandas | 2.2.3 | Data manipulation (Python 3.11-3.13 compatible) |
| numpy | 1.26.4 | Numerical computing (Python 3.11-3.13 compatible) |
| scipy | 1.14.1 | Scientific computing (Python 3.11-3.13 compatible) |
| scikit-learn | 1.5.2 | Machine learning (Critical Speed regression) |
| pyarrow | 18.0.0 | Parquet file support (Python 3.11-3.13 compatible) |
| certifi | 2024.8.30 | SSL/TLS certificate bundle provider |
| python-dotenv | 1.0.0 | Environment management |
| dnspython | 2.4.2 | DNS resolution for MongoDB |