# afonsosousah/mgira architecture

> Architecture diagram of the GitHub repository afonsosousah/mgira, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/afonsosousah/mgira
- Repository: https://github.com/afonsosousah/mgira

## Overview

mGira is a browser-based companion app for Lisbon’s GIRA bike-share system. The main journey is to find a station or destination, inspect available bikes, plan a route, unlock a bike, and keep the trip synchronized through completion; account, trip-history, and usage-statistics features complement it. The README documents OpenLayers, Mapbox, Firebase, and VAIMOO integrations. The graph reflects the sampled calls and explicit documentation; several implementation details are unsampled, so uncertain proxy wiring is left unverified.

Main entry points: [`scripts/vaimoo.js`](https://github.com/afonsosousah/mgira/blob/main/scripts/vaimoo.js) (VAIMOO client), [`scripts/stations.js`](https://github.com/afonsosousah/mgira/blob/main/scripts/stations.js) (Stations), [`scripts/requests.js`](https://github.com/afonsosousah/mgira/blob/main/scripts/requests.js) (Request helper), [`scripts/routing.js`](https://github.com/afonsosousah/mgira/blob/main/scripts/routing.js) (Route planning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_map_routing["Map and routing"]
  node_app_shell["App shell<br/>[index.html]"]
  node_map_view["Map view<br/>[map.js]"]
  node_stations["Stations<br/>[stations.js]"]
  node_routing["Route planning<br/>[routing.js]"]
  node_navigation["Turn navigation<br/>[navigation.js]"]
end

subgraph group_ride_management["Bike and trip"]
  node_bike_actions["Bike actions<br/>[bikes.js]"]
  node_trip_sync["Trip sync<br/>[tripSync.js]"]
end

subgraph group_account_activity["Account and activity"]
  node_account["Account and stats<br/>[user.js]"]
  node_trip_history["Trip history<br/>[user.js]"]
end

subgraph group_service_integrations["Service integrations"]
  node_vaimoo_client["VAIMOO client<br/>[vaimoo.js]"]
  node_firestore_client["Firestore client<br/>[firestore.js]"]
  node_request_helper["Request helper<br/>[requests.js]"]
  node_php_proxy["PHP proxy<br/>[proxy.php]"]
  node_worker_proxy["Cloudflare proxy<br/>[proxy.js]"]
end

node_rider(("Rider"))
node_firebase[("Firebase")]
node_vaimoo_api["VAIMOO API"]
node_map_directions["Map directions"]

node_rider -->|"uses"| node_app_shell
node_map_view -->|"opens station"| node_stations
node_map_view -->|"views route"| node_routing
node_stations -->|"routes to station"| node_routing
node_stations -->|"subscribes bikes"| node_firestore_client
node_routing -->|"gets directions"| node_map_directions
node_rider -->|"navigates"| node_navigation
node_bike_actions -->|"starts and rates"| node_vaimoo_client
node_trip_sync -->|"subscribes stations"| node_firestore_client
node_trip_sync -->|"checks trip"| node_vaimoo_client
node_vaimoo_client -->|"calls API"| node_vaimoo_api
node_firestore_client -->|"reads live data"| node_firebase
node_account -->|"loads account"| node_vaimoo_client
node_account -->|"shows history"| node_trip_history
node_trip_history -.->|"loads trips"| node_vaimoo_client
node_vaimoo_client -.->|"uses proxy request"| node_request_helper
node_request_helper -.->|"may proxy via"| node_php_proxy
node_request_helper -.->|"may proxy via"| node_worker_proxy

click node_app_shell "https://github.com/afonsosousah/mgira/blob/main/index.html"
click node_map_view "https://github.com/afonsosousah/mgira/blob/main/scripts/map.js"
click node_stations "https://github.com/afonsosousah/mgira/blob/main/scripts/stations.js"
click node_routing "https://github.com/afonsosousah/mgira/blob/main/scripts/routing.js"
click node_navigation "https://github.com/afonsosousah/mgira/blob/main/scripts/navigation.js"
click node_bike_actions "https://github.com/afonsosousah/mgira/blob/main/scripts/bikes.js"
click node_trip_sync "https://github.com/afonsosousah/mgira/blob/main/scripts/tripSync.js"
click node_account "https://github.com/afonsosousah/mgira/blob/main/scripts/user.js"
click node_trip_history "https://github.com/afonsosousah/mgira/blob/main/scripts/user.js"
click node_vaimoo_client "https://github.com/afonsosousah/mgira/blob/main/scripts/vaimoo.js"
click node_firestore_client "https://github.com/afonsosousah/mgira/blob/main/scripts/firestore.js"
click node_request_helper "https://github.com/afonsosousah/mgira/blob/main/scripts/requests.js"
click node_php_proxy "https://github.com/afonsosousah/mgira/blob/main/proxy.php"
click node_worker_proxy "https://github.com/afonsosousah/mgira/blob/main/self-hosted-proxies/cloudflare/proxy.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_shell,node_map_view,node_stations,node_routing,node_navigation toneBlue
class node_bike_actions,node_trip_sync,node_firebase toneAmber
class node_account,node_trip_history,node_vaimoo_api toneMint
class node_vaimoo_client,node_firestore_client,node_request_helper,node_php_proxy,node_worker_proxy toneRose
class node_rider,node_map_directions toneIndigo
```

## Components

### Map and routing

- [App shell](https://github.com/afonsosousah/mgira/blob/main/index.html): `index.html`
- [Map view](https://github.com/afonsosousah/mgira/blob/main/scripts/map.js): `scripts/map.js`
- [Stations](https://github.com/afonsosousah/mgira/blob/main/scripts/stations.js): `scripts/stations.js`
- [Route planning](https://github.com/afonsosousah/mgira/blob/main/scripts/routing.js): `scripts/routing.js`
- [Turn navigation](https://github.com/afonsosousah/mgira/blob/main/scripts/navigation.js): `scripts/navigation.js`

### Bike and trip

- [Bike actions](https://github.com/afonsosousah/mgira/blob/main/scripts/bikes.js): `scripts/bikes.js`
- [Trip sync](https://github.com/afonsosousah/mgira/blob/main/scripts/tripSync.js): `scripts/tripSync.js`

### Account and activity

- [Account and stats](https://github.com/afonsosousah/mgira/blob/main/scripts/user.js): `scripts/user.js`
- [Trip history](https://github.com/afonsosousah/mgira/blob/main/scripts/user.js): `scripts/user.js`

### Service integrations

- [VAIMOO client](https://github.com/afonsosousah/mgira/blob/main/scripts/vaimoo.js): `scripts/vaimoo.js`
- [Firestore client](https://github.com/afonsosousah/mgira/blob/main/scripts/firestore.js): `scripts/firestore.js`
- [Request helper](https://github.com/afonsosousah/mgira/blob/main/scripts/requests.js): `scripts/requests.js`
- [PHP proxy](https://github.com/afonsosousah/mgira/blob/main/proxy.php): `proxy.php`
- [Cloudflare proxy](https://github.com/afonsosousah/mgira/blob/main/self-hosted-proxies/cloudflare/proxy.js): `self-hosted-proxies/cloudflare/proxy.js`

### Other components

- **Rider**
- **Firebase**
- **VAIMOO API**
- **Map directions**

## Connections

- Rider → App shell: uses (evidence: `README.md`)
- Map view → Stations: opens station (evidence: `scripts/map.js`)
- Map view → Route planning: views route (evidence: `scripts/map.js`)
- Stations → Route planning: routes to station (evidence: `scripts/stations.js`)
- Stations → Firestore client: subscribes bikes (evidence: `scripts/stations.js`)
- Route planning → Map directions: gets directions (evidence: `README.md`)
- Rider → Turn navigation: navigates (evidence: `README.md`)
- Bike actions → VAIMOO client: starts and rates (evidence: `scripts/bikes.js`)
- Trip sync → Firestore client: subscribes stations (evidence: `scripts/tripSync.js`)
- Trip sync → VAIMOO client: checks trip (evidence: `scripts/tripSync.js`)
- VAIMOO client → VAIMOO API: calls API (evidence: `scripts/vaimoo.js`)
- Firestore client → Firebase: reads live data (evidence: `README.md`)
- Account and stats → VAIMOO client: loads account (evidence: `scripts/user.js`)
- Account and stats → Trip history: shows history (evidence: `README.md`)
- Trip history → VAIMOO client: loads trips
- VAIMOO client → Request helper: uses proxy request
- Request helper → PHP proxy: may proxy via
- Request helper → Cloudflare proxy: may proxy via
