# trainin-entrenamientos/trainin architecture

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

- Interactive diagram: https://gitdiagram.com/trainin-entrenamientos/trainin
- Repository: https://github.com/trainin-entrenamientos/trainin

## Overview

##### Project type and purpose
- This is an Angular single-page application (SPA) front-end (Trainin).
- Purpose: Provide a user interface for fitness training—user authentication, plan creation, exercise execution (with posture-correction), progress tracking, payment (Mercado Pago), notifications, and music integration (Spotify).

##### File structure
- Top-level configuration: angular.json, tsconfig*, package.json, cypress/ (e2e), karma.conf.js (unit tests), public/ (static assets), environments/ (runtime flags), vercel.json (deployment).
- src/app/
– app.module.ts + app-routing.module.ts (root module & routes)
– compartido/ (SharedModule: reusable UI components, pipes, utilities)
– core/ (CoreModule: services, models/DTOs, guards, HTTP interceptors, token utils)
– vistas/ (feature pages grouped by route: login, registro, crear-plan, corrección-postura, ejercicio-diario, perfil, planes, historial, etc.)
- src/firebase-messaging-sw.js (service worker for push notifications)
- cypress.config.ts and tests under cypress/ ensure end-to-end coverage.

##### README
- Minimal: “Proyecto Trainin – Frontend” confirms front-end focus.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Angular Modules
    subgraph "Angular Modules"
        AppModule["AppModule"]:::module
        AppRouting["AppRoutingModule"]:::module
        SharedModule["SharedModule"]:::shared
        CoreModule["CoreModule"]:::core
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        FV["Feature Views"]:::view
        SC["Shared UI Components"]:::shared
        SpotifyUI["Spotify Component"]:::shared
        PaymentView["Payment Success View"]:::view
    end

    %% Application Layer
    subgraph "Application Layer"
        AuthService["AuthService"]:::service
        EjService["EjercicioService"]:::service
        CorrDataService["CorrectionDataService"]:::service
        HandlerFactory["HandlerFactory"]:::service
        BlazeHandlers["BlazePose Handlers"]:::handler
        SpotifyService["SpotifyService"]:::service
        MercadoService["MercadoPagoService"]:::service
        Interceptor["Auth Interceptor"]:::interceptor
        AuthGuard["AuthGuard"]:::guard
        AdminGuard["AdminGuard"]:::guard
    end

    %% Data Models
    subgraph "Data Models"
        Models["DTOs (Models)"]:::model
        Interfaces["Interfaces"]:::model
        Enums["Enums"]:::model
    end

    %% Service Worker
    subgraph "Service Worker"
        FCM["Firebase Messaging SW"]:::sw
    end

    %% External Systems
    AuthAPI["Auth API"]:::external
    ExAPI["Exercise API"]:::external
    SpotifyAPI["Spotify API"]:::external
    MPagoAPI["Mercado Pago API"]:::external
    PushEndpoint["Firebase Push Endpoint"]:::external

    %% Relationships
    AppModule -->|imports| AppRouting
    AppModule -->|imports| SharedModule
    AppModule -->|imports| CoreModule

    FV -->|uses| SC
    FV -->|calls| AuthService
    FV -->|calls| EjService
    FV -->|calls| CorrDataService
    FV -->|calls| SpotifyService
    FV -->|calls| MercadoService

    SC -->|provides| SpotifyUI

    AuthService -->|uses| Interceptor
    EjService -->|uses| Interceptor
    CorrDataService -->|uses| Interceptor
    SpotifyService -->|uses| Interceptor
    MercadoService -->|uses| Interceptor

    AuthService -->|POST /login| AuthAPI
    AuthService -->|POST /register| AuthAPI
    EjService -->|GET /exercises| ExAPI
    CorrDataService -->|local stream| HandlerFactory
    HandlerFactory -->|instantiates| BlazeHandlers
    BlazeHandlers -->|analysis results| FV

    SpotifyService -->|Web API calls| SpotifyAPI
    MercadoService -->|SDK calls| MPagoAPI
    FCM -->|listens to| PushEndpoint

    %% Models & Interfaces
    AuthService -->|maps| Models
    EjService -->|maps| Models
    FV -->|binds to| Models
    Services("---"):::separator
    CoreModule -->|provides| Interfaces
    SharedModule -->|provides| Interfaces
    SharedModule -->|provides| Enums

    %% Guards
    AppRouting -->|protects routes| AuthGuard
    AppRouting -->|protects routes| AdminGuard

    %% Click Events
    click SharedModule "https://github.com/trainin-entrenamientos/trainin/tree/main/src/app/compartido/"
    click FV "https://github.com/trainin-entrenamientos/trainin/tree/main/src/app/vistas/"
    click AppModule "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/app.module.ts"
    click AppRouting "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/app-routing.module.ts"
    click AuthService "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/authServicio/auth.service.ts"
    click EjService "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/EjercicioServicio/ejercicio.service.ts"
    click CorrDataService "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/correccionPosturaServicio/correccion-data.service.ts"
    click HandlerFactory "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/correccionPosturaServicio/fabrica-manejadores.service.ts"
    click BlazeHandlers "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/vistas/correccion-postura/manejadores/*.handler.ts"
    click SpotifyService "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/spotifyServicio/spotify.service.ts"
    click SpotifyUI "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/compartido/componentes/spotify/spotify.component.ts"
    click MercadoService "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/servicios/mercadoPagoServicio/mercado-pago.service.ts"
    click PaymentView "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/vistas/pago-exitoso/pago-exitoso.component.ts"
    click Interceptor "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/interceptores/auth.interceptor.ts"
    click AuthGuard "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/guardias/auth/auth.guard.ts"
    click AdminGuard "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/guardias/admin/admin.guard.ts"
    click Models "https://github.com/trainin-entrenamientos/trainin/tree/main/src/app/core/modelos/"
    click Interfaces "https://github.com/trainin-entrenamientos/trainin/tree/main/src/app/compartido/interfaces/"
    click Enums "https://github.com/trainin-entrenamientos/trainin/tree/main/src/app/compartido/enums/"
    click FCM "https://github.com/trainin-entrenamientos/trainin/blob/main/src/firebase-messaging-sw.js"
    click TokenUtils "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/core/utilidades/token-utils.ts"
    click PostureUtils "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/compartido/utilidades/correccion-postura.utils.ts"
    click DateUtils "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/compartido/utilidades/fecha.utils.ts"
    click ToastrUtils "https://github.com/trainin-entrenamientos/trainin/blob/main/src/app/compartido/utilidades/errores-toastr.ts"

    %% Styles
    classDef module fill:#f9f,stroke:#333,stroke-width:1px
    classDef shared fill:#bbf,stroke:#333,stroke-width:1px
    classDef core fill:#bfb,stroke:#333,stroke-width:1px
    classDef view fill:#ff9,stroke:#333
    classDef service fill:#9ff,stroke:#333
    classDef interceptor fill:#f99,stroke:#333
    classDef guard fill:#fdd,stroke:#333
    classDef model fill:#fbf,stroke:#333
    classDef external fill:#ccc,stroke:#333,stroke-dasharray:5 5
    classDef handler fill:#f0f,stroke:#333
    classDef sw fill:#cdf,stroke:#333
```
