# xbaank/madridtransporte-front architecture

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

- Interactive diagram: https://gitdiagram.com/xbaank/madridtransporte-front
- Repository: https://github.com/xbaank/madridtransporte-front

## Overview

##### Main Components
- Frontend Web Application – The core user interface and business logic implemented with React/TypeScript.
- Native Mobile Wrapper – The “android” folder hosts an Android project configured with Gradle and Capacitor to package the web app for mobile devices.
- Build & Deployment Pipeline – Tools and configuration files (Vite config, environment files, GitHub workflows, npm scripts) that manage building, testing, and deploying the application.
- External Service Integrations – Components such as Firebase (see firebase-messaging-sw.js), Maps, and any backend API endpoints (linked in the README pointing to the backend repository).

##### Relationships and Interactions
- UI Components (e.g., MobileNavBar, StopMap, AbonoNFC, etc.)
- That UI Components interact with an API layer—the “api” directories inside “components” (for stops, abono, etc.)—which in turn communicates with the external backend service (linked in the README) via HTTP or WebSocket calls.
- Connections to external services:
- Firebase for push notifications or messaging.
- Google Maps or other mapping APIs (as seen in “public/maps” and the mapping components).
- Incorporate the Mobile/Capacitor component:

##### Architectural Patterns
- Clearly separate the application layers – the presentation (UI), the business logic (React components, contexts, hooks), and the integration/API layer.
- Modular design. The project groups related functionality in directories (for abono, stops, etc.) implying component-based architecture.
- Use of environment configurations (.env.development, .env.production) to manage different deployment scenarios.
- Mention the build/deployment pipeline with GitHub workflows as part of the overall ecosystem.

##### Technologies and Frameworks
- Vite for build and development.
- React/TypeScript for the application logic.
- Tailwind CSS for styling (tailwind.config.js).
- Capacitor for enabling a native Android experience.
- Gradle for Android build configuration.
- Firebase (for messaging) and Google services (google-services.json in Android).
- GitHub Actions for CI/CD as seen in the “.github/workflows” directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        F["Frontend UI (React/TS)"]:::frontend
        I["Index (index.tsx)"]:::entry
        C["UI Components"]:::component
        CH["Contexts & Hooks"]:::component2
        API["API Layer (HTTP/WebSocket)"]:::api
    end

    %% External Integrations
    subgraph "External Integrations"
        FB["Firebase Messaging"]:::external
        GM["Google Maps"]:::external
    end

    %% Mobile Platform
    subgraph "Mobile Platform"
        CAP["Capacitor Wrapper (Android)"]:::mobile
    end

    %% Build & Deployment Pipeline
    subgraph "Build & Deployment Pipeline"
        BC["Build Config (Vite & Env)"]:::pipeline
        GHA["CI/CD (GitHub Actions)"]:::pipeline
        VCONFIG["vite.config.ts"]:::file
        ENVDEV[".env.development"]:::file
        ENVPROD[".env.production"]:::file
        ENVSAMPLE[".env.sample"]:::file
        PKG["package.json"]:::file
        WORKFLOWS[".github/workflows"]:::file
    end

    %% External Service (Backend)
    subgraph "External Service"
        BE["External Backend Service"]:::backend
    end

    %% Relationships and Data Flow
    F --> I
    I --> C
    C -->|"calls"| API
    API -->|"sendsRequestTo"| BE

    C -->|"integratesWith"| FB
    C -->|"integratesWith"| GM

    F --> CAP
    F --> BC
    F --> GHA

    %% Grouping Build Config subitems (invisible relationships for layout)
    BC --- VCONFIG
    BC --- ENVDEV
    BC --- ENVPROD
    BC --- ENVSAMPLE
    BC --- PKG
    GHA --- WORKFLOWS

    %% Click Events
    click F "https://github.com/xbaank/madridtransporte-front/tree/master/src"
    click I "https://github.com/xbaank/madridtransporte-front/blob/master/src/index.tsx"
    click C "https://github.com/xbaank/madridtransporte-front/tree/master/src/components"
    click CAP "https://github.com/xbaank/madridtransporte-front/tree/master/android"
    click VCONFIG "https://github.com/xbaank/madridtransporte-front/blob/master/vite.config.ts"
    click ENVDEV "https://github.com/xbaank/madridtransporte-front/blob/master/.env.development"
    click ENVPROD "https://github.com/xbaank/madridtransporte-front/blob/master/.env.production"
    click ENVSAMPLE "https://github.com/xbaank/madridtransporte-front/blob/master/.env.sample"
    click PKG "https://github.com/xbaank/madridtransporte-front/blob/master/package.json"
    click WORKFLOWS "https://github.com/xbaank/madridtransporte-front/tree/master/.github/workflows"
    click FB "https://github.com/xbaank/madridtransporte-front/blob/master/public/firebase-messaging-sw.js"
    click GM "https://github.com/xbaank/madridtransporte-front/tree/master/public/maps"

    %% Styles
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef entry fill:#cfc,stroke:#333,stroke-width:2px;
    classDef component fill:#fcf,stroke:#333,stroke-width:2px;
    classDef component2 fill:#ffc,stroke:#333,stroke-width:2px;
    classDef api fill:#def,stroke:#333,stroke-width:2px;
    classDef backend fill:#fdd,stroke:#333,stroke-width:2px;
    classDef external fill:#dfd,stroke:#333,stroke-width:2px;
    classDef mobile fill:#fbb,stroke:#333,stroke-width:2px;
    classDef pipeline fill:#ffd,stroke:#333,stroke-width:2px;
    classDef file fill:#eee,stroke:#333,stroke-width:1px;
```
