A Next.js and Supabase Architecture for a Small B2B SaaS
Map customer pages, account membership, background work and staff tools with a small service-request example.
A venue manager invites a staff member to view orders. The screen knows which venue is open. The database needs to know which venue the staff member can access, and what they’re allowed to do there. This one task helps decide where the important parts of a small B2B application belong.
Give the request a place to change meaning
| Layer | Job in the invitation example |
|---|---|
| Browser | Collect an email and role, show validation and the outcome |
| Next.js server | Identify the caller, check the requested operation and coordinate the write |
| PostgreSQL | Store the invitation, enforce tenant and membership boundaries and preserve uniqueness |
| Background service | Deliver the invitation after the database commits and report the delivery outcome |
The browser can offer a responsive experience and explain the action. Role and venue should come from verified state on the server. If the invite is sent twice, the database can enforce an appropriate uniqueness rule on active invitations. A background sender can retry the notification without creating another invitation.
Build and review one vertical slice
Start with two test venues, two staff roles and one small record type. Demonstrate a normal read, a write from the right role and a refusal from the wrong account. Use normal user sessions when reviewing row-level policies. A broad server credential is appropriate only where it is actually required, and its actions need an explicit access check.
Then record a frontend failure after submitting the invitation. Does a reload show the pending record? If the message provider is down, can staff see that the invitation exists and delivery is pending? Your answer will tell you whether status belongs to the invitation or the message record.
For a first B2B release, separate identity, membership and business records before adding lots of shared helpers. As you add invoices, assets and webhooks, repeat the same account-isolation exercise for each new path. The platform's convenience helps you ship. The everyday operator workflow tells you whether the pieces fit together.
