API Maker

The backend engine for the AI era

Case study 01 · Multi-tenant architecture

One set of APIs, 180 clinics, 180 databases

CareGrid Health sells clinic management software to clinics and hospital groups across the Gulf. Every clinic lived in one shared database, kept apart by a clinic_id filter in every query. When hospital groups asked for a database of their own, CareGrid moved to the multi-tenant instances of API Maker: one set of APIs, one database per clinic, chosen on every request.

  • 20 minto onboard a new clinicwas 3 days
  • 180clinics livewas 38 when the move started
  • 0rows seen by the wrong clinicin 14 months since go-live
  • −54%hosting cost per clinic$41 → $19 a month

The challenge

Where CareGrid was stuck

CareGrid started in 2019 with a booking app for one dental clinic in Dubai. Five years later its product ran appointments, patient files, billing and lab results for 38 clinics. All of them shared one PostgreSQL database. Every table had a clinic_id column, and every query had to remember it.

In March 2025 a new report in staging forgot that filter. A tester at one clinic saw the appointment list of another. It never reached production, but the CTO still calls it the scariest day of the company. A week later the largest prospect, a group of 22 hospitals, sent its security questionnaire. The first question was: "Is our data stored in a separate database?"

The honest answer was no. The team quoted five months to rebuild the backend with a database per clinic, with the risk of a second codebase just for the large customers.

  • One missing filter from a leakEvery query needed WHERE clinic_id = ?. Code review was the only guard, across more than 400 queries.
  • Hospitals wanted their own databaseLarge customers asked for a separate database, and one for a database server in its own data center.
  • Onboarding took three daysA new clinic meant seed scripts, manual data checks and a deployment window at night.

The solution

What they built with API Maker

The team tried API Maker on a copy of their database in one afternoon. The multi-tenant instance settled it: the same APIs, schemas, hooks and permissions for every clinic, with the database chosen by the request. No tenant filter to write, so no tenant filter to forget.

  1. A tenants table, not a new codebase

    A small catalog database keeps one row per clinic: its username and its connection string, stored encrypted. The instance is marked as a multi-tenant structure and points to that table.

    Multi-Tenant
  2. APIs generated from the schema

    The 64 tables of the product became REST APIs by themselves. The team wrote custom APIs only for billing and the lab integrations.

    Auto Generated APIs
  3. The clinic in every request

    The web and mobile apps send the clinic in the x-am-tenant-username header. API Maker opens the pool and the cache of that clinic. A user token made for one clinic is refused by every other one.

    Access Management
  4. Big customers on their own servers

    Small clinics share a database server. The hospital group has its own, and one clinic keeps its database in its own data center. Moving a clinic is copying its database and changing one row.

    Secrets Management
  5. One clinic a night

    A migration script split the shared database by clinic. Each clinic moved on its own night, so a problem could only ever touch one clinic.

    Database Migrations

The numbers

Before and after

Clinics live, at the end of each quarter

050100150200Q1 25Q2 25Q3 25Q4 25Q1 26Q2 26Q3 26Nov 26API Maker liveQ1 25, Clinics: 36Q2 25, Clinics: 38Q3 25, Clinics: 41Q4 25, Clinics: 58Q1 26, Clinics: 79Q2 26, Clinics: 104Q3 26, Clinics: 141Nov 26, Clinics: 18036180
050100150200Q1 25Q3 25Q1 26Nov 26API Maker liveQ1 25, Clinics: 36Q2 25, Clinics: 38Q3 25, Clinics: 41Q4 25, Clinics: 58Q1 26, Clinics: 79Q2 26, Clinics: 104Q3 26, Clinics: 141Nov 26, Clinics: 18036180

Growth came from hospital groups that needed a database of their own.

Hosting cost per clinic, each month (USD)

  • Shared Node.js backend
  • API Maker, a database per clinic
$0$5$10$15$20$25API servers, Shared Node.js backend: $24$24API servers, API Maker, a database per clinic: $9$9API serversDatabases, Shared Node.js backend: $14$14Databases, API Maker, a database per clinic: $8$8DatabasesBackups and logs, Shared Node.js backend: $3$3Backups and logs, API Maker, a database per clinic: $2$2Backups and logs
$0$5$10$15$20$25API servers, Shared Node.js backend: $24$24API servers, API Maker, a database per clinic: $9$9API serversDatabases, Shared Node.js backend: $14$14Databases, API Maker, a database per clinic: $8$8DatabasesBackups and logs, Shared Node.js backend: $3$3Backups and logs, API Maker, a database per clinic: $2$2Backups and logs

6 Node.js servers before, 2 API Maker servers now, for 4.7 times more clinics.

The results

What changed for CareGrid

  • Isolation by designEach clinic has its own database. There is no clinic filter left to forget, and the security questionnaire now has a short answer: yes.
  • Sales close fasterThe hospital group signed in October 2025. Two more groups followed, each with a database server of its own.
  • One product, one teamSchemas, hooks and permissions are written once for 180 clinics. The backend team is still four developers.
  • A pool and a cache per clinicA busy clinic no longer slows the others. The P95 of the appointment APIs went from 420 ms to 85 ms.
When hospitals asked about their data, we used to say "trust our code review". Now we say "your data is in your own database", and we can show them the row that points to it.
CTOCareGrid Health

What comes next. CareGrid is moving its lab results to events: when a lab posts a result, a listener updates the patient file and tells the doctor over WebSockets.

Have a problem like CareGrid?

Try API Maker on your own computer for free, or tell us about your project.