Skip to content

Case 02 · SaaS for clinics · 2025 – present

Dental Smart.

SaaS for dental clinics. I’ve owned its engineering since 2025: multi-tenant with RLS, NFS-e invoices, WhatsApp and AI appointment transcription in production.

Fact sheet

Role
Architecture, back end and AI
Period
2025 – present
Stack
Next.js 16 · React 19 · Supabase · Postgres RLS · Edge Functions · Groq
AI
In production · Appointment transcription and summary
  • Clinics

    ~20active clinics

  • Churn

    0no clinic has cancelled

  • AI

    Feb 2026appointment transcription in production

01 / Problem

The whole clinic in one system.

RLSone tenant per clinic · isolated in the database

Dental clinics needed scheduling, finance, NFS-e invoices and WhatsApp in one system. And each clinic can only see its own data, because this is patient health data.

I talked to dentists, receptionists and dental assistants.

02 / Context

From the database to the front end.

The product already existed when I took over its engineering. I made it multi-tenant, with one tenant per clinic, and I’m still building it.

03 / My role

Engineering end to end.

3.1

Engineering.

  • Multi-tenant SaaS in Next.js and Supabase, with RLS isolation
  • Appointment transcription and summary with Whisper and Llama
  • WhatsApp message queue with LLM-generated variations
  • NFS-e via Focus NFe and contract signing over WhatsApp
  • SaaS admin to provision clinics
  • CI on GitHub Actions and database backups to R2
3.2

Scope.

  • Scheduling, patients and treatment plans
  • Finance with P&L, and a CRM funnel tied to WhatsApp
  • Inventory, prosthetics and reports

04 / Architecture

Isolation in the database.

Fig. 01Multi-tenant
  1. Web appNext.js 16 · VercelAPI routesprivileged operations
  2. Supabaseuser JWT · RLS by tenant_id
  3. Edge FunctionsDeno
  4. IntegrationsWhatsApp · Focus NFe · Groq

One clinic, one tenant · pg_dump backup to R2

Fig. 02Transcription and summary
  1. Recordingbrowser
  2. Storageper clinic
  3. Edge FunctionDeno
  4. WhisperGroq · transcription
  5. Llama 3.3 70BGroq · summary
  6. Resultsaved per clinic

In production since Feb 2026

05 / Where AI comes in

In the appointment, not the finances.

Transcription
In productionWhisper large-v3-turbo transcribes the appointment recording. Llama 3.3 70B summarizes it. Both run on Groq.
Messages
An LLM writes variations of the WhatsApp messages. Sending runs from a scheduled queue. It is not an agent.
Reconciliation
DecisionRule-based, no AI.

06 / Decisions and trade-offs

Where AI stayed out.

  1. 6.1
    Not used

    Reconciliation without AI.

    I decided not to use AI in bank reconciliation. It stayed rule-based: CSV column auto-detection and dedupe. The OFX import was removed in Apr 2026 as an unused feature.

  2. 6.2

    Tenant isolation via RLS.

    Each clinic is a tenant. The browser talks to Supabase with the user’s JWT, and RLS by tenant_id isolates the data in Postgres.

  3. 6.3

    Server-only privileges.

    User management, contract signing, NFS-e and PDFs go through Next API routes, with the admin client on the server.

  4. 6.4

    Text variation, not an agent.

    The LLM only rewrites the message. A cron-driven queue triggers the sending. No tool calling.

  5. 6.5
    Not built

    X-ray out of scope.

    The X-ray analysis was not built. We prioritized finance, which had more urgent demand.

07 / Result

No clinic has walked away.

~20 active clinics, each in its own tenant isolated by RLS.

  • AIIn productionAppointment transcription and summary on Groq, since Feb 2026.