# atalasluis/clinica_whatsapp architecture

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

- Interactive diagram: https://gitdiagram.com/atalasluis/clinica_whatsapp
- Repository: https://github.com/atalasluis/clinica_whatsapp

## Overview

#### Purpose and deployment shape
Clinic WhatsApp is an early-stage clinic automation system for WhatsApp-based customer service, sales, and appointment scheduling, with planned AI integration. It is split into independent Node.js API and React browser-client projects. PostgreSQL persistence is provisioned but currently has no tables.

#### Backend API runtime
The backend is a TypeScript/Node.js Express service. Its application composition and HTTP middleware/routes belong in `backend/src/app.ts`; process startup and port binding belong in `backend/src/server.ts`. This is the principal server-side boundary for future WhatsApp, Botpress, scheduling, and persistence integrations.

Paths:
- `backend/src/app.ts`
- `backend/src/server.ts`
- `backend/package.json`

#### Frontend runtime
The frontend is a Vite-served React TypeScript single-page application. `frontend/src/main.tsx` mounts the client, while `frontend/src/App.tsx` is the current top-level UI composition point. It should consume backend APIs rather than connect directly to Supabase, WhatsApp, or Botpress.

Paths:
- `frontend/src/main.tsx`
- `frontend/src/App.tsx`
- `frontend/vite.config.ts`

#### Persistence boundary
Prisma is the data-access boundary between backend business workflows and PostgreSQL. The intended database is Supabase-hosted PostgreSQL using its Session Pooler over IPv4, scoped to the `public` schema. `DATABASE_URL` is environment-provided and must remain outside source control. The schema is presently only a PostgreSQL datasource declaration; no domain models or migrations/tables exist yet.

Paths:
- `backend/prisma/schema.prisma`
- `backend/prisma.config.ts`
- `backend/.env.example`

#### Core future workflow
The intended control flow is: a WhatsApp message enters an external messaging integration, backend logic identifies or creates the patient/contact and conversation context, Botpress/AI determines an assistance or sales response, and appointment actions persist through Prisma to PostgreSQL. The backend returns or dispatches the generated response through the WhatsApp provider. The React UI is an operator/admin surface for viewing or managing the same backend-owned records.

#### External-service boundaries
WhatsApp and Botpress are named product dependencies but no adapter, webhook, client configuration, or Botpress implementation is present in the tree. Treat each as an isolated integration module behind backend interfaces; do not couple frontend code or Prisma models directly to provider payloads. Supabase is used as managed PostgreSQL, not as a stated application API/auth runtime.

#### Documentation and current maturity
Technical architecture documentation has a dedicated location, while the repository is still scaffold-level: frontend shell, Express entry points, and database connectivity configuration exist, but the database is empty and no explicit domain modules are visible.

Paths:
- `docs/architecture.md`
- `README.md`
- `frontend/README.md`

Main entry points: [`backend/src/app.ts`](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/src/app.ts) (Express API), [`backend/prisma/schema.prisma`](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/prisma/schema.prisma) (Prisma data access), [`docs/architecture.md`](https://github.com/atalasluis/clinica_whatsapp/blob/main/docs/architecture.md) (Architecture documentation), [`frontend/src/main.tsx`](https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/src/main.tsx) (React entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_react_entry["React entry<br/>browser bootstrap<br/>[main.tsx]"]
  node_react_app["Operator/admin UI<br/>React application<br/>[App.tsx]"]
  node_vite["Vite dev server<br/>frontend tooling<br/>[vite.config.ts]"]
end

subgraph group_backend["Backend API"]
  node_api_server["API process<br/>Node.js startup<br/>[server.ts]"]
  node_express_app["Express API<br/>HTTP composition<br/>[app.ts]"]
  node_workflow{{"Clinic workflows<br/>backend domain layer"}}
  node_whatsapp_adapter["WhatsApp adapter<br/>integration boundary"]
  node_botpress_adapter["Botpress/AI adapter<br/>integration boundary"]
end

subgraph group_data["Persistence"]
  node_prisma["Prisma data access<br/>ORM boundary<br/>[schema.prisma]"]
  node_prisma_config["Prisma configuration<br/>database setup<br/>[prisma.config.ts]"]
  node_postgres[("Supabase PostgreSQL<br/>managed database")]
end

subgraph group_external["External integrations"]
  node_whatsapp["WhatsApp provider<br/>external messaging"]
  node_botpress["Botpress / AI<br/>external AI service"]
end

node_architecture_docs["Architecture documentation<br/>[architecture.md]"]

node_vite -->|"serves"| node_react_entry
node_react_entry -->|"mounts"| node_react_app
node_react_app -->|"backend API calls"| node_express_app
node_api_server -->|"starts"| node_express_app
node_express_app -->|"routes requests to"| node_workflow
node_workflow -->|"persists records through"| node_prisma
node_prisma_config -->|"configures"| node_prisma
node_prisma -->|"PostgreSQL connection"| node_postgres
node_workflow -.->|"receives and dispatches messages"| node_whatsapp_adapter
node_whatsapp_adapter -.->|"provider API/webhooks"| node_whatsapp
node_workflow -.->|"requests responses"| node_botpress_adapter
node_botpress_adapter -.->|"AI integration"| node_botpress
node_architecture_docs -.->|"documents"| node_express_app
node_architecture_docs -.->|"documents"| node_prisma

click node_react_entry "https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/src/main.tsx"
click node_react_app "https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/src/App.tsx"
click node_vite "https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/vite.config.ts"
click node_api_server "https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/src/server.ts"
click node_express_app "https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/src/app.ts"
click node_prisma "https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/prisma/schema.prisma"
click node_prisma_config "https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/prisma.config.ts"
click node_architecture_docs "https://github.com/atalasluis/clinica_whatsapp/blob/main/docs/architecture.md"

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_react_entry,node_react_app,node_vite toneBlue
class node_api_server,node_express_app,node_workflow,node_whatsapp_adapter,node_botpress_adapter toneAmber
class node_prisma,node_prisma_config,node_postgres toneMint
class node_whatsapp,node_botpress toneRose
class node_architecture_docs toneNeutral
```

## Components

### Frontend

- [React entry](https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/src/main.tsx): browser bootstrap · `frontend/src/main.tsx`
- [Operator/admin UI](https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/src/App.tsx): React application · Current top-level UI composition. · `frontend/src/App.tsx`
- [Vite dev server](https://github.com/atalasluis/clinica_whatsapp/blob/main/frontend/vite.config.ts): frontend tooling · `frontend/vite.config.ts`

### Backend API

- [API process](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/src/server.ts): Node.js startup · Starts the Express service and binds its port. · `backend/src/server.ts`
- [Express API](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/src/app.ts): HTTP composition · Owns middleware, routes, and future workflow interfaces. · `backend/src/app.ts`
- **Clinic workflows**: backend domain layer · Planned contact, conversation, response, and appointment orchestration.
- **WhatsApp adapter**: integration boundary · Planned isolated provider webhook and dispatch adapter.
- **Botpress/AI adapter**: integration boundary · Planned isolated assistance and sales response adapter.

### Persistence

- [Prisma data access](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/prisma/schema.prisma): ORM boundary · Backend-owned persistence access layer. · `backend/prisma/schema.prisma`
- [Prisma configuration](https://github.com/atalasluis/clinica_whatsapp/blob/main/backend/prisma.config.ts): database setup · `backend/prisma.config.ts`
- **Supabase PostgreSQL**: managed database · Public-schema PostgreSQL reached through the Session Pooler.

### External integrations

- **WhatsApp provider**: external messaging
- **Botpress / AI**: external AI service

### Other components

- [Architecture documentation](https://github.com/atalasluis/clinica_whatsapp/blob/main/docs/architecture.md): documentation · Describes the evolving technical architecture. · `docs/architecture.md`

## Connections

- Vite dev server → React entry: serves
- React entry → Operator/admin UI: mounts
- Operator/admin UI → Express API: backend API calls
- API process → Express API: starts
- Express API → Clinic workflows: routes requests to
- Clinic workflows → Prisma data access: persists records through
- Prisma configuration → Prisma data access: configures
- Prisma data access → Supabase PostgreSQL: PostgreSQL connection
- Clinic workflows → WhatsApp adapter: receives and dispatches messages
- WhatsApp adapter → WhatsApp provider: provider API/webhooks
- Clinic workflows → Botpress/AI adapter: requests responses
- Botpress/AI adapter → Botpress / AI: AI integration
- Architecture documentation → Express API: documents
- Architecture documentation → Prisma data access: documents
