How robiningelbrecht/statistics-for-strava works
Project type and purpose
• “Statistics for Strava” is a full-stack, self-hosted dashboard application built on Symfony (PHP).
• It fetches data from the Strava API, persists it locally, and renders interactive HTML pages (PWA) and badges.
Top-level components
• Dockerized services (docker-compose.yml):
• app (nginx + php-fpm)
• php-cli (for cron/console commands)
• database (MySQL/PostgreSQL) – not shown in the tree but implied
• Symfony application (Kernel.php, config/, src/, templates/, public/)
• Database (via Doctrine DBAL/migrations)
• CI/CD (GitHub Actions workflows)
Key interactions & flows
a. HTTP requests
• User browser → Nginx (docker/app) → PHP-FPM → Symfony HTTP kernel
• Controllers (AppRequestHandler, StravaOAuthRequestHandler) dispatch Query/Command via CQRS buses
• Handlers fetch data from repositories (Dbal*) or KeyValueStore, then render Twig templates → HTML/CSS/JS delivered to browser
b. Data import & site build
• Cron or manual trigger: php-cli container runs bin/console ImportStravaDataConsoleCommand → pulls from Strava API → persists via Doctrine → dispatches domain events if needed
• After import: bin/console BuildAppConsoleCommand (and other Build* commands) generate static HTML pages into a build directory → deployed under public/
c. External integrations
• Strava API (OAuth refresh, activities, segments, challenges)
• AI providers via Domain/Integration/AI (e.g., OpenAI, NeuronAI)
• Geocoding (Nominatim), Weather (OpenMeteo), Notifications (ntfy)
• Zwift (domain calculations only)
Architectural patterns & principles
• Layered architecture:
• Presentation: Controllers → Twig templates (templates/html, templates/svg)
• Application (Console commands + HTTP handlers) orchestrating CQRS commands/queries
• Domain: business models, command/query handlers under src/Domain
• Infrastructure: abstracted services (DBAL repositories, file system, event bus, serialization, Twig extensions) under src/Infrastructure
• CQRS: In-memory CommandBus & QueryBus decouple write vs read operations
• Dependency Injection & Symfony service container (config/services.yaml)
• Doctrine migrations for schema management