Roles · BFF
Ops dashboard
An ops team had outgrown a shared spreadsheet: conflicting edits, no audit trail, everyone could see everything, and numbers were refreshed by hand from billing, ops, and logs. Rebuilt as a Next.js app. Roles come from the server session. A backend-for-frontend is the only thing that talks to those three systems.
ROLES, QUERIES, AUDIT, COMPONENTS
01Session
The server reads identity and role from the session established with the identity provider. A page asks that role what it may render. The client cannot widen the answer. A hidden button, a CSS rule, or a route the browser still knows about does not count as a check.
| Session field | Used for |
|---|---|
| Identity | Who is signed in, and the who on an audit row |
| Role | Which views and actions the server will perform |
02BFF
The browser talks only to the Next.js app. Each internal system has its own route behind the BFF. That route absorbs the system's pagination and auth, then returns one shape.
| System | What the BFF absorbs | What the browser gets |
|---|---|---|
| Billing | Its auth and page size | One list shape |
| Ops | Its auth and page size | One list shape |
| Logs | Its auth and page size | One list shape |
Credentials for those three systems stay on the server.
03Queries
React Query is the client cache for that server data. There is no second store beside it. A mutation that changes ops data writes the audit row in the same request as the change. The query key is then invalidated, so the table shows the write the audit log just recorded.
04Audit
Stored in PostgreSQL with the rest of the app state.
| Column | Meaning |
|---|---|
| Who | Identity from the session |
| Role | Role at the time of the action |
| Action | What was attempted |
| Target | Which record |
| When | Server time |
05Components
A new view is assembled from the set that already exists. It is not a new script.
| Piece | Job |
|---|---|
| Table | The read view, fed by a query |
| Filter | The client interaction on that table |
| Role-gated section | Rendered only when the session role allows it |