# pricardok/agendafacil architecture

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

- Interactive diagram: https://gitdiagram.com/pricardok/agendafacil
- Repository: https://github.com/pricardok/agendafacil

## Overview

Agendamento Já is a multi-tenant appointment-booking SaaS, with a separate Admin back office sharing the PostgreSQL database. The principal customer flow is a public booking request through the PWA, which checks service and professional availability and creates appointments; tenant staff then manage appointments and professionals. Other major product areas include subscriptions and payment processing, messaging, and scheduled jobs. The map combines documented capabilities with indexed source references; unsampled implementation details and integration wiring are left unverified where necessary.

Main entry points: [`AgendaPro_Backend/app/routes/pwa_routes.py`](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/pwa_routes.py) (Public booking PWA), [`AgendaPro_Backend/app/main.py`](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/main.py) (Backend API), [`AgendaPro_Admin/app/main.py`](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/main.py) (Admin API), [`AgendaPro_Backend/app/routes/admin_agendamento_routes.py`](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/admin_agendamento_routes.py) (Appointment management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_booking["Booking &amp; Tenants"]
  node_pwa["Public booking PWA<br/>[pwa_routes.py]"]
  node_booking_service["Appointment services"]
  node_appointments[("Appointments<br/>[agendamento.py]")]
  node_tenant_records[("Tenant records")]
end

subgraph group_operations["Tenant Operations"]
  node_staff_routes["Professional management"]
  node_staff_schedule[("Professional availability")]
  node_admin_appointments["Appointment management"]
  node_anamnesis["Anamnesis records"]
end

subgraph group_platform["Platform Admin"]
  node_admin_api["Admin API<br/>[main.py]"]
  node_admin_auth["Admin authentication<br/>[auth_routes.py]"]
  node_tenant_admin["Tenant administration"]
  node_subscription_admin["Subscription management"]
end

subgraph group_integrations["Payments &amp; Messaging"]
  node_payment_provider["Payment providers"]
  node_stripe_webhook["Stripe webhooks"]
  node_efi_webhook["EFI webhooks"]
  node_whatsapp["WhatsApp messaging"]
  node_email["Email notifications<br/>[email_service.py]"]
end

subgraph group_foundation["Shared Foundation"]
  node_backend_api["Backend API<br/>[main.py]"]
  node_database[("Shared PostgreSQL<br/>[database_core.py]")]
  node_schedulers["Background schedulers"]
end

node_customer(("Booking customer"))
node_tenant_staff(("Tenant staff"))

node_customer -->|"books through"| node_pwa
node_pwa -->|"checks availability"| node_booking_service
node_pwa -.->|"creates bookings"| node_appointments
node_pwa -->|"checks schedules"| node_staff_schedule
node_tenant_staff -->|"manages bookings"| node_admin_appointments
node_admin_appointments -->|"delegates to"| node_booking_service
node_admin_appointments -->|"reads and writes"| node_appointments
node_staff_routes -->|"manages availability"| node_staff_schedule
node_anamnesis -.->|"supports care records"| node_appointments
node_backend_api -->|"registers routes"| node_pwa
node_admin_api -->|"registers routes"| node_admin_auth
node_admin_api -->|"registers routes"| node_tenant_admin
node_admin_api -->|"registers routes"| node_subscription_admin
node_admin_auth -->|"reads admin records"| node_database
node_tenant_admin -->|"manages tenants"| node_tenant_records
node_subscription_admin -->|"generates charges"| node_payment_provider
node_backend_api -->|"configures provider"| node_payment_provider
node_stripe_webhook -->|"handles payment events"| node_payment_provider
node_efi_webhook -->|"records webhook payments"| node_database
node_booking_service -.->|"sends reminders"| node_whatsapp
node_backend_api -->|"configures service"| node_email
node_schedulers -.->|"dispatches messages"| node_whatsapp
node_backend_api -->|"uses shared database"| node_database

click node_pwa "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/pwa_routes.py"
click node_booking_service "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/agendamento_service.py"
click node_appointments "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/models/agendamento.py"
click node_tenant_records "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/models/clientes_plataforma.py"
click node_staff_routes "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/profissional_admin_routes.py"
click node_staff_schedule "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/models/profissional_horario.py"
click node_admin_appointments "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/admin_agendamento_routes.py"
click node_anamnesis "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/anamnese_service.py"
click node_admin_api "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/main.py"
click node_admin_auth "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/auth_routes.py"
click node_tenant_admin "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/tenant_usuarios_routes.py"
click node_subscription_admin "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/assinaturas_routes.py"
click node_payment_provider "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/payment_provider_factory.py"
click node_stripe_webhook "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/webhooks/stripe_webhook_routes.py"
click node_efi_webhook "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/webhooks/efi_webhook_routes.py"
click node_whatsapp "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/waha_outbound_service_v2.py"
click node_email "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/email_service.py"
click node_backend_api "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/main.py"
click node_database "https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/database/database_core.py"
click node_schedulers "https://github.com/pricardok/agendafacil/tree/main/AgendaPro_Backend/app/schedulers"

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_booking_service,node_appointments,node_tenant_records toneBlue
class node_staff_routes,node_staff_schedule,node_admin_appointments,node_anamnesis toneAmber
class node_admin_api,node_admin_auth,node_tenant_admin,node_subscription_admin toneMint
class node_payment_provider,node_stripe_webhook,node_efi_webhook,node_whatsapp,node_email toneRose
class node_backend_api,node_database,node_schedulers,node_customer,node_tenant_staff toneIndigo
```

## Components

### Booking & Tenants

- [Public booking PWA](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/pwa_routes.py): `AgendaPro_Backend/app/routes/pwa_routes.py`
- [Appointment services](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/agendamento_service.py): `AgendaPro_Backend/app/services/agendamento_service.py`
- [Appointments](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/models/agendamento.py): `AgendaPro_Admin/app/models/agendamento.py`
- [Tenant records](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/models/clientes_plataforma.py): `AgendaPro_Admin/app/models/clientes_plataforma.py`

### Tenant Operations

- [Professional management](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/profissional_admin_routes.py): `AgendaPro_Backend/app/routes/profissional_admin_routes.py`
- [Professional availability](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/models/profissional_horario.py): `AgendaPro_Backend/app/models/profissional_horario.py`
- [Appointment management](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/admin_agendamento_routes.py): `AgendaPro_Backend/app/routes/admin_agendamento_routes.py`
- [Anamnesis records](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/anamnese_service.py): `AgendaPro_Backend/app/services/anamnese_service.py`

### Platform Admin

- [Admin API](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/main.py): `AgendaPro_Admin/app/main.py`
- [Admin authentication](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/auth_routes.py): `AgendaPro_Admin/app/routes/auth_routes.py`
- [Tenant administration](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/tenant_usuarios_routes.py): `AgendaPro_Admin/app/routes/tenant_usuarios_routes.py`
- [Subscription management](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/routes/assinaturas_routes.py): `AgendaPro_Admin/app/routes/assinaturas_routes.py`

### Payments & Messaging

- [Payment providers](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/payment_provider_factory.py): `AgendaPro_Backend/app/services/payment_provider_factory.py`
- [Stripe webhooks](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/webhooks/stripe_webhook_routes.py): `AgendaPro_Backend/app/routes/webhooks/stripe_webhook_routes.py`
- [EFI webhooks](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/routes/webhooks/efi_webhook_routes.py): `AgendaPro_Backend/app/routes/webhooks/efi_webhook_routes.py`
- [WhatsApp messaging](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/waha_outbound_service_v2.py): `AgendaPro_Backend/app/services/waha_outbound_service_v2.py`
- [Email notifications](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/services/email_service.py): `AgendaPro_Backend/app/services/email_service.py`

### Shared Foundation

- [Backend API](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Backend/app/main.py): `AgendaPro_Backend/app/main.py`
- [Shared PostgreSQL](https://github.com/pricardok/agendafacil/blob/main/AgendaPro_Admin/app/database/database_core.py): `AgendaPro_Admin/app/database/database_core.py`
- [Background schedulers](https://github.com/pricardok/agendafacil/tree/main/AgendaPro_Backend/app/schedulers): `AgendaPro_Backend/app/schedulers`

### Other components

- **Booking customer**
- **Tenant staff**

## Connections

- Booking customer → Public booking PWA: books through (evidence: `README.md`)
- Public booking PWA → Appointment services: checks availability (evidence: `AgendaPro_Backend/app/routes/pwa_routes.py`)
- Public booking PWA → Appointments: creates bookings (evidence: `AgendaPro_Backend/app/routes/pwa_routes.py`)
- Public booking PWA → Professional availability: checks schedules (evidence: `AgendaPro_Backend/app/routes/pwa_routes.py`)
- Tenant staff → Appointment management: manages bookings (evidence: `README.md`)
- Appointment management → Appointment services: delegates to (evidence: `AgendaPro_Backend/app/routes/admin_agendamento_routes.py`)
- Appointment management → Appointments: reads and writes (evidence: `AgendaPro_Backend/app/routes/admin_agendamento_routes.py`)
- Professional management → Professional availability: manages availability (evidence: `AgendaPro_Backend/app/routes/profissional_admin_routes.py`)
- Anamnesis records → Appointments: supports care records
- Backend API → Public booking PWA: registers routes (evidence: `AgendaPro_Backend/app/main.py`)
- Admin API → Admin authentication: registers routes (evidence: `AgendaPro_Admin/app/main.py`)
- Admin API → Tenant administration: registers routes (evidence: `AgendaPro_Admin/app/main.py`)
- Admin API → Subscription management: registers routes (evidence: `AgendaPro_Admin/app/main.py`)
- Admin authentication → Shared PostgreSQL: reads admin records (evidence: `AgendaPro_Admin/app/routes/auth_routes.py`)
- Tenant administration → Tenant records: manages tenants (evidence: `AgendaPro_Admin/app/routes/tenant_usuarios_routes.py`)
- Subscription management → Payment providers: generates charges (evidence: `AgendaPro_Admin/app/routes/assinaturas_routes.py`)
- Backend API → Payment providers: configures provider (evidence: `AgendaPro_Backend/app/main.py`)
- Stripe webhooks → Payment providers: handles payment events (evidence: `AgendaPro_Backend/app/routes/webhooks/stripe_webhook_routes.py`)
- EFI webhooks → Shared PostgreSQL: records webhook payments (evidence: `AgendaPro_Backend/app/routes/webhooks/efi_webhook_routes.py`)
- Appointment services → WhatsApp messaging: sends reminders
- Backend API → Email notifications: configures service (evidence: `AgendaPro_Backend/app/main.py`)
- Background schedulers → WhatsApp messaging: dispatches messages
- Backend API → Shared PostgreSQL: uses shared database (evidence: `README.md`)
