Web Development
ReactArchitectureRBACAdmin PanelsB2B SaaSTestingAudit LogsFeature Flags

React Admin Dashboard Architecture: RBAC, Audit Logs, Navigation, and Scalable Modules

AO
Adrijan Omićević
·14 min read

# What You’ll Build (and Why It Matters)#

A solid React admin dashboard architecture is not about picking a UI kit. It is about reducing risk in a B2B environment where mistakes are expensive: data leaks, broken compliance trails, and permission regressions that only show up in production.

This guide gives you a practical blueprint for B2B admin panels with:

  • Information architecture that scales beyond 10 screens
  • Permission-driven navigation and UI
  • A production-ready audit log event model
  • Feature flags that work with RBAC, not against it
  • Clear module boundaries and testing approaches for permissioned routes

For a broader SaaS-focused view, also read: Next.js B2B SaaS admin panel architecture with RBAC and audit logs. For module design patterns, see: React modern frontend architecture with feature slices and modules.

# Assumptions and Non-Negotiables#

Admin dashboards are “internal” only until they are not. Treat them like public apps with stronger controls.

AreaRecommendationWhy
AuthOIDC or JWT session with short-lived access tokensReduces blast radius of token leaks
AuthorizationEnforced on backend for every requestFrontend checks are not security
Frontend RBACMirrored permissions to drive UIPrevents confusing UX and reduces support load
Audit logsImmutable, append-onlyCompliance and incident response
FlagsServer-driven, cached client-sideSafe rollouts and tenant-specific features
TestingPermissioned routes + API auth testsPrevents regressions during refactors

⚠️ Warning: Hiding buttons is not authorization. If the API accepts a forbidden action, your admin panel is already compromised.

# Information Architecture That Scales#

Most admin panels fail because they grow like a kitchen junk drawer: each new feature adds a menu item and a route, and the result is a navigation tree nobody understands.

A scalable information architecture starts with domain-based grouping, not screen-based grouping.

Define Domains, Not Pages#

Common B2B admin domains:

  • Organization and tenants
  • Users, roles, permissions
  • Billing and subscriptions
  • Data management or catalog
  • Integrations and webhooks
  • Security, audit logs, settings
  • Support tooling

A good signal your domain boundaries are right: each domain can be owned by a team and deployed behind a feature flag without breaking others.

Keep top-level navigation stable. In most B2B products, 6 to 9 top-level sections is a practical ceiling; beyond that, users rely on search more than menus.

Navigation layerWhat it containsChanges frequency
Top-levelDomains: Users, Billing, IntegrationsRarely
Second-levelWorkflows: Invite, Roles, API keysSometimes
Deep pagesEntity-specific screens: user details, invoice detailsOften

A Practical Route Map Structure#

Use a route map that is data-driven and permission-aware. It becomes the single place where you reason about visibility, access, and breadcrumbs.

TypeScript
export type AppRoute = {
  id: string;
  path: string;
  label: string;
  navGroup?: string;
  requiredPermissions?: string[];
  requiredFlags?: string[];
  children?: AppRoute[];
};
 
export const routes: AppRoute[] = [
  {
    id: "users",
    path: "/users",
    label: "Users",
    navGroup: "Identity",
    requiredPermissions: ["users.read"],
    children: [
      {
        id: "user-details",
        path: "/users/:userId",
        label: "User details",
        requiredPermissions: ["users.read"],
      },
    ],
  },
];

This pays off when you add:

  • A new tenant plan that hides Billing
  • A compliance feature that adds Audit Logs
  • A role change that removes user management access

💡 Tip: Treat the route map as a product artifact. Keep labels, groups, and breadcrumbs in one place to avoid “navigation drift” between menus and pages.

# RBAC Blueprint: Permission-Driven UI Without Chaos#

RBAC typically fails in frontend code because permission checks are scattered. The fix is to centralize permission semantics and keep UI logic declarative.

RBAC Model: Roles Are UX, Permissions Are Control#

Use permissions as the atomic unit. Roles are sets of permissions for easier admin management.

ConceptExampleStored where
Permissionusers.invite, billing.updateBackend policy store
RoleAdmin, Billing managerBackend, tenant-scoped
AssignmentUser has roles in tenantBackend
Effective permissionsFlattened permission listBackend response on login and refresh

In most B2B SaaS, permissions are tenant-scoped. Do not treat “Admin” as global unless your product truly is single-tenant.

Centralize Permission Checks#

Create a small authorization surface in the frontend:

  • can(permission) for single permission checks
  • canAll([...]) for strict actions
  • canAny([...]) for UI sections
TypeScript
export type Permission = string;
 
export function createAbility(effective: Permission[]) {
  const set = new Set(effective);
 
  return {
    can: (p: Permission) => set.has(p),
    canAll: (ps: Permission[]) => ps.every((p) => set.has(p)),
    canAny: (ps: Permission[]) => ps.some((p) => set.has(p)),
  };
}

Permission-Driven Navigation#

Navigation should be derived from the route map plus:

  • effective permissions
  • enabled feature flags
  • current tenant context
TypeScript
export function filterRoutesForUser(
  allRoutes: AppRoute[],
  ability: { canAll: (ps: string[]) => boolean },
  flags: { hasAll: (fs: string[]) => boolean }
) {
  return allRoutes
    .filter((r) => !r.requiredPermissions || ability.canAll(r.requiredPermissions))
    .filter((r) => !r.requiredFlags || flags.hasAll(r.requiredFlags))
    .map((r) => ({
      ...r,
      children: r.children ? filterRoutesForUser(r.children, ability, flags) : undefined,
    }));
}

Permission-Driven UI: One Wrapper, Many Benefits#

Use a small RequirePermission wrapper for conditional rendering. Keep it dumb and predictable.

TSX
type RequirePermissionProps = {
  all?: string[];
  any?: string[];
  fallback?: React.ReactNode;
  children: React.ReactNode;
};
 
export function RequirePermission(props: RequirePermissionProps) {
  const ability = useAbility();
 
  const okAll = props.all ? ability.canAll(props.all) : true;
  const okAny = props.any ? ability.canAny(props.any) : true;
 
  if (!okAll || !okAny) return props.fallback ?? null;
  return props.children;
}

Use it for:

  • action buttons
  • dangerous controls
  • entire panels inside a page

Do not use it as a “security boundary.” That boundary is the API.

# Feature Flags: Safe Rollouts and Tenant Variants#

Feature flags in admin dashboards are not optional once you have multiple tenants, pricing tiers, or staged rollouts. They let you ship code to production without exposing it.

The Rule: Flags Gate Availability, Permissions Gate Access#

A practical combined rule for UI is:

  • Show a feature only if the flag is enabled
  • Allow usage only if the permission is granted
  • For routes: enforce both
ScenarioFlagPermissionResult
Feature in betaOffGrantedHidden and inaccessible
Tenant paid add-onOnNot grantedVisible only if you want upsell UI, but actions blocked
Normal featureOnGrantedFull access

If you want upsell UX, separate “view upsell” from “use feature” permissions, or use a route variant like /integrations showing limited content.

ℹ️ Note: Keep flags server-driven for tenant correctness. Client-only flags are fine for UI experiments but not for plan enforcement.

Minimal Flag Client#

A simple approach:

  • Fetch flags on boot or tenant switch
  • Cache in memory
  • Refresh on interval or when you receive a 409 or 412 from the backend signaling stale config
TypeScript
export type FlagKey = string;
 
export function createFlagSet(enabled: FlagKey[]) {
  const set = new Set(enabled);
  return {
    has: (k: FlagKey) => set.has(k),
    hasAll: (ks: FlagKey[]) => ks.every((k) => set.has(k)),
  };
}

# Audit Logs: Event Model You Can Actually Use in Incidents#

Audit logs are only valuable if they answer who did what, when, where, and what changed. Many teams log “User updated settings” and call it a day, then cannot investigate a real incident.

Audit Log Event Model#

Store audit events as immutable records. Avoid “free-form message only.” Make it queryable.

FieldTypeExampleWhy it matters
idstringevt_01J...Stable reference
occurredAtISO datetime2026-11-07T10:30:12ZTimeline reconstruction
tenantIdstringtnt_123Multi-tenant isolation
actorobjectuser id, type, emailAttribution
actionstringusers.inviteAggregation and filters
entityobjecttype user, id usr_9Trace impact
outcomestringsuccess or deniedSecurity analysis
ipstring203.0.113.9Investigation
userAgentstringMozilla/...Forensics
requestIdstringreq_abcCorrelate with app logs
changesobjectbefore/after subsetUnderstand what changed
metadataobjectplan, role id, reasonBusiness context

Example Audit Event Payload#

Keep diffs minimal. Log only fields that changed, and avoid sensitive values.

JSON
{
  "occurredAt": "2026-11-07T10:30:12Z",
  "tenantId": "tnt_123",
  "actor": { "type": "user", "id": "usr_1", "email": "ops@acme.com" },
  "action": "roles.update",
  "entity": { "type": "role", "id": "role_billing_manager" },
  "outcome": "success",
  "requestId": "req_c9f2a",
  "ip": "203.0.113.9",
  "changes": {
    "permissions": {
      "before": ["billing.read"],
      "after": ["billing.read", "billing.update"]
    }
  },
  "metadata": { "reason": "Access needed for subscription changes" }
}

Audit Log UI: Filtering That Supports Real Work#

In practice, the most-used filters are:

  • time range
  • actor
  • action
  • entity type and id
  • outcome denied vs success

Add deep links from entity pages. Example: from User details, a link “View audit events for this user” that filters by entity.type = user and entity.id = usr_9.

🎯 Key Takeaway: Design the audit log schema for investigations, not for dashboards. Queryability beats pretty messages.

# Scalable Modules and Component Boundaries#

Admin panels grow fast. If you do not draw boundaries early, you end up with shared components that become global dependencies and slow down delivery.

A practical module boundary is: a domain slice owns its routes, API calls, UI state, and permission requirements.

Suggested Folder Layout#

Avoid a flat components folder that becomes a dumping ground. Use feature modules and a thin app shell.

LayerOwnsMust not own
app-shellrouter, layout, nav, providersdomain logic
modules or featurespages, components, hooks, api clients for domainglobal UI primitives
shared uibuttons, inputs, table, modalbusiness rules
shared coreauth client, ability, flags, http clientfeature-specific endpoints

Example structure:

  • src/app-shell/
  • src/shared/core/ability/
  • src/shared/core/flags/
  • src/shared/ui/
  • src/modules/users/
  • src/modules/billing/
  • src/modules/audit-log/

For a deeper dive into modularization patterns, see: React modern frontend architecture with feature slices and modules.

Define Module Contracts Explicitly#

Each module should expose:

  • route definitions
  • navigation items
  • optional sidebar fragments
  • permission list used by the module

That keeps app-shell simple: it composes modules, filters by ability and flags, and renders.

# Permissioned Routes: Patterns That Don’t Break During Refactors#

There are two access control points for routes:

  1. 1
    Navigation should not show routes a user cannot access.
  2. 2
    Router must still guard direct URL access.

Route Guard Strategy#

A reliable pattern:

  • Each route has requiredPermissions and requiredFlags
  • Router checks them before rendering the page component
  • Unauthorized goes to a dedicated 403 page, not a blank screen
TSX
type GuardedRouteProps = {
  requiredPermissions?: string[];
  requiredFlags?: string[];
  children: React.ReactNode;
};
 
export function GuardedRoute(props: GuardedRouteProps) {
  const ability = useAbility();
  const flags = useFlags();
 
  const okPerms = props.requiredPermissions ? ability.canAll(props.requiredPermissions) : true;
  const okFlags = props.requiredFlags ? flags.hasAll(props.requiredFlags) : true;
 
  if (!okFlags) return <NotFoundPage />;
  if (!okPerms) return <ForbiddenPage />;
  return props.children;
}

Use Not Found for disabled flags to avoid “leaking” unreleased features, and Forbidden for permission issues where the feature exists but the user cannot use it.

# Testing Blueprint: Permissioned Routes and UI Controls#

Permission logic is notoriously brittle because it spreads across routes, nav, buttons, and API calls. Your test strategy should target the decision points, not just snapshots.

For a complete testing setup with Vitest, React Testing Library, and MSW, see: React testing strategy with Vitest, React Testing Library, and MSW.

What to Test (High Value, Low Maintenance)#

Test typeFocusExample assertion
Unit testsability and flag logiccanAll true only when all present
Component testsconditional UI“Invite user” button hidden without users.invite
Router testspermissioned routesnavigating to /billing redirects to 403
Integration tests with MSWend-to-end flowsAPI returns 403, UI shows error state
API testsserver authorizationforbidden action rejected regardless of UI

Example: Testing a Permissioned Route#

Use an in-memory router, inject auth state, and assert correct page.

TSX
import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { App } from "./App";
 
test("blocks billing route without permission", async () => {
  render(
    <MemoryRouter initialEntries={["/billing"]}>
      <TestProviders auth={{ permissions: ["users.read"] }}>
        <App />
      </TestProviders>
    </MemoryRouter>
  );
 
  expect(await screen.findByText("Forbidden")).toBeInTheDocument();
});

Keep TestProviders as the single entry point to mock:

  • effective permissions
  • enabled flags
  • tenant context

⚠️ Warning: If your tests mock permission checks by mocking can() everywhere, you are not testing real behavior. Prefer injecting effective permissions and letting the ability layer compute decisions.

Example: Testing a Permission-Driven Button#

TSX
import { render, screen } from "@testing-library/react";
import { UserToolbar } from "./UserToolbar";
 
test("hides Invite button without users.invite", () => {
  render(
    <TestProviders auth={{ permissions: ["users.read"] }}>
      <UserToolbar />
    </TestProviders>
  );
 
  expect(screen.queryByText("Invite user")).toBeNull();
});

Contract Tests Between Frontend and Backend#

The most common production bug is mismatch between permission strings and backend enforcement. Add a lightweight contract:

  • frontend permission constants live in one place
  • backend exposes /me/permissions and /me/flags
  • CI validates that frontend permission keys are a subset of backend-known keys

This can be as simple as a JSON list produced by backend during build or a test endpoint in staging.

# Putting It Together: A Practical Blueprint#

Use this sequence to implement a new module safely:

  1. 1
    Add domain module with routes, required permissions, required flags.
  2. 2
    Add API client methods for that domain and ensure backend enforces authorization.
  3. 3
    Add navigation items derived from route definitions.
  4. 4
    Add audit log events for key actions, especially destructive or permission-related changes.
  5. 5
    Add permission-driven UI wrappers for controls.
  6. 6
    Add tests at three levels: ability, route guard, and at least one integration flow.

This is how you keep velocity while preventing permission regressions when the dashboard grows from 15 to 150 screens.

# Key Takeaways#

  • Treat the route map as data: include labels, permissions, and flags, then derive navigation and breadcrumbs from it.
  • Enforce authorization on the backend, and mirror effective permissions in the frontend to drive a permission-driven UI.
  • Design audit log events for investigations: actor, action, entity, outcome, request id, and minimal diffs.
  • Use feature flags to gate availability and permissions to gate access; require both for sensitive routes.
  • Split the dashboard into domain modules that own routes, API calls, and permission requirements to avoid cross-feature coupling.
  • Test permissioned routes with an in-memory router and injected effective permissions, then back it up with API authorization tests.

# Conclusion#

A maintainable React admin dashboard architecture is a system: information architecture, RBAC-driven navigation, auditability, flags, module boundaries, and tests all reinforce each other. If you implement only one part, the weak link becomes your source of incidents and support tickets.

If you want a proven baseline for your B2B admin panel, Samioda can help you define the module boundaries, RBAC model, audit event schema, and a testing strategy that prevents permission regressions while your product scales. Reach out via Samioda and we’ll turn this blueprint into a working codebase.

FAQ

Share
A
Adrijan OmićevićFounder & Senior Developer

Founder & Senior Developer at Samioda. 8+ years building React, Next.js, Flutter and n8n automation solutions for clients across Europe.

Need help with your project?

We build custom solutions using the technologies discussed in this article. Senior team, fixed prices.