Choosing a web framework, an authentication service and a database settles only part of a SaaS architecture. The application still has to decide who owns each record, who may change it and what happens when payment or submission state changes halfway through a request.
I would design those boundaries around one complete user task before expanding the dashboard.
What does each part of this SaaS stack own?
Next.js provides the application surface and server entry points. Clerk provides authentication capabilities. PostgreSQL stores durable application records. Your application connects them through its own authorization and business rules.
Authentication answers who the requester is. Authorization decides whether that requester may perform a particular action on a particular record. A signed-in user should not gain access to another account's data merely by changing an identifier in a URL.
Clerk's content-protection guidance emphasizes checks on protected resources. The Next.js data-security guide is a useful companion for server-side data access and mutation boundaries.
Start with the record's owner, not the dashboard route
For an illustrative study product, a study belongs to an account or workspace, a response belongs to a study, and a private note belongs to the review workflow. Carry those relationships into the data-access checks.
A simple architecture might be:
Browser -> Next.js page or request handler
|
+-> Clerk identity
|
+-> Application ownership and access check
|
v
PostgreSQL recordThe ownership check belongs near the protected operation. Hiding a navigation item or redirecting from a dashboard page is not a substitute for checking the endpoint that reads or changes the data.
For every new operation, ask which user, workspace and record are involved. Determine where each value comes from and which values require server-side verification.
Public links need a separate permission model
A customer-feedback product may allow an invited respondent to submit without signing in. That public action should not inherit every capability of the founder's account.
Treat the link as granting a narrow capability under defined conditions. Check whether it is still valid, whether the study is open, what fields may be submitted and which private fields must never be returned.
The account-free feedback guide covers that experience in more detail. Architecturally, it is a second access path to the same product, not an exception that bypasses all validation.
Paid access is durable application state
The payment return page should not be the only place the product decides that access was purchased. A browser can close before returning, and a page load is not proof that the relevant payment state is valid.
Define how verified provider events update an entitlement record, how repeated events are handled and how access changes after a refund, expiration or other supported transition. Follow the chosen payment provider's current verification mechanism when implementing that boundary.
Here is a small acceptance checklist that does not depend on a particular billing product:
| Test | Expected boundary |
|---|---|
| Signed-in user changes a record identifier | Other accounts' data remains inaccessible |
| Public respondent requests private notes | The public path does not return them |
| Same verified billing event is delivered twice | The entitlement change is applied once |
| Browser closes after payment | Access can be reconciled independently |
| Account loses access | Protected operations check the new state |
These are proposed acceptance tests, not claims that a named provider guarantees each application behavior automatically.
Why I use a complete workflow as the architecture test
In the StackFlight work described in my portfolio, I built across the public experience, authentication, response collection, private review, paid access and deployment. Those boundaries had to fit the same task.
The case study demonstrates that product scope. It does not establish customer adoption or revenue. For a new founder project, I would use one comparable end-to-end flow to expose missing ownership rules before adding more features.
Questions about this SaaS stack
Does adding authentication make the database private?
No. Each protected read and write still needs the appropriate authorization checks. Database access and application identity must be connected deliberately.
Should we build a separate backend immediately?
Not automatically. Start with the boundaries, workload and deployment needs. Splitting services adds communication and operating work; it should solve a concrete problem.
Do database constraints replace validation?
No. Constraints protect stored invariants, while application validation provides task-specific rules and useful errors. Use each at the boundary it can actually enforce.
Before building your next screen, list its reads and writes and test each as the wrong account. That exercise reveals more about a SaaS architecture than a diagram containing only framework logos.