# arianablanco06/treksafe architecture

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

- Interactive diagram: https://gitdiagram.com/arianablanco06/treksafe
- Repository: https://github.com/arianablanco06/treksafe

## Overview

TrekSafe is a hiking-expedition planning and rescue-coordination platform. Hikers plan trips, prepare routes and equipment, track progress, and confirm their return; overdue trips trigger alerts for rescuers to coordinate, document, and close an incident. The frontend is a PWA, while the backend separates HTTP handling from a worker that monitors deadlines and processes a persistent notification queue. The README documents the product workflow and deployment; sampled sources confirm selected entry-point, composition, and outbox links, but most feature-level backend calls were not sampled.

Main entry points: [`backend/src/infrastructure/composicion/arranque.ts`](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/composicion/arranque.ts) (Worker composition), [`frontend/src/pages/PaginaCrearExpedicion.tsx`](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaCrearExpedicion.tsx) (Trip planning), [`frontend/src/pages/PaginaConsolaRescate.tsx`](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaConsolaRescate.tsx) (Rescue console), [`backend/src/application/services/WorkerOutboxNotificaciones.ts`](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/services/WorkerOutboxNotificaciones.ts) (Outbox processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["PWA and planning"]
  node_pwa["TrekSafe PWA<br/>[App.tsx]"]
  node_trip_planning["Trip planning"]
  node_offline_drafts["Offline drafts<br/>[offlineStorage.ts]"]
  node_frontend_api["API client<br/>[clienteApi.ts]"]
end

subgraph group_api["HTTP and application"]
  node_api_entry["API entry<br/>[api.ts]"]
  node_http_app["HTTP app<br/>[app.ts]"]
  node_http_routes["Feature routes"]
  node_expedition_service["Expedition services"]
end

subgraph group_rescue["Rescue operations"]
  node_rescue_console["Rescue console"]
  node_incident_coordination["Incident coordination"]
  node_incident_records["Incident records"]
  node_reports["Reports and stats"]
end

subgraph group_operations["Worker and integrations"]
  node_worker_entry["Worker entry<br/>[worker.ts]"]
  node_worker_composition["Worker composition<br/>[arranque.ts]"]
  node_deadline_jobs["Deadline jobs"]
  node_outbox_worker["Outbox processor"]
  node_outbox_store[("Notification outbox")]
  node_email_transport["Email transport<br/>[ServicioCorreo.ts]"]
  node_worker_state[("Worker health state")]
end

node_hiker(("Hiker"))
node_rescuer(("Rescuer"))
node_contacts(("Emergency contacts"))
node_supabase[("Supabase PostgreSQL<br/>[supabase.ts]")]

node_hiker -->|"uses"| node_pwa
node_rescuer -->|"uses"| node_pwa
node_pwa -->|"offers"| node_trip_planning
node_trip_planning -->|"supports drafts"| node_offline_drafts
node_trip_planning -->|"submits changes"| node_frontend_api
node_frontend_api -->|"calls REST"| node_api_entry
node_api_entry -->|"composes"| node_worker_composition
node_worker_composition -->|"creates app"| node_http_app
node_http_app -->|"mounts routes"| node_http_routes
node_http_routes -.->|"handles trip operations"| node_expedition_service
node_hiker -->|"plans expedition"| node_trip_planning
node_trip_planning -->|"sets return deadline"| node_deadline_jobs
node_deadline_jobs -->|"raises overdue alert"| node_rescue_console
node_rescuer -->|"reviews alerts"| node_rescue_console
node_rescue_console -->|"coordinates response"| node_incident_coordination
node_rescue_console -->|"records incident"| node_incident_records
node_rescue_console -->|"views reports"| node_reports
node_worker_entry -->|"starts worker"| node_worker_composition
node_worker_composition -->|"starts tasks"| node_deadline_jobs
node_worker_composition -->|"creates processor"| node_outbox_worker
node_outbox_worker -->|"leases and records"| node_outbox_store
node_outbox_worker -->|"sends messages"| node_email_transport
node_contacts -->|"receives alerts"| node_email_transport
node_worker_composition -->|"records worker status"| node_worker_state
node_worker_state -->|"queries availability"| node_supabase
node_outbox_store -.->|"persists queue"| node_supabase

click node_pwa "https://github.com/arianablanco06/treksafe/blob/main/frontend/src/app/App.tsx"
click node_trip_planning "https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaCrearExpedicion.tsx"
click node_offline_drafts "https://github.com/arianablanco06/treksafe/blob/main/frontend/src/lib/offlineStorage.ts"
click node_frontend_api "https://github.com/arianablanco06/treksafe/blob/main/frontend/src/services/clienteApi.ts"
click node_api_entry "https://github.com/arianablanco06/treksafe/blob/main/backend/src/api.ts"
click node_http_app "https://github.com/arianablanco06/treksafe/blob/main/backend/src/presentation/http/app.ts"
click node_http_routes "https://github.com/arianablanco06/treksafe/tree/main/backend/src/presentation/http/routes"
click node_expedition_service "https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/services/servicioExpedicion.ts"
click node_rescue_console "https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaConsolaRescate.tsx"
click node_incident_coordination "https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/AsignarResponsable.ts"
click node_incident_records "https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/AgregarEntradaBitacora.ts"
click node_reports "https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/ExportarReporteIncidentes.ts"
click node_worker_entry "https://github.com/arianablanco06/treksafe/blob/main/backend/src/worker.ts"
click node_worker_composition "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/composicion/arranque.ts"
click node_deadline_jobs "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/jobs/cronFechaLimiteExpedicion.ts"
click node_outbox_worker "https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/services/WorkerOutboxNotificaciones.ts"
click node_outbox_store "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/repositories/RepositorioOutboxSupabase.ts"
click node_email_transport "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/email/ServicioCorreo.ts"
click node_worker_state "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/repositories/EstadoWorkerSupabase.ts"
click node_supabase "https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/database/supabase.ts"

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_pwa,node_trip_planning,node_offline_drafts,node_frontend_api toneBlue
class node_api_entry,node_http_app,node_http_routes,node_expedition_service,node_supabase toneAmber
class node_rescue_console,node_incident_coordination,node_incident_records,node_reports toneMint
class node_worker_entry,node_worker_composition,node_deadline_jobs,node_outbox_worker,node_outbox_store,node_email_transport,node_worker_state toneRose
class node_hiker,node_rescuer,node_contacts toneIndigo
```

## Components

### PWA and planning

- [TrekSafe PWA](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/app/App.tsx): `frontend/src/app/App.tsx`
- [Trip planning](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaCrearExpedicion.tsx): `frontend/src/pages/PaginaCrearExpedicion.tsx`
- [Offline drafts](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/lib/offlineStorage.ts): `frontend/src/lib/offlineStorage.ts`
- [API client](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/services/clienteApi.ts): `frontend/src/services/clienteApi.ts`

### HTTP and application

- [API entry](https://github.com/arianablanco06/treksafe/blob/main/backend/src/api.ts): `backend/src/api.ts`
- [HTTP app](https://github.com/arianablanco06/treksafe/blob/main/backend/src/presentation/http/app.ts): `backend/src/presentation/http/app.ts`
- [Feature routes](https://github.com/arianablanco06/treksafe/tree/main/backend/src/presentation/http/routes): `backend/src/presentation/http/routes`
- [Expedition services](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/services/servicioExpedicion.ts): `backend/src/application/services/servicioExpedicion.ts`

### Rescue operations

- [Rescue console](https://github.com/arianablanco06/treksafe/blob/main/frontend/src/pages/PaginaConsolaRescate.tsx): `frontend/src/pages/PaginaConsolaRescate.tsx`
- [Incident coordination](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/AsignarResponsable.ts): `backend/src/application/use-cases/AsignarResponsable.ts`
- [Incident records](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/AgregarEntradaBitacora.ts): `backend/src/application/use-cases/AgregarEntradaBitacora.ts`
- [Reports and stats](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/use-cases/ExportarReporteIncidentes.ts): `backend/src/application/use-cases/ExportarReporteIncidentes.ts`

### Worker and integrations

- [Worker entry](https://github.com/arianablanco06/treksafe/blob/main/backend/src/worker.ts): `backend/src/worker.ts`
- [Worker composition](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/composicion/arranque.ts): `backend/src/infrastructure/composicion/arranque.ts`
- [Deadline jobs](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/jobs/cronFechaLimiteExpedicion.ts): `backend/src/infrastructure/jobs/cronFechaLimiteExpedicion.ts`
- [Outbox processor](https://github.com/arianablanco06/treksafe/blob/main/backend/src/application/services/WorkerOutboxNotificaciones.ts): `backend/src/application/services/WorkerOutboxNotificaciones.ts`
- [Notification outbox](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/repositories/RepositorioOutboxSupabase.ts): `backend/src/infrastructure/repositories/RepositorioOutboxSupabase.ts`
- [Email transport](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/email/ServicioCorreo.ts): `backend/src/infrastructure/email/ServicioCorreo.ts`
- [Worker health state](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/repositories/EstadoWorkerSupabase.ts): `backend/src/infrastructure/repositories/EstadoWorkerSupabase.ts`

### Other components

- **Hiker**
- **Rescuer**
- **Emergency contacts**
- [Supabase PostgreSQL](https://github.com/arianablanco06/treksafe/blob/main/backend/src/infrastructure/database/supabase.ts): `backend/src/infrastructure/database/supabase.ts`

## Connections

- Hiker → TrekSafe PWA: uses
- Rescuer → TrekSafe PWA: uses
- TrekSafe PWA → Trip planning: offers
- Trip planning → Offline drafts: supports drafts
- Trip planning → API client: submits changes
- API client → API entry: calls REST
- API entry → Worker composition: composes (evidence: `backend/src/api.ts`)
- Worker composition → HTTP app: creates app (evidence: `backend/src/infrastructure/composicion/arranque.ts`)
- HTTP app → Feature routes: mounts routes (evidence: `backend/src/presentation/http/app.ts`)
- Feature routes → Expedition services: handles trip operations
- Hiker → Trip planning: plans expedition
- Trip planning → Deadline jobs: sets return deadline
- Deadline jobs → Rescue console: raises overdue alert
- Rescuer → Rescue console: reviews alerts
- Rescue console → Incident coordination: coordinates response
- Rescue console → Incident records: records incident
- Rescue console → Reports and stats: views reports
- Worker entry → Worker composition: starts worker (evidence: `backend/src/worker.ts`)
- Worker composition → Deadline jobs: starts tasks (evidence: `backend/src/infrastructure/composicion/arranque.ts`)
- Worker composition → Outbox processor: creates processor (evidence: `backend/src/infrastructure/composicion/arranque.ts`)
- Outbox processor → Notification outbox: leases and records (evidence: `backend/src/application/services/WorkerOutboxNotificaciones.ts`)
- Outbox processor → Email transport: sends messages (evidence: `backend/src/application/services/WorkerOutboxNotificaciones.ts`)
- Emergency contacts → Email transport: receives alerts
- Worker composition → Worker health state: records worker status (evidence: `backend/src/infrastructure/composicion/arranque.ts`)
- Worker health state → Supabase PostgreSQL: queries availability (evidence: `backend/src/infrastructure/repositories/EstadoWorkerSupabase.ts`)
- Notification outbox → Supabase PostgreSQL: persists queue
