# jjulian10/quadra-aberta architecture

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

- Interactive diagram: https://gitdiagram.com/jjulian10/quadra-aberta
- Repository: https://github.com/jjulian10/quadra-aberta

## Overview

Quadra Aberta is a court-booking and arena-management web app. Players browse an arena’s schedule, make a reservation, and can use a reservation portal; managers authenticate to manage bookings and payments. The backend persists arenas, courts, bookings, and related records in Supabase, with Edge Functions supporting Pix payments, waitlists, and messaging. Push notifications are another product capability. The README describes the booking and admin experience; sampled source confirms several backend integrations, but does not show all frontend-to-function wiring, so uncertain links are omitted.

Main entry points: [`supabase/schema.sql`](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/schema.sql) (Supabase database), [`app.js`](https://github.com/jjulian10/quadra-aberta/blob/main/app.js) (Booking and admin UI), [`index.html`](https://github.com/jjulian10/quadra-aberta/blob/main/index.html) (Web page), [`supabase/functions/create-arena/index.ts`](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-arena/index.ts) (Arena creation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Booking and management"]
  node_site["Booking and admin UI<br/>[app.js]"]
  node_page["Web page<br/>[index.html]"]
  node_pushclient["Push client<br/>[push.js]"]
end

subgraph group_booking["Booking services"]
  node_arena_create["Arena creation<br/>[index.ts]"]
  node_reservation_portal["Reservation lookup<br/>[index.ts]"]
  node_waitlist["Waitlist enrollment<br/>[index.ts]"]
end

subgraph group_payments["Pix payments"]
  node_pix_create["Reservation Pix<br/>[index.ts]"]
  node_pix_check["Pix status check<br/>[index.ts]"]
  node_balance_create["Balance Pix<br/>[index.ts]"]
  node_balance_check["Balance status check<br/>[index.ts]"]
  node_webhook["Payment webhook<br/>[index.ts]"]
end

subgraph group_messaging["Messaging and push"]
  node_whatsapp_worker["WhatsApp message worker<br/>[index.ts]"]
  node_push_setup["Push subscription<br/>[index.ts]"]
  node_push_worker["Push delivery worker<br/>[index.ts]"]
  node_sw["Service worker<br/>[sw.js]"]
end

subgraph group_data["Supabase data"]
  node_db[("Supabase database<br/>[schema.sql]")]
  node_supabase_auth["Supabase Auth"]
end

node_player(("Player"))
node_manager(("Arena manager"))
node_mp["Mercado Pago"]
node_whatsapp["WhatsApp API"]

node_player -->|"opens"| node_page
node_manager -->|"opens"| node_page
node_page -->|"loads"| node_site
node_site -->|"reads and writes"| node_db
node_site -->|"invokes"| node_pushclient
node_site -->|"authenticates"| node_supabase_auth
node_arena_create -->|"validates user"| node_supabase_auth
node_arena_create -->|"creates arena"| node_db
node_reservation_portal -->|"reads reservation"| node_db
node_waitlist -->|"checks and records"| node_db
node_pix_create -->|"creates booking"| node_db
node_pix_create -->|"creates order"| node_mp
node_pix_check -->|"reads and updates"| node_db
node_pix_check -->|"checks order"| node_mp
node_balance_create -->|"reads and updates"| node_db
node_balance_create -->|"creates order"| node_mp
node_balance_check -->|"reads and updates"| node_db
node_balance_check -->|"checks order"| node_mp
node_mp -.->|"sends events"| node_webhook
node_webhook -->|"updates payment"| node_db
node_whatsapp_worker -->|"reads queue and booking"| node_db
node_whatsapp_worker -->|"sends templates"| node_whatsapp
node_push_setup -->|"manages subscriptions"| node_db
node_push_worker -->|"claims events and reads subscriptions"| node_db
node_push_worker -->|"delivers notification"| node_sw

click node_site "https://github.com/jjulian10/quadra-aberta/blob/main/app.js"
click node_page "https://github.com/jjulian10/quadra-aberta/blob/main/index.html"
click node_pushclient "https://github.com/jjulian10/quadra-aberta/blob/main/push.js"
click node_arena_create "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-arena/index.ts"
click node_reservation_portal "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/get-reservation/index.ts"
click node_waitlist "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/join-waitlist/index.ts"
click node_pix_create "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-pix-payment/index.ts"
click node_pix_check "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/check-pix-payment/index.ts"
click node_balance_create "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-reservation-balance-pix/index.ts"
click node_balance_check "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/check-reservation-balance-payment/index.ts"
click node_webhook "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/mercado-pago-webhook/index.ts"
click node_whatsapp_worker "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/process-whatsapp-messages/index.ts"
click node_push_setup "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/push-subscription/index.ts"
click node_push_worker "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/process-push-notifications/index.ts"
click node_sw "https://github.com/jjulian10/quadra-aberta/blob/main/public/sw.js"
click node_db "https://github.com/jjulian10/quadra-aberta/blob/main/supabase/schema.sql"

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_site,node_page,node_pushclient toneBlue
class node_arena_create,node_reservation_portal,node_waitlist toneAmber
class node_pix_create,node_pix_check,node_balance_create,node_balance_check,node_webhook,node_whatsapp toneMint
class node_whatsapp_worker,node_push_setup,node_push_worker,node_sw toneRose
class node_db,node_supabase_auth,node_player,node_manager,node_mp toneIndigo
```

## Components

### Booking and management

- [Booking and admin UI](https://github.com/jjulian10/quadra-aberta/blob/main/app.js): `app.js`
- [Web page](https://github.com/jjulian10/quadra-aberta/blob/main/index.html): `index.html`
- [Push client](https://github.com/jjulian10/quadra-aberta/blob/main/push.js): `push.js`

### Booking services

- [Arena creation](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-arena/index.ts): `supabase/functions/create-arena/index.ts`
- [Reservation lookup](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/get-reservation/index.ts): `supabase/functions/get-reservation/index.ts`
- [Waitlist enrollment](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/join-waitlist/index.ts): `supabase/functions/join-waitlist/index.ts`

### Pix payments

- [Reservation Pix](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-pix-payment/index.ts): `supabase/functions/create-pix-payment/index.ts`
- [Pix status check](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/check-pix-payment/index.ts): `supabase/functions/check-pix-payment/index.ts`
- [Balance Pix](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/create-reservation-balance-pix/index.ts): `supabase/functions/create-reservation-balance-pix/index.ts`
- [Balance status check](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/check-reservation-balance-payment/index.ts): `supabase/functions/check-reservation-balance-payment/index.ts`
- [Payment webhook](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/mercado-pago-webhook/index.ts): `supabase/functions/mercado-pago-webhook/index.ts`

### Messaging and push

- [WhatsApp message worker](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/process-whatsapp-messages/index.ts): `supabase/functions/process-whatsapp-messages/index.ts`
- [Push subscription](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/push-subscription/index.ts): `supabase/functions/push-subscription/index.ts`
- [Push delivery worker](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/functions/process-push-notifications/index.ts): `supabase/functions/process-push-notifications/index.ts`
- [Service worker](https://github.com/jjulian10/quadra-aberta/blob/main/public/sw.js): `public/sw.js`

### Supabase data

- [Supabase database](https://github.com/jjulian10/quadra-aberta/blob/main/supabase/schema.sql): `supabase/schema.sql`
- **Supabase Auth**

### Other components

- **Player**
- **Arena manager**
- **Mercado Pago**
- **WhatsApp API**

## Connections

- Player → Web page: opens
- Arena manager → Web page: opens
- Web page → Booking and admin UI: loads
- Booking and admin UI → Supabase database: reads and writes
- Booking and admin UI → Push client: invokes
- Booking and admin UI → Supabase Auth: authenticates
- Arena creation → Supabase Auth: validates user
- Arena creation → Supabase database: creates arena
- Reservation lookup → Supabase database: reads reservation
- Waitlist enrollment → Supabase database: checks and records
- Reservation Pix → Supabase database: creates booking
- Reservation Pix → Mercado Pago: creates order
- Pix status check → Supabase database: reads and updates
- Pix status check → Mercado Pago: checks order
- Balance Pix → Supabase database: reads and updates
- Balance Pix → Mercado Pago: creates order
- Balance status check → Supabase database: reads and updates
- Balance status check → Mercado Pago: checks order
- Mercado Pago → Payment webhook: sends events
- Payment webhook → Supabase database: updates payment
- WhatsApp message worker → Supabase database: reads queue and booking
- WhatsApp message worker → WhatsApp API: sends templates
- Push subscription → Supabase database: manages subscriptions
- Push delivery worker → Supabase database: claims events and reads subscriptions
- Push delivery worker → Service worker: delivers notification
