# obraga45/appointment_system architecture

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

- Interactive diagram: https://gitdiagram.com/obraga45/appointment_system
- Repository: https://github.com/obraga45/appointment_system

## Overview

TemVagas serves small businesses with public appointment booking, an owner dashboard for managing services and appointments, and WhatsApp confirmations and reminders. The main customer flow starts at a business booking page; the owner manages the resulting schedule from the app. The README documents optional deposits, client cancellation, and WhatsApp connection, while sampled server actions show service management and authentication using Prisma and optional Supabase Auth. Several booking, settings, and messaging implementations were not sampled, so their internal call relationships are not expanded.

Main entry points: [`actions/appointments.ts`](https://github.com/obraga45/appointment_system/blob/main/actions/appointments.ts) (Appointment actions), [`lib/reminders.ts`](https://github.com/obraga45/appointment_system/blob/main/lib/reminders.ts) (Reminder dispatch), [`components/booking-wizard.tsx`](https://github.com/obraga45/appointment_system/blob/main/components/booking-wizard.tsx) (Booking wizard), [`actions/auth.ts`](https://github.com/obraga45/appointment_system/blob/main/actions/auth.ts) (Account actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public booking"]
  node_public_page["Booking page"]
  node_booking_wizard["Booking wizard<br/>[booking-wizard.tsx]"]
  node_cancel_page["Cancel booking<br/>[page.tsx]"]
  node_cancel_form["Cancellation form"]
end

subgraph group_workspace["Owner workspace"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_appointments_ui["Appointments<br/>[page.tsx]"]
  node_new_appointment["Manual booking"]
  node_services_page["Services page<br/>[page.tsx]"]
  node_services_manager["Service manager"]
  node_settings_page["Settings page<br/>[page.tsx]"]
  node_settings_forms["Business settings<br/>[settings-forms.tsx]"]
end

subgraph group_operations["Booking operations"]
  node_appointment_actions["Appointment actions<br/>[appointments.ts]"]
  node_service_actions["Service actions<br/>[services.ts]"]
  node_availability["Availability rules<br/>[availability.ts]"]
  node_whatsapp_cancel["Message cancellation<br/>[whatsapp-cancel.ts]"]
end

subgraph group_messaging["WhatsApp messaging"]
  node_reminders["Reminder dispatch<br/>[reminders.ts]"]
  node_qstash_route["QStash endpoint<br/>[route.ts]"]
  node_cron_route["Cron endpoint<br/>[route.ts]"]
  node_notifications["Notifications<br/>[notifications.ts]"]
  node_evolution["WhatsApp provider<br/>[evolution.ts]"]
  node_webhook["WhatsApp webhook<br/>[route.ts]"]
end

subgraph group_identity["Identity and data"]
  node_db[("PostgreSQL")]
  node_auth_actions["Account actions<br/>[auth.ts]"]
  node_auth["User authentication<br/>[auth.ts]"]
  node_supabase_auth["Supabase Auth"]
end

node_customer(("Customer"))
node_owner(("Business owner"))
node_whatsapp_service["Business WhatsApp"]

node_customer -->|"opens booking"| node_public_page
node_public_page -->|"presents booking"| node_booking_wizard
node_customer -->|"books appointment"| node_booking_wizard
node_customer -->|"opens cancel link"| node_cancel_page
node_cancel_page -->|"renders form"| node_cancel_form
node_customer -->|"cancels booking"| node_cancel_form
node_owner -->|"views schedule"| node_dashboard
node_owner -->|"manages appointments"| node_appointments_ui
node_owner -->|"creates appointment"| node_new_appointment
node_owner -->|"manages services"| node_services_page
node_services_page -->|"renders manager"| node_services_manager
node_services_manager -->|"calls service actions"| node_service_actions
node_service_actions -->|"reads and writes"| node_db
node_owner -->|"configures business"| node_settings_page
node_settings_page -->|"renders settings"| node_settings_forms
node_owner -->|"updates appointments"| node_appointment_actions
node_appointment_actions -.->|"stores appointments"| node_db
node_booking_wizard -.->|"submits booking"| node_appointment_actions
node_appointment_actions -.->|"checks availability"| node_availability
node_auth_actions -->|"reads and writes"| node_db
node_auth_actions -->|"uses when configured"| node_supabase_auth
node_auth -->|"loads user profile"| node_db
node_auth -->|"checks session when configured"| node_supabase_auth
node_qstash_route -->|"dispatches reminders"| node_reminders
node_cron_route -->|"dispatches reminders"| node_reminders
node_reminders -->|"reads appointments"| node_db
node_reminders -->|"sends notices"| node_notifications
node_notifications -.->|"sends messages"| node_evolution
node_evolution -->|"delivers WhatsApp"| node_whatsapp_service
node_whatsapp_service -->|"posts events"| node_webhook
node_webhook -->|"handles cancellation"| node_whatsapp_cancel
node_whatsapp_cancel -.->|"cancels next visit"| node_appointment_actions

click node_public_page "https://github.com/obraga45/appointment_system/blob/main/components/public-booking-page.tsx"
click node_booking_wizard "https://github.com/obraga45/appointment_system/blob/main/components/booking-wizard.tsx"
click node_cancel_page "https://github.com/obraga45/appointment_system/blob/main/app/agendar/cancel/%5Btoken%5D/page.tsx"
click node_cancel_form "https://github.com/obraga45/appointment_system/blob/main/components/cancel-booking-form.tsx"
click node_dashboard "https://github.com/obraga45/appointment_system/blob/main/app/(app)/dashboard/page.tsx"
click node_appointments_ui "https://github.com/obraga45/appointment_system/blob/main/app/(app)/appointments/page.tsx"
click node_new_appointment "https://github.com/obraga45/appointment_system/blob/main/components/new-appointment-form.tsx"
click node_services_page "https://github.com/obraga45/appointment_system/blob/main/app/(app)/services/page.tsx"
click node_services_manager "https://github.com/obraga45/appointment_system/blob/main/components/services-manager.tsx"
click node_settings_page "https://github.com/obraga45/appointment_system/blob/main/app/(app)/settings/page.tsx"
click node_settings_forms "https://github.com/obraga45/appointment_system/blob/main/components/settings-forms.tsx"
click node_appointment_actions "https://github.com/obraga45/appointment_system/blob/main/actions/appointments.ts"
click node_service_actions "https://github.com/obraga45/appointment_system/blob/main/actions/services.ts"
click node_availability "https://github.com/obraga45/appointment_system/blob/main/lib/availability.ts"
click node_auth_actions "https://github.com/obraga45/appointment_system/blob/main/actions/auth.ts"
click node_auth "https://github.com/obraga45/appointment_system/blob/main/lib/auth.ts"
click node_reminders "https://github.com/obraga45/appointment_system/blob/main/lib/reminders.ts"
click node_qstash_route "https://github.com/obraga45/appointment_system/blob/main/app/api/qstash/reminders/route.ts"
click node_cron_route "https://github.com/obraga45/appointment_system/blob/main/app/api/cron/reminders/route.ts"
click node_notifications "https://github.com/obraga45/appointment_system/blob/main/lib/notifications.ts"
click node_evolution "https://github.com/obraga45/appointment_system/blob/main/lib/evolution.ts"
click node_webhook "https://github.com/obraga45/appointment_system/blob/main/app/api/webhooks/evolution/route.ts"
click node_whatsapp_cancel "https://github.com/obraga45/appointment_system/blob/main/lib/whatsapp-cancel.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_public_page,node_booking_wizard,node_cancel_page,node_cancel_form toneBlue
class node_dashboard,node_appointments_ui,node_new_appointment,node_services_page,node_services_manager,node_settings_page,node_settings_forms toneAmber
class node_appointment_actions,node_service_actions,node_availability,node_whatsapp_cancel toneMint
class node_reminders,node_qstash_route,node_cron_route,node_notifications,node_evolution,node_webhook toneRose
class node_db,node_auth_actions,node_auth,node_supabase_auth,node_customer,node_owner,node_whatsapp_service toneIndigo
```

## Components

### Public booking

- [Booking page](https://github.com/obraga45/appointment_system/blob/main/components/public-booking-page.tsx): `components/public-booking-page.tsx`
- [Booking wizard](https://github.com/obraga45/appointment_system/blob/main/components/booking-wizard.tsx): `components/booking-wizard.tsx`
- [Cancel booking](https://github.com/obraga45/appointment_system/blob/main/app/agendar/cancel/%5Btoken%5D/page.tsx): `app/agendar/cancel/[token]/page.tsx`
- [Cancellation form](https://github.com/obraga45/appointment_system/blob/main/components/cancel-booking-form.tsx): `components/cancel-booking-form.tsx`

### Owner workspace

- [Dashboard](https://github.com/obraga45/appointment_system/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`
- [Appointments](https://github.com/obraga45/appointment_system/blob/main/app/(app)/appointments/page.tsx): `app/(app)/appointments/page.tsx`
- [Manual booking](https://github.com/obraga45/appointment_system/blob/main/components/new-appointment-form.tsx): `components/new-appointment-form.tsx`
- [Services page](https://github.com/obraga45/appointment_system/blob/main/app/(app)/services/page.tsx): `app/(app)/services/page.tsx`
- [Service manager](https://github.com/obraga45/appointment_system/blob/main/components/services-manager.tsx): `components/services-manager.tsx`
- [Settings page](https://github.com/obraga45/appointment_system/blob/main/app/(app)/settings/page.tsx): `app/(app)/settings/page.tsx`
- [Business settings](https://github.com/obraga45/appointment_system/blob/main/components/settings-forms.tsx): `components/settings-forms.tsx`

### Booking operations

- [Appointment actions](https://github.com/obraga45/appointment_system/blob/main/actions/appointments.ts): `actions/appointments.ts`
- [Service actions](https://github.com/obraga45/appointment_system/blob/main/actions/services.ts): `actions/services.ts`
- [Availability rules](https://github.com/obraga45/appointment_system/blob/main/lib/availability.ts): `lib/availability.ts`
- [Message cancellation](https://github.com/obraga45/appointment_system/blob/main/lib/whatsapp-cancel.ts): `lib/whatsapp-cancel.ts`

### WhatsApp messaging

- [Reminder dispatch](https://github.com/obraga45/appointment_system/blob/main/lib/reminders.ts): `lib/reminders.ts`
- [QStash endpoint](https://github.com/obraga45/appointment_system/blob/main/app/api/qstash/reminders/route.ts): `app/api/qstash/reminders/route.ts`
- [Cron endpoint](https://github.com/obraga45/appointment_system/blob/main/app/api/cron/reminders/route.ts): `app/api/cron/reminders/route.ts`
- [Notifications](https://github.com/obraga45/appointment_system/blob/main/lib/notifications.ts): `lib/notifications.ts`
- [WhatsApp provider](https://github.com/obraga45/appointment_system/blob/main/lib/evolution.ts): `lib/evolution.ts`
- [WhatsApp webhook](https://github.com/obraga45/appointment_system/blob/main/app/api/webhooks/evolution/route.ts): `app/api/webhooks/evolution/route.ts`

### Identity and data

- **PostgreSQL**
- [Account actions](https://github.com/obraga45/appointment_system/blob/main/actions/auth.ts): `actions/auth.ts`
- [User authentication](https://github.com/obraga45/appointment_system/blob/main/lib/auth.ts): `lib/auth.ts`
- **Supabase Auth**

### Other components

- **Customer**
- **Business owner**
- **Business WhatsApp**

## Connections

- Customer → Booking page: opens booking
- Booking page → Booking wizard: presents booking
- Customer → Booking wizard: books appointment
- Customer → Cancel booking: opens cancel link
- Cancel booking → Cancellation form: renders form (evidence: `app/agendar/cancel/[token]/page.tsx`)
- Customer → Cancellation form: cancels booking
- Business owner → Dashboard: views schedule
- Business owner → Appointments: manages appointments
- Business owner → Manual booking: creates appointment
- Business owner → Services page: manages services
- Services page → Service manager: renders manager (evidence: `app/(app)/services/page.tsx`)
- Service manager → Service actions: calls service actions (evidence: `components/services-manager.tsx`)
- Service actions → PostgreSQL: reads and writes (evidence: `actions/services.ts`)
- Business owner → Settings page: configures business
- Settings page → Business settings: renders settings (evidence: `app/(app)/settings/page.tsx`)
- Business owner → Appointment actions: updates appointments
- Appointment actions → PostgreSQL: stores appointments
- Booking wizard → Appointment actions: submits booking
- Appointment actions → Availability rules: checks availability
- Account actions → PostgreSQL: reads and writes (evidence: `actions/auth.ts`)
- Account actions → Supabase Auth: uses when configured (evidence: `actions/auth.ts`)
- User authentication → PostgreSQL: loads user profile (evidence: `lib/auth.ts`)
- User authentication → Supabase Auth: checks session when configured (evidence: `lib/auth.ts`)
- QStash endpoint → Reminder dispatch: dispatches reminders (evidence: `app/api/qstash/reminders/route.ts`)
- Cron endpoint → Reminder dispatch: dispatches reminders (evidence: `app/api/cron/reminders/route.ts`)
- Reminder dispatch → PostgreSQL: reads appointments (evidence: `lib/reminders.ts`)
- Reminder dispatch → Notifications: sends notices (evidence: `lib/reminders.ts`)
- Notifications → WhatsApp provider: sends messages
- WhatsApp provider → Business WhatsApp: delivers WhatsApp
- Business WhatsApp → WhatsApp webhook: posts events
- WhatsApp webhook → Message cancellation: handles cancellation (evidence: `app/api/webhooks/evolution/route.ts`)
- Message cancellation → Appointment actions: cancels next visit
