Product · Architecture · NestJS · PostgreSQL
Building ORYNZA: One Core API for a Hotel's Whole Day
A hotel and resort platform where five apps and a public API share one core API and one database. How we made the property the tenant, never sold the last room twice, let bookings change without rewriting history, gave the front desk an identity per person, and wrote every decision down.
A small resort's day touches more software than you would expect. The owner sets rates and watches revenue. Reception checks guests in and out on a shared PC. Housekeeping needs to know which rooms are dirty. Guests book on the hotel's own website, on a marketplace, or by phone. Accounts want GST invoices that match the money. Most small properties stitch this together from spreadsheets, a booking widget and a lot of phone calls.
ORYNZA is a hotel management and booking platform for hotels, resorts and homestays that tries to hold that whole day in one system. We started building it at the beginning of October 2026. I work across the API and the apps, and I own the repositories and the deployments.
This post is about the architecture and the decisions that shaped it: the ones about data, the ones about money, and the ones about people, which turned out to be the hardest.
Five apps, one core API
ORYNZA is five apps and a public API:
- Orynza OS, where owners and managers run rooms, rates, inventory and reservations.
- The front desk terminal, a PIN-based app for reception.
- The platform console, where ORYNZA's own staff run the platform itself.
- The booking site, where guests search, book and pay.
- The marketing site, where hotels ask for a demo.
- A versioned public API, for hotels that already have their own website.
Every one of them goes through one NestJS core API, and only that API touches the database. No app has its own copy of the rules for pricing, availability or permissions. When a rule changes, it changes in one place, and every screen that shows a price shows the same price.
The API is a modular monolith: one deployable service, organised internally into modules with clear boundaries, such as authentication and permissions, the inventory ledger, bookings and pricing, payments, invoices and the outbox. At this stage, microservices would have meant running a distributed system instead of building a product. A monolith with firm module boundaries keeps the option to split later without paying for it now.
Each app has its own repository and its own deploy: the API on Render in Singapore, next to Neon Postgres in the same region, and the web apps on Vercel. The data layer is Drizzle, with raw SQL wherever the query deserves it. Continuous integration runs typechecks, lint and the full test suite on every push, against a dedicated test branch of the database rather than a mock.
The property is the tenant
The first big decision was what a customer is. We started with organisations, a group above one or more properties, with group managers and per-property access lists, because hotel chains exist and it felt prudent to model them.
Within a week we removed it, and wrote down why. The organisation layer added a whole tier of permission logic we would have to get right on day one, for a kind of customer we didn't have yet. The decision became one property, one account: each hotel signs up and runs as a single property, and a parent-and-branch model for chains will come later, designed for chains rather than guessed at.
The migration that removed organisations converted existing rows in place, and refused to
run if any organisation had more than one property, so it could never silently merge two
hotels. Every table that carried an organisation now carries a property_id.
That column is enforced by Postgres row-level security, forced on every tenant table.
The API sets the current property on the connection at the start of each transaction, with
set_config scoped to that transaction, and the policies do the rest. Composite foreign keys
make sure a child row can only point at a parent in the same property. A query that forgets
its WHERE property_id = ... doesn't leak another hotel's bookings; it returns nothing.
Isolation is a property of the database, not a habit of the developer.
Some data is deliberately global: demo requests, intake links and hotel registrations. Anyone may submit them, but only platform admins may read or change them, and row-level security says that too.
Onboarding is invite-only, for now
There is no public sign-up. A hotel asks for a demo on the marketing site, sees the product in a demo, and then receives a private intake link, valid for fourteen days, to register. A platform admin approves the registration, which creates the property and invites its owner.
That is a product decision as much as a technical one. A self-serve sign-up is only honest when a hotel can finish setting up alone and billing is online. Until then, opening the door publicly would mean hotels arriving into a product that needs a person to finish their setup. The decision is written down with the condition for revisiting it.
Never sell the last room twice
Overbooking is the failure a hotel will not forgive. Two guests on two channels both book the last deluxe room for the same Saturday, and someone arrives to find there is no room.
Availability is held as a nightly inventory ledger: for each room type and night, how many rooms exist, how many are closed, how many are held and how many are sold. A database check keeps closed plus held plus sold at or below the total, so the database itself refuses to oversell, whichever app the request came from.
When a guest starts a booking on the website, the rooms are held for fifteen minutes while
they pay, and the hold counts against availability. Pay-at-hotel rates confirm at once. Every
change to the ledger locks the affected rows together, in a fixed order so two transactions
can't deadlock each other, and if any night is gone the whole operation rolls back with a
clear sold_out answer. The last room can't go twice.
Resorts added a twist: villas. A villa can be sold whole, or its bedrooms can be sold room by room, but never both on the same night. So the ledger keeps a "linked" count on both sides: booking a villa takes its bedrooms off sale, and booking a bedroom, or putting one out of order, takes the villa off sale. There are two checks, one for selling and one for the physical rooms, so "out of order" still works on a night the calendar is closed. The test that matters books a villa and one of its bedrooms at the same moment. One wins.
Changing a booking without rewriting history
Bookings change all the time: a guest extends by a night, leaves early, adds a room or upgrades. The naive way to handle that, recalculating the whole stay at today's prices, is quietly unfair: if rates went up since the booking, the guest's original nights get more expensive just because they asked for one more.
So a change request describes the booking as it should be: dates, rooms, rate and guests, plus a reason. The API works out the difference.
- Nights the change keeps hold the price they were booked at. Only new nights, and the nights of any room whose type or rate changes, are priced at today's rates, with GST worked out per night as before.
- What can change depends on where the stay is. A confirmed booking can change almost anything. A guest who has checked in can only extend, leave early or change the guests per room; changing room type mid-stay is a room move, which is a different operation.
- Rules bend where reality does. Kept nights ignore a stop-sell. Shortening a stay never fails a minimum-stay rule, because an early departure is a fact, not a sale.
- The ledger moves only the difference. It gives back nights the booking no longer needs and takes the new ones, under the same locks as before, so a shorter stay works even if the hotel has since closed some dates. If a new night is gone, the change rolls back.
Staff see a preview before anything happens: before and after for every room and night,
the difference and the new balance. The preview runs the real change inside a database
savepoint and rolls it back, so it is exactly what applying would do, not a second
implementation that might drift. Applying then sends the total the preview showed; if prices
moved in between, the API refuses with price_changed instead of charging something nobody
saw.
Money that has been invoiced is treated as history. Each night records the invoice it went on, and an invoiced night is never edited in place: added or re-priced nights go on a further invoice, and removing or lowering an invoiced night needs a manager's approval and records the amount to credit. If a guest has paid more than the new total, the credit stays on the booking unless a refund of the difference is asked for, which goes through the usual refund path and its permissions.
Money you can trust
Online payments go through Razorpay, and a booking is confirmed only by a verified payment signature, never by the browser saying the payment succeeded. For development and staging there is a simulated provider, which the API refuses to use in production unless explicitly allowed.
Guests get links to their booking by email. Each link carries an HMAC of the reservation id, signed with a server secret. Nothing secret is stored, links can be re-sent at any time, and a link can't be altered to open someone else's booking.
GST is calculated per night, because the rate slab depends on the nightly tariff. The slabs are implemented as notified, prices are exclusive of tax, and the whole calculation lives in one function, so when the accountant confirms the details for launch, changing it is one place, not a search.
Permissions as data, granted down a chain
Hotels are run by different people with different levels of trust. ORYNZA treats permissions as data, granted down a chain.
Each role starts with a default set. The owner always has everything and decides what each manager may do. Owners and managers decide what other staff may do, and nobody can give a permission they don't hold themselves. Because permissions are rows rather than branches in code, a hotel can shape its own staff's access without a deploy, and the API enforces every one of them; a hidden button is never the only protection.
The platform console works the same way for ORYNZA's own staff: super admin, admin and support roles, each a named set of permissions stored as data, one permission per area of the console, with two-step sign-in using an authenticator app. Staff management follows the same grain: a manager can add front desk, housekeeping and accounts staff, but never another manager or an owner.
The front desk is its own app
Reception was the most interesting design problem, because it is where software meets a shared machine. Does every front desk person need their own login, or can bookings simply be done "through the terminal"? And if each person has a login, do they sign out after every shift?
Before building anything we studied how hotel systems handle it, from large property management systems to the small cloud tools common in India. The answer was consistent:
- Every person who takes bookings or money has their own identity. No serious system recommends one shared "front desk" login. The terminal is a trusted device, not a user.
- Nobody types an email and password at every handover. Shared desks use a quick switch: a short PIN, a badge or a security key, plus an automatic lock when idle.
- Money is closed per person, per shift.
The reasons are accountability, fraud and leavers. An activity log is only useful if each entry names a person; with a shared login, a void or a discount belongs to nobody. Fraud at small hotels is usually inside: phantom charges and skimmed cash, where the fixes are always named users, limited rights for voids and discounts, and an owner who reads the log. And when someone leaves, you deactivate one person, instead of changing a shared password that nobody actually changes.
So the front desk terminal is its own app. The reception PC has a terminal login of its own, created by an owner or manager, and every staff member, owners and managers included, has a personal six-digit PIN. A person enters their PIN to act, sees only work screens (today's board, bookings, rooms, guests, payments) within their own permissions, and every action is recorded against them. When something needs approval, such as checking out a guest who still owes money, a manager enters their PIN at the same desk, and the record shows who asked and who approved.
Room status is three things, not one
A first version of most hotel systems has a single room status: available, occupied, dirty, maintenance. It breaks as soon as a room is occupied and dirty, or vacant but out of service.
ORYNZA keeps three separate parts:
- Occupancy, derived from the stays: vacant or occupied.
- Cleaning: dirty, cleaning, clean, inspected.
- Availability: in order; out of service, still sellable but not assigned; or out of order, removed from inventory for a set of dates with a reason, and refused if it would oversell.
Housekeeping, the front desk and the inventory ledger each read the part they care about, and none of them has to decode a combined state. Guest requests, an extra pillow or a wake-up call, go to housekeeping as tasks, which made them the first piece of the housekeeping module.
A business date, and reports that match the invoices
Hotels don't close their day at midnight. Each property has a business date that moves only when a day is closed. Closing lists arrivals not checked in, guests due out and money owed, and posts each night stayed exactly once. Revenue is earned night by night from booked nights, and the GST summary and invoice register come only from issued invoices, so the reports always agree with the paperwork an accountant will see.
Email, webhooks and the things you only learn in production
Email goes through a transactional outbox: the message is written in the same transaction as the booking that caused it, and a worker sends it. A booking can't commit without its confirmation being queued, and a slow email provider can't slow down a booking. Events for hotels' own systems, bookings, payments, invoices and availability, go out as signed webhooks, with a test button, secret rotation and a delivery history.
One small fix says a lot about running a system like this. Without an email key configured, the mailer used to print each email's text to the log, so a developer could read sign-in codes off the console. In production that would mean sign-in codes, password reset links and booking links in the logs. Now production logs only the recipient and the subject, and the full text appears only in development.
The public API is keyed. Hotels request secret or browser keys in Orynza OS and see each key exactly once; only its hash is stored. ORYNZA's staff approve, reject or revoke keys in the console, and server keys are refused when they come from a browser.
Running it, not just building it
The platform console is also how ORYNZA itself is operated, recorded by the API itself where possible: which commit each app is running, recent deploys, migrations in the code compared with the database, errors, performance and an audit log. Platform admins get an email the first time in an hour that a new server error appears, a queued job or a refund fails for good, a payment webhook arrives with a bad signature, or the API restarts too often. A deep health check reports the database and the email queue to an outside uptime monitor.
Even load testing taught restraint. A first run on staging, five searches a second with no cap on waiting requests, slowed staging for about nine minutes. The next run was deliberately gentle: one search a second, at most five requests in flight, for two or three minutes, at a quiet hour, with everyone using staging told first. A load test is also a production event for everyone else using the environment.
Writing every decision down
A product this broad will relitigate the same questions forever unless the answers are written down. ORYNZA keeps a numbered decision log in the repository: what was decided, who decided it, when and why. Tenancy, the hold duration, how invoices work after a change, what a role may grant, whether to run a pilot. Tasks are numbered too, and each one ends with a changelog entry and a work-log line saying what shipped and what was applied to which database.
When a question comes back, the answer is a decision number, and changing it means writing a new decision that replaces the old one, not quietly drifting. It turned out to be the most useful engineering practice on the project. It makes reviews faster, it lets AI coding tools work from the same written context, and it makes the reasoning visible to anyone who joins later. Periodic audits read the whole state at once: which repositories are clean, which checks pass, what is built, what is blocked and on whom.
Where it stands
Every app runs on staging. The foundations, the booking engine with payments and GST invoices, and most of the front desk, setup, staff, reports, day close and booking changes are built. The production environment and some outside accounts are still to come, and the public API is set up but not yet running. We are building to the finished product and testing it end to end with our own demo hotels before launch, with their images clearly labelled as illustrations rather than borrowed from real hotels.
What it taught me
A hotel's day looks like a lot of screens, but it is really a handful of invariants: a room can't be sold twice, a booked price doesn't change behind the guest's back, an invoice is history, and every action belongs to a person.
The architecture that worked was the one that put each invariant in exactly one place, mostly in the database, and let five apps lean on it. And the practice that kept the work moving quickly was the least glamorous one: writing every decision down, so the next argument starts from the last answer instead of from scratch.
