WorkPro is a Next.js 15 App Router application on MongoDB with path-based tenancy (/[org]/…) and a two-layer access model.
Key design decisions
- Personas decide the area; roles decide the data. Six personas route users to the admin console, the workspace or the client portal. Per-organisation security roles grant permissions from a compile-time-checked set of 104, each at an Own, Team, Department or All scope.
- Scopes as data filters. The held scope is turned into a MongoDB filter for lists, search and single-record checks; an empty match means nothing is visible, never everything.
- Modules as plug-ins. Provisioning hooks, demo seeders, dashboard widgets, search providers and import adapters are contributed by each module through typed registries, so the nine modules could be built in parallel against fixed contracts.
- Fail-closed tenancy. A Mongoose plugin throws on any query without a tenant filter, and cross-tenant IDs return “not found”.
- Uniform entry points. Six action wrappers and five route wrappers handle auth, permissions, validation, read-only mode, audit and revalidation; repo scripts fail the build when an action skips them or a client file imports server code.
- AI as an assistant, not an actor. Every AI call is availability-checked, rate-limited and logged; results are reviewed and applied through the normal permission-checked actions.
Architecture
Server components call module services through thin server actions; versioned JSON APIs under /api/v1/[org] feed server-driven tables, uploads, search and exports. Mongoose 9 on a MongoDB replica set stores 62 models, files go to Cloudinary, optional Upstash Redis backs rate limits, and five protected cron routes run recurring work. The public site, careers boards, hosted inquiry forms and invoice tracking links sit beside the workspace.