Skip to content

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 fieldUsed for
IdentityWho is signed in, and the who on an audit row
RoleWhich 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.

SystemWhat the BFF absorbsWhat the browser gets
BillingIts auth and page sizeOne list shape
OpsIts auth and page sizeOne list shape
LogsIts auth and page sizeOne 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.

ColumnMeaning
WhoIdentity from the session
RoleRole at the time of the action
ActionWhat was attempted
TargetWhich record
WhenServer time

05Components

A new view is assembled from the set that already exists. It is not a new script.

PieceJob
TableThe read view, fed by a query
FilterThe client interaction on that table
Role-gated sectionRendered only when the session role allows it