# ariasnahuel/tfc-estacionamiento architecture

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

- Interactive diagram: https://gitdiagram.com/ariasnahuel/tfc-estacionamiento
- Repository: https://github.com/ariasnahuel/tfc-estacionamiento

## Overview

TFC Estacionamiento is a browser-based parking system for entry and exit terminals plus an administrator panel. Users select a terminal, initiate a vehicle or reservation operation, and follow sensor-confirmed barrier progress; administrators manage reservations, credentials, settings, history, and manual controls. The UI reads state through a hook that selects an in-memory simulator or Supabase adapter. Supabase migrations provide the shared backend, while firmware exists in the repository but the README says physical control is not currently connected. Relationships reflect shown calls and documented backend behavior; unsampled firmware wiring is omitted.

Main entry points: [`src/services/supabaseParking.ts`](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/supabaseParking.ts) (Supabase parking adapter), [`src/pages/App.tsx`](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/pages/App.tsx) (Terminal and admin UI), [`src/hooks/useParking.ts`](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/hooks/useParking.ts) (Parking state hook), [`src/services/parkingStore.ts`](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/parkingStore.ts) (Local simulator store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser interfaces"]
  node_app["Terminal and admin UI<br/>[App.tsx]"]
  node_bootstrap["React app entry<br/>[main.tsx]"]
end

subgraph group_runtime["Parking runtime"]
  node_parking_hook["Parking state hook<br/>[useParking.ts]"]
  node_parking_rules["Parking rules<br/>[parking.ts]"]
  node_token_input["Token input normalization"]
  node_local_store["Local simulator store<br/>[parkingStore.ts]"]
  node_credential_service["Terminal credentials"]
end

subgraph group_backend["Shared backend"]
  node_supabase_adapter["Supabase parking adapter<br/>[supabaseParking.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_database[("Supabase database")]
end

subgraph group_device["Device firmware"]
  node_controller["ESP8266 controller<br/>[esp8266.ino]"]
  node_safety_logic["Controller safety logic<br/>[SafetyLogic.h]"]
  node_wifi_diagnostic["ESP8266 Wi-Fi diagnostic"]
end

node_visitor(("Parking user"))
node_admin(("Administrator"))

node_visitor -->|"uses terminals"| node_app
node_admin -->|"manages parking"| node_app
node_bootstrap -->|"renders"| node_app
node_app -->|"reads state"| node_parking_hook
node_parking_hook -->|"selects locally"| node_local_store
node_parking_hook -->|"selects remotely"| node_supabase_adapter
node_parking_hook -->|"checks configuration"| node_supabase_client
node_app -->|"validates credentials"| node_credential_service
node_local_store -->|"checks and applies"| node_parking_rules
node_local_store -->|"delegates when configured"| node_supabase_adapter
node_local_store -->|"checks configuration"| node_supabase_client
node_supabase_adapter -->|"reads credentials"| node_credential_service
node_supabase_adapter -->|"uses client"| node_supabase_client
node_supabase_adapter -->|"calls RPC and queries"| node_database

click node_app "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/pages/App.tsx"
click node_bootstrap "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/main.tsx"
click node_parking_hook "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/hooks/useParking.ts"
click node_parking_rules "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/domain/parking.ts"
click node_token_input "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/domain/reservationToken.ts"
click node_local_store "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/parkingStore.ts"
click node_credential_service "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/terminalCredentials.ts"
click node_supabase_adapter "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/supabaseParking.ts"
click node_supabase_client "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/lib/supabase.ts"
click node_database "https://github.com/ariasnahuel/tfc-estacionamiento/tree/main/supabase/migrations"
click node_controller "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266/esp8266.ino"
click node_safety_logic "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266/SafetyLogic.h"
click node_wifi_diagnostic "https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266_wifi_diagnostic/esp8266_wifi_diagnostic.ino"

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,node_bootstrap,node_visitor toneBlue
class node_parking_hook,node_parking_rules,node_token_input,node_local_store,node_credential_service toneAmber
class node_supabase_adapter,node_supabase_client,node_database toneMint
class node_controller,node_safety_logic,node_wifi_diagnostic toneRose
class node_admin toneIndigo
```

## Components

### Browser interfaces

- [Terminal and admin UI](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/pages/App.tsx): `src/pages/App.tsx`
- [React app entry](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/main.tsx): `src/main.tsx`

### Parking runtime

- [Parking state hook](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/hooks/useParking.ts): `src/hooks/useParking.ts`
- [Parking rules](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/domain/parking.ts): `src/domain/parking.ts`
- [Token input normalization](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/domain/reservationToken.ts): `src/domain/reservationToken.ts`
- [Local simulator store](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/parkingStore.ts): `src/services/parkingStore.ts`
- [Terminal credentials](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/terminalCredentials.ts): `src/services/terminalCredentials.ts`

### Shared backend

- [Supabase parking adapter](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/services/supabaseParking.ts): `src/services/supabaseParking.ts`
- [Supabase client](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Supabase database](https://github.com/ariasnahuel/tfc-estacionamiento/tree/main/supabase/migrations): `supabase/migrations`

### Device firmware

- [ESP8266 controller](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266/esp8266.ino): `firmware/esp8266/esp8266.ino`
- [Controller safety logic](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266/SafetyLogic.h): `firmware/esp8266/SafetyLogic.h`
- [ESP8266 Wi-Fi diagnostic](https://github.com/ariasnahuel/tfc-estacionamiento/blob/main/firmware/esp8266_wifi_diagnostic/esp8266_wifi_diagnostic.ino): `firmware/esp8266_wifi_diagnostic/esp8266_wifi_diagnostic.ino`

### Other components

- **Parking user**
- **Administrator**

## Connections

- Parking user → Terminal and admin UI: uses terminals (evidence: `README.md`)
- Administrator → Terminal and admin UI: manages parking (evidence: `README.md`)
- React app entry → Terminal and admin UI: renders (evidence: `src/main.tsx`)
- Terminal and admin UI → Parking state hook: reads state (evidence: `src/pages/App.tsx`)
- Parking state hook → Local simulator store: selects locally (evidence: `src/hooks/useParking.ts`)
- Parking state hook → Supabase parking adapter: selects remotely (evidence: `src/hooks/useParking.ts`)
- Parking state hook → Supabase client: checks configuration (evidence: `src/hooks/useParking.ts`)
- Terminal and admin UI → Terminal credentials: validates credentials (evidence: `src/pages/App.tsx`)
- Local simulator store → Parking rules: checks and applies (evidence: `src/services/parkingStore.ts`)
- Local simulator store → Supabase parking adapter: delegates when configured (evidence: `src/services/parkingStore.ts`)
- Local simulator store → Supabase client: checks configuration (evidence: `src/services/parkingStore.ts`)
- Supabase parking adapter → Terminal credentials: reads credentials (evidence: `src/services/supabaseParking.ts`)
- Supabase parking adapter → Supabase client: uses client (evidence: `src/services/supabaseParking.ts`)
- Supabase parking adapter → Supabase database: calls RPC and queries (evidence: `README.md`)
