# nbulteau/mystravastats-2 architecture

> Architecture diagram of the GitHub repository nbulteau/mystravastats-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nbulteau/mystravastats-2
- Repository: https://github.com/nbulteau/mystravastats-2

## Overview

##### Main Components
- Frontend: The “front-vue” directory contains the Vue.js application, including views, components, services, stores, and routing logic.
- Backend API(s): There are two backend implementations:
- “back-go”: A Go-based backend that follows a layered architecture with packages for adapters (integrating with both local and Strava APIs), API (controllers, routing, and DTOs), and domain (business logic, services, statistics calculations, and helpers).
- “back-kotlin”: A Kotlin-based backend with a similar layered structure, featuring modules for adapters (e.g., local repositories, Strava integration, terrain data), API (REST controllers, DTOs, configuration), and a domain layer (including business services, statistics services, and interfaces).
- Domain/Business Core: Both backends have a rich domain layer that encapsulates business rules, data models, and statistical calculations used for various activity-related metrics.
- External Services Integration: Integration with the Strava API for obtaining user activity data (using OAuth2 flow—as indicated by the README’s explanation) and local activity data caching.
- CSV Exporting: Services to generate CSV files with the computed statistics.

##### Relationships and Data Flow
- Both backend implementations expose HTTP endpoints (controllers/handlers) that receive API requests, convert data via DTOs, and delegate processing to business logic.
- The Backend’s API Layer calls into the Domain Layer (services, business logic, and statistics computation modules). Show these as internal calls within the backend.
- The Domain Layer might fetch or update data through the Adapters layer, which includes integration with:
- Strava API (for retrieving activity data).
- Local storage systems and file-based data (such as the “strava-cache” directory).
- Computation results (statistics) are then returned through the layered structure from the Domain back to the API layer and finally to the Frontend.

##### Architectural Patterns and Design Principles
- Layered Architecture (or hexagonal architecture): Separate concerns into layers—Adapters (for external integrations), Domain/Business (core rule and computation logic), and API/Controllers (presentation of services).
- Interface Abstraction: Both implementations use interfaces (e.g., ILocalStorage, IStravaApi) to abstract away data fetching and processing, important for extensibility and future testing.

##### Technologies and Frameworks
- Frontend: Vue.js with TypeScript, along with supporting libraries for routing and state management.
- Backend (Kotlin version): Spring Boot (as evidenced by the “ServletInitializer” and application configuration files) and Gradle as the build system.

##### Specific Elements
- Data/request flow from the Frontend to Backend.
- Internal calls from API Controllers to Domain Services.
- External calls from the Domain to external sources (Strava API, local cache).
- Clearly Omit Docker Workflows: Exclude any references to Docker containers or orchestration details since the instructions require removing Docker specifics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    FE("Vue Frontend"):::frontend

    %% Go Backend Implementation
    subgraph "Go Backend Implementation"
        G_API("Go Backend API (Controllers, DTOs)"):::api
        G_Domain("Go Domain & Business Logic"):::domain
        G_Adapters("Go External Integrations (Adapters)"):::adapters
    end

    %% Kotlin Backend Implementation
    subgraph "Kotlin Backend Implementation"
        K_API("Kotlin Backend API (Controllers, DTOs)"):::api
        K_Domain("Kotlin Domain & Business Core"):::domain
        K_Adapters("Kotlin External Integrations (Adapters)"):::adapters
        CSV("CSV Exporting Service"):::csv
    end

    %% External Integrations
    STRAVA("Strava API"):::external
    LOCAL("Local Data Cache"):::external

    %% Connections: Frontend to Backends
    FE -->|"sendsRequest"| G_API
    FE -->|"sendsRequest"| K_API

    %% Go Backend internal flow
    G_API -->|"delegatesTo"| G_Domain
    G_Domain -->|"calls"| G_Adapters

    %% Kotlin Backend internal flow
    K_API -->|"delegatesTo"| K_Domain
    K_Domain -->|"calls"| K_Adapters
    K_Domain -->|"exportsCSV"| CSV

    %% Adapters to External Services
    G_Adapters -->|"fetchesData"| STRAVA
    G_Adapters -->|"fetchesData"| LOCAL
    K_Adapters -->|"fetchesData"| STRAVA
    K_Adapters -->|"fetchesData"| LOCAL

    %% Click Events
    click FE "https://github.com/nbulteau/mystravastats-2/tree/main/front-vue"
    click G_API "https://github.com/nbulteau/mystravastats-2/tree/main/back-go/api"
    click G_Domain "https://github.com/nbulteau/mystravastats-2/tree/main/back-go/domain"
    click G_Adapters "https://github.com/nbulteau/mystravastats-2/tree/main/back-go/adapters"
    click K_API "https://github.com/nbulteau/mystravastats-2/tree/main/back-kotlin/src/main/kotlin/me/nicolas/stravastats/api"
    click K_Domain "https://github.com/nbulteau/mystravastats-2/tree/main/back-kotlin/src/main/kotlin/me/nicolas/stravastats/domain"
    click K_Adapters "https://github.com/nbulteau/mystravastats-2/tree/main/back-kotlin/src/main/kotlin/me/nicolas/stravastats/adapters"
    click CSV "https://github.com/nbulteau/mystravastats-2/tree/main/back-kotlin/src/main/kotlin/me/nicolas/stravastats/domain/services/csv"

    %% Styles
    classDef frontend fill:#7FDBFF,stroke:#0074D9,stroke-width:2px;
    classDef api fill:#2ECC40,stroke:#28A745,stroke-width:2px;
    classDef domain fill:#FF851B,stroke:#FF4136,stroke-width:2px;
    classDef adapters fill:#FFDC00,stroke:#FF851B,stroke-width:2px;
    classDef csv fill:#B10DC9,stroke:#85144b,stroke-width:2px;
    classDef external fill:#FF4136,stroke:#85144b,stroke-width:2px;
```
