TrimBook is a multi-tenant SaaS platform that helps barbershops in Uganda manage their business from one dashboard. Accept bookings, manage barbers and services, track revenue, and get paid via MTN, Airtel and Flutterwave. Each shop gets isolated data, automated reminders, and a subscription plan from UGX 25,000/month. Start a 14-day free trial.
# TrimBook
Multi-tenant SaaS platform for barbershops. Each shop is an isolated tenant
(scoped by `shopId`) sharing one application. Built in phases.
## Stack
- **Next.js 16** (App Router, Turbopack) · **React 19.2** · **TypeScript**
- **Tailwind CSS v4** + shadcn-style UI · light/dark mode (`next-themes`)
- **Prisma 6** + **PostgreSQL**
- **Auth.js (NextAuth v5)** — Credentials provider, JWT sessions carrying
`role` + `shopId`
- **Zod v4** validation · **bcryptjs** password hashing
> Note: Next.js 16 renames `middleware.ts` → **`proxy.ts`** (Node runtime) and
> makes `cookies()`, `headers()`, `params`, `searchParams` **async**. This
> project already follows those conventions.
## Architecture
```
src/
app/ # routes (App Router)
(auth)/ # login, register, register/shop
admin/ dashboard/ barber/ account/ # role homes (guarded)
api/auth/[...nextauth]/ # Auth.js handlers
components/
ui/ # Button, Input, Label, Card (shadcn-style)
app/ auth/ # topbar, theme toggle, logout, field errors
lib/
auth/ # NextAuth config, password hashing
db/prisma.ts # Prisma singleton
subscription/policy.ts # PURE feature-gating from subscription state
validations/ # Zod schemas
dal.ts # Data Access Layer: requireUser/Role/ShopId
constants.ts env.ts utils.ts
server/
tenant/context.ts # tenant context + assertShopAccess / resolveScopeShopId
repositories/ # tenant-scoped repository base + ServiceRepository
services/ # auth.service, audit.service
actions/ # server actions (auth)
types/next-auth.d.ts # session/JWT augmentation (role + shopId)
proxy.ts # optimistic route guard (Next 16 middleware)
prisma/schema.prisma # full data model (13 tables, shopId everywhere)
prisma/seed.ts # super admin + demo shop/barber/services/customer
```
### Tenant isolation (defense in depth)
1. **Session** c …