How atalasluis/clinica_whatsapp works
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: app.ts Express API · schema.prisma Prisma data access · architecture.md Architecture documentation · main.tsx React entry
Components 14
Frontend
- React entry
frontend/src/main.tsx - Operator/admin UI · Current top-level UI composition.
frontend/src/App.tsx - Vite dev server
frontend/vite.config.ts
Backend API
- API process · Starts the Express service and binds its port.
backend/src/server.ts - Express API · Owns middleware, routes, and future workflow interfaces.
backend/src/app.ts - Clinic workflows · Planned contact, conversation, response, and appointment orchestration.
- WhatsApp adapter · Planned isolated provider webhook and dispatch adapter.
- Botpress/AI adapter · Planned isolated assistance and sales response adapter.
Persistence
- Prisma data access · Backend-owned persistence access layer.
backend/prisma/schema.prisma - Prisma configuration
backend/prisma.config.ts - Supabase PostgreSQL · Public-schema PostgreSQL reached through the Session Pooler.
External integrations
- WhatsApp provider
- Botpress / AI
Other components
- Architecture documentation · Describes the evolving technical architecture.
docs/architecture.md
Connections 14
- 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