ESC
> launch.rentals beta
Home › Docs ›Architecture › Data Model

Data Model

The Postgres tables behind companies, items, customers and reservations

The schema is defined in src/db/schema.ts (application tables) and src/db/auth-schema.ts (generated by Better Auth). Twenty-two tables in total. Every application table that belongs to a company has a company_id column that references the Better Auth organization table.

Accounts and companies

TablePurpose
user, session, account, verificationBetter Auth: people, their sessions and credentials
organizationA company. Its slug is the /[company] URL segment
memberA user's role in a company: owner, admin, manager, employee, viewer or customer
invitationPending staff invitations, valid for 7 days
user_preferencePer-user notification and display preferences
company_profileTagline, description, contact details, currency, locale, time zone, plan and trial end

Rental data

TablePurpose
category, itemThe catalog: price, price unit, stock quantity, status and whether the item is public
item_stage, item_unit_stageThe company's post-return steps, and how many units of each item currently wait in each step
customerA renter. Optionally linked to a login through user_id
reservation, reservation_itemA booking with a period and status, and its lines with quantity and the price at booking time
content, commentPages and news with block bodies, and staff comments on them
attendanceStaff check-in and check-out events
custom_fieldDefinitions of extra fields for items, customers and reservations
table_permissionPer-member overrides of what a role may do on a resource
audit_logWho changed what, and when

Conventions

  • Custom values are stored in a custom JSONB column on items, customers and reservations, keyed by the field's key.
  • Prices are numeric(10,2) and copied onto each reservation line, so later price edits never change past bookings.
  • Times are stored as timestamps without a zone and treated as UTC.
  • Slugs (items, pages, news, categories) are unique within a company, not globally.