# imsusanta/helpa architecture

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

- Interactive diagram: https://gitdiagram.com/imsusanta/helpa
- Repository: https://github.com/imsusanta/helpa

## Overview

Helpa is a clinic-focused WhatsApp receptionist and patient-communications platform. Its main workflow is: a patient messages the clinic, an inbound webhook feeds the AI workflow, the system checks availability and confirms appointments, then sends confirmations and reminders; staff can review or take over conversations. The product also includes contact/lead management, campaigns and automations, voice calling, and tenant administration. The graph combines README-described capabilities with relationships visible in the supplied source index and excerpts; unsampled wiring is omitted where it cannot be verified.

Main entry points: [`src/app/api/whatsapp/send/route.ts`](https://github.com/imsusanta/helpa/blob/main/src/app/api/whatsapp/send/route.ts) (Send messages), [`src/lib/supabase/server.ts`](https://github.com/imsusanta/helpa/blob/main/src/lib/supabase/server.ts) (Supabase database), [`src/core/providers/whatsapp`](https://github.com/imsusanta/helpa/tree/main/src/core/providers/whatsapp) (WhatsApp channels), [`src/core/ai/engine.ts`](https://github.com/imsusanta/helpa/blob/main/src/core/ai/engine.ts) (AI receptionist)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_messaging["Messaging and AI"]
  node_whatsapp["WhatsApp channels"]
  node_inbound["Inbound webhook<br/>[route.ts]"]
  node_ai["AI receptionist<br/>[engine.ts]"]
  node_outbound["Send messages<br/>[route.ts]"]
  node_meta_api["Meta API helpers<br/>[meta-api.ts]"]
end

subgraph group_care["Clinic workflow"]
  node_inbox["Conversation inbox<br/>[page.tsx]"]
  node_appointments["Appointments<br/>[route.ts]"]
  node_patients["Patient records<br/>[route.ts]"]
  node_reminders["Follow-up reminders<br/>[route.ts]"]
  node_contacts["Contacts and leads<br/>[route.ts]"]
end

subgraph group_engagement["Automation and outreach"]
  node_automations["Automation engine<br/>[engine.ts]"]
  node_flows["Flow engine<br/>[engine.ts]"]
  node_campaigns["Broadcast campaigns<br/>[route.ts]"]
  node_voice["AI calling<br/>[route.ts]"]
end

subgraph group_platform["Platform services"]
  node_auth["Session and tenant guard<br/>[account.ts]"]
  node_database[("Supabase database<br/>[server.ts]")]
end

node_patient(("Patient"))
node_staff(("Clinic staff"))

node_patient -->|"messages clinic"| node_whatsapp
node_whatsapp -->|"delivers events"| node_inbound
node_inbound -->|"feeds workflow"| node_ai
node_ai -->|"checks availability"| node_appointments
node_appointments -.->|"confirms booking"| node_outbound
node_reminders -.->|"sends reminders"| node_outbound
node_staff -->|"reviews conversations"| node_inbox
node_inbox -.->|"sends replies"| node_outbound
node_outbound -->|"requires agent role"| node_auth
node_outbound -->|"sends messages"| node_meta_api
node_outbound -->|"selects provider"| node_whatsapp
node_outbound -->|"persists outbound"| node_database
node_automations -->|"reads and writes"| node_database
node_automations -->|"sends messages"| node_outbound
node_flows -->|"reads and writes"| node_database
node_campaigns -->|"loads campaign data"| node_database
node_campaigns -.->|"sends campaign messages"| node_outbound
node_voice -->|"uses AI provider"| node_ai
node_auth -->|"authenticates and scopes"| node_database
node_patients -.->|"stores records"| node_database
node_contacts -.->|"stores contacts"| node_database

click node_whatsapp "https://github.com/imsusanta/helpa/tree/main/src/core/providers/whatsapp"
click node_inbound "https://github.com/imsusanta/helpa/blob/main/src/app/api/whatsapp/webhook/route.ts"
click node_ai "https://github.com/imsusanta/helpa/blob/main/src/core/ai/engine.ts"
click node_outbound "https://github.com/imsusanta/helpa/blob/main/src/app/api/whatsapp/send/route.ts"
click node_meta_api "https://github.com/imsusanta/helpa/blob/main/src/lib/whatsapp/meta-api.ts"
click node_inbox "https://github.com/imsusanta/helpa/blob/main/src/app/(dashboard)/inbox/page.tsx"
click node_appointments "https://github.com/imsusanta/helpa/blob/main/src/app/api/appointments/route.ts"
click node_patients "https://github.com/imsusanta/helpa/blob/main/src/app/api/patients/%5Bid%5D/route.ts"
click node_reminders "https://github.com/imsusanta/helpa/blob/main/src/app/api/cron/reminders/route.ts"
click node_contacts "https://github.com/imsusanta/helpa/blob/main/src/app/api/contacts/route.ts"
click node_automations "https://github.com/imsusanta/helpa/blob/main/src/lib/automations/engine.ts"
click node_flows "https://github.com/imsusanta/helpa/blob/main/src/lib/flows/engine.ts"
click node_campaigns "https://github.com/imsusanta/helpa/blob/main/src/app/api/cron/campaigns/route.ts"
click node_voice "https://github.com/imsusanta/helpa/blob/main/src/app/api/voice/outbound/route.ts"
click node_auth "https://github.com/imsusanta/helpa/blob/main/src/lib/auth/account.ts"
click node_database "https://github.com/imsusanta/helpa/blob/main/src/lib/supabase/server.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_whatsapp,node_inbound,node_ai,node_outbound,node_meta_api toneBlue
class node_inbox,node_appointments,node_patients,node_reminders,node_contacts toneAmber
class node_automations,node_flows,node_campaigns,node_voice toneMint
class node_auth,node_database toneRose
class node_patient,node_staff toneIndigo
```

## Components

### Messaging and AI

- [WhatsApp channels](https://github.com/imsusanta/helpa/tree/main/src/core/providers/whatsapp): `src/core/providers/whatsapp`
- [Inbound webhook](https://github.com/imsusanta/helpa/blob/main/src/app/api/whatsapp/webhook/route.ts): `src/app/api/whatsapp/webhook/route.ts`
- [AI receptionist](https://github.com/imsusanta/helpa/blob/main/src/core/ai/engine.ts): `src/core/ai/engine.ts`
- [Send messages](https://github.com/imsusanta/helpa/blob/main/src/app/api/whatsapp/send/route.ts): `src/app/api/whatsapp/send/route.ts`
- [Meta API helpers](https://github.com/imsusanta/helpa/blob/main/src/lib/whatsapp/meta-api.ts): `src/lib/whatsapp/meta-api.ts`

### Clinic workflow

- [Conversation inbox](https://github.com/imsusanta/helpa/blob/main/src/app/(dashboard)/inbox/page.tsx): `src/app/(dashboard)/inbox/page.tsx`
- [Appointments](https://github.com/imsusanta/helpa/blob/main/src/app/api/appointments/route.ts): `src/app/api/appointments/route.ts`
- [Patient records](https://github.com/imsusanta/helpa/blob/main/src/app/api/patients/%5Bid%5D/route.ts): `src/app/api/patients/[id]/route.ts`
- [Follow-up reminders](https://github.com/imsusanta/helpa/blob/main/src/app/api/cron/reminders/route.ts): `src/app/api/cron/reminders/route.ts`
- [Contacts and leads](https://github.com/imsusanta/helpa/blob/main/src/app/api/contacts/route.ts): `src/app/api/contacts/route.ts`

### Automation and outreach

- [Automation engine](https://github.com/imsusanta/helpa/blob/main/src/lib/automations/engine.ts): `src/lib/automations/engine.ts`
- [Flow engine](https://github.com/imsusanta/helpa/blob/main/src/lib/flows/engine.ts): `src/lib/flows/engine.ts`
- [Broadcast campaigns](https://github.com/imsusanta/helpa/blob/main/src/app/api/cron/campaigns/route.ts): `src/app/api/cron/campaigns/route.ts`
- [AI calling](https://github.com/imsusanta/helpa/blob/main/src/app/api/voice/outbound/route.ts): `src/app/api/voice/outbound/route.ts`

### Platform services

- [Session and tenant guard](https://github.com/imsusanta/helpa/blob/main/src/lib/auth/account.ts): `src/lib/auth/account.ts`
- [Supabase database](https://github.com/imsusanta/helpa/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Other components

- **Patient**
- **Clinic staff**

## Connections

- Patient → WhatsApp channels: messages clinic (evidence: `README.md`)
- WhatsApp channels → Inbound webhook: delivers events (evidence: `README.md`)
- Inbound webhook → AI receptionist: feeds workflow (evidence: `README.md`)
- AI receptionist → Appointments: checks availability (evidence: `README.md`)
- Appointments → Send messages: confirms booking
- Follow-up reminders → Send messages: sends reminders
- Clinic staff → Conversation inbox: reviews conversations (evidence: `README.md`)
- Conversation inbox → Send messages: sends replies
- Send messages → Session and tenant guard: requires agent role (evidence: `src/app/api/whatsapp/send/route.ts`)
- Send messages → Meta API helpers: sends messages (evidence: `src/app/api/whatsapp/send/route.ts`)
- Send messages → WhatsApp channels: selects provider (evidence: `src/app/api/whatsapp/send/route.ts`)
- Send messages → Supabase database: persists outbound (evidence: `src/app/api/whatsapp/send/route.ts`)
- Automation engine → Supabase database: reads and writes (evidence: `src/lib/automations/engine.ts`)
- Automation engine → Send messages: sends messages
- Flow engine → Supabase database: reads and writes (evidence: `src/lib/flows/engine.ts`)
- Broadcast campaigns → Supabase database: loads campaign data (evidence: `src/app/api/cron/campaigns/route.ts`)
- Broadcast campaigns → Send messages: sends campaign messages
- AI calling → AI receptionist: uses AI provider
- Session and tenant guard → Supabase database: authenticates and scopes (evidence: `src/lib/auth/account.ts`)
- Patient records → Supabase database: stores records
- Contacts and leads → Supabase database: stores contacts
