API Maker
The backend engine for the AI era
Case study 01 · Multi-tenant architecture
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.
The challenge
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.
The solution
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.
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-TenantThe 64 tables of the product became REST APIs by themselves. The team wrote custom APIs only for billing and the lab integrations.
Auto Generated APIsThe 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 ManagementSmall 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 ManagementA 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 MigrationsThe numbers
Growth came from hospital groups that needed a database of their own.
6 Node.js servers before, 2 API Maker servers now, for 4.7 times more clinics.
The results
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.
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.
Try API Maker on your own computer for free, or tell us about your project.