Multi-Portal Architecture
LatticeDX segregates operational workspaces by business role on a single NocoBase 2.2.50 host rather than maintaining separate frontend deployments. The @latticedx/plugin-lattice-foundation plugin manages layout lifecycles, role-to-route mappings, and portal metadata, while @latticedx/plugin-dxos-studio seeds the default overview portals and domain cockpits.
Each /p/<slug> URL binds a uiLayouts record, a desktopRoutes tree linked through desktopRoutesUiLayouts, role visibility entries in rolesDesktopRoutes, and metadata stored under applicationPlugins.options.portals. All collection queries executed inside any portal pass through PostgreSQL 16 FORCE ROW LEVEL SECURITY tenant isolation.
Built-In Layouts and Seeded Portals
The platform defines two immutable built-in layouts (BUILTIN_UIDS) that cannot be deleted via the management API, alongside four seeded overview portals (OVERVIEW_SPECS in portal-composer.js) and dynamic domain cockpits installed by Business Packs.
| Route Path | Layout UID | Type | Default Roles | Operational Scope |
|---|---|---|---|---|
/admin | admin-layout-model | desktop | root, admin | System administration, plugin settings, and visual builder |
/mobile | mobile-layout-model | mobile | Field roles | Base shell for the Field Mobile PWA and offline capture |
/p/procurement | ldx-portal-procurement | desktop | ldx_employee, ldx_manager, ldx_director, ldx_admin | Purchase requests (latticeRequests), asset ledger (latticeAssets) |
/p/incidents | ldx-portal-incidents | desktop | ldx_manager, ldx_dispatcher, ldx_warehouse, ldx_director, ldx_admin | IoT incidents (latticeIncidentCases), alarm rules (latticeIncidentRules), WebGIS |
/p/logistics | ldx-portal-logistics | desktop | ldx_warehouse, ldx_dispatcher, ldx_driver, ldx_manager, ldx_admin | Cold-chain orders (latticeOrders), warehouses (latticeLocations), FEFO and ePOD |
/p/services | ldx-portal-services | desktop | ldx_employee, ldx_manager, ldx_warehouse, ldx_dispatcher, ldx_driver, ldx_director, ldx_admin | Service tickets (latticeServiceTickets), HR directory, P.A.R.A. knowledge vault |
Business Packs installed via dxosBuilder:installBusinessPack provision additional domain portals such as /p/cmms (CMMS maintenance) and /p/partner-claims (partner settlement). The client also registers workspace and builder routes at /admin/lattice-workspace, /admin/lattice-builder, /admin/settings/multi-portal, /lattice, /lattice/console, /lattice/studio, and /lattice/systems.
Prefix-Aware Portal Fallback Routing
The resolvePortalRedirect helper resolves /p/<slug> to the first firstPagePath accessible to the caller's active role. If a user lacks access to the primary portal but holds grants on a sibling portal sharing the same prefix (for example, an ldx_employee visiting /p/logistics redirects to the employee-scoped logistics portal), the router transitions safely instead of rendering an empty view.
Slug Rules and Portal Conventions
Every custom portal submitted to latticePortals:save is validated and normalized by normalizePortalInput (native-portal-helpers.js) before any database write runs.
| Parameter | Type | Default | Description |
|---|---|---|---|
slugrequired | string | — | Must match SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,35}[a-z0-9])$/ (2 to 37 lowercase alphanumeric or hyphen chars) and cannot appear in RESERVED_SLUGS. |
uid | string | — | Generated as ldx-portal-<slug> for custom portals. If supplied on create or update, it must match ldx-portal-<slug> (except the two built-in UIDs). |
titlerequired | string | — | Display name shown in the portal switcher, 1 to 80 characters. |
layoutType | desktop | mobile | desktop | Layout target stored on uiLayouts. |
routeName | string | — | Derived as p_<slug_underscored> (hyphens replaced with underscores), or admin for admin-layout-model. |
routePath | string | — | Derived as /p/<slug> (or /admin for admin-layout-model). |
icon | string | AppstoreOutlined | Icon identifier matching /^[a-zA-Z0-9_-]{1,64}$/. |
color | string | #1677ff | Hex accent color matching /^#[0-9a-fA-F]{3,8}$/. |
description | string | '' | Short portal summary, truncated to 300 characters. |
isDefault | boolean | false | Marks the portal as default; setting true clears isDefault on all other portals in the same transaction. |
sort | integer | 0 | Sort order in the portal switcher. |
enabled | boolean | true | Controls whether end users can access the portal. |
roles | string[] | null | Business role names granted visibility to routes linked to this layout. |
Reserved Slugs (RESERVED_SLUGS)
To prevent route collisions with administrative panels, public endpoints, and static asset handlers, the following 11 slugs are permanently reserved:
admin, settings, signin, signup, p, v, api, static, storage, files, latticelatticePortals API and PostgreSQL Advisory Locking
The latticePortals resource (native-portals.js) exposes five actions under the loggedIn ACL. All management actions (list, save, destroy, exportBlueprint) enforce isPortalAdmin, requiring root, allowConfigure: true, or role snippets containing pm / pm.*.
/api/latticePortals:list/api/latticePortals:listAccessible?includeMobile=false/api/latticePortals:save/api/latticePortals:destroy/api/latticePortals:exportBlueprint?uid=ldx-portal-logisticsTransaction Advisory Lock (741209551) and Route Grant Sync
Extended portal metadata (icon, color, description, isDefault, sort, roles) is persisted inside applicationPlugins.options.portals on the @latticedx/plugin-lattice-foundation row. To prevent concurrent admin saves from overwriting sibling entries in that JSON object, createPortalMetaStore.write acquires a transaction-scoped PostgreSQL advisory lock before reading and writing:
SELECT pg_advisory_xact_lock(741209551);The lock is released automatically when the outer Sequelize transaction commits or rolls back. Inside the same transaction, syncPortalRoles reconciles rolesDesktopRoutes for every desktopRouteId linked to the portal:
- Only roles satisfying
isBusinessPortalRoleare added or removed by portal role synchronization. - Before revoking an unchecked role from a route,
protectedByOtherPortalchecks whether that route is also linked toadmin-layout-modelor another portal whoserolesmetadata still grants that role, preventing accidental lockouts on shared routes.
curl -X POST https://localhost:8443/api/latticePortals:save \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slug": "quality-qa",
"title": "Quality Assurance Portal",
"layoutType": "desktop",
"icon": "SafetyCertificateOutlined",
"color": "#D94E1F",
"sort": 35,
"roles": ["ldx_warehouse", "ldx_manager", "ldx_admin"]
}'The 8 Native ldx_* Roles and Business Role Filtering
The @latticedx/plugin-lattice-foundation plugin provisions 8 operational roles (native-roles.js) with allowConfigure: false, allowNewMenu: false, allowNewAiEmployee: false, and collection/field-level ACL scopes.
| Role Name | Purpose | Document Read Scope (latticeRequests, latticeOrders) | Write & Operational Capabilities |
|---|---|---|---|
ldx_employee | Employee | Restricted to records where requester.userId or assignee.userId matches caller | Create requests/orders and update own draft records |
ldx_manager | Manager | Full visibility within tenant organization | Create, update own drafts, approve/reject/assign, manage IoT cases |
ldx_operator | Operator | Assigned or requested records | Execute operational tasks and complete assigned steps |
ldx_warehouse | Warehouse | Assigned or requested records | Execute FEFO stock allocations, issues, MKT holds, and lot checks |
ldx_dispatcher | Dispatcher | Full visibility within tenant organization | Create, update drafts, dispatch orders, and complete deliveries |
ldx_driver | Driver | Assigned or requested records | Complete delivery legs and submit field ePOD captures |
ldx_director | Director (read-only) | Full visibility within tenant organization | Read-only (view) across operational collections; no create or update |
ldx_admin | Business Admin | Full visibility within tenant organization | Full operational CRUD and incident resolution within the tenant |
The isBusinessPortalRole predicate (src/shared/portal-roles.js) governs which roles appear in the Multi-Portal Manager:
- The role name must match
BUSINESS_ROLE_NAME_RE = /^[a-z][a-z0-9_]{1,40}$/. - Four system roles in
SYSTEM_PORTAL_EXCLUDED_ROLESare always excluded:root,admin,anonymous,member. - Any role with
allowConfigure === trueor admin plugin snippets (pmorpm.*) is excluded.
Public Tenant Branding (/v/lattice-brand.svg) and Gateway Routing
Protected file storage under /files/* requires an authenticated session. To render tenant branding on the sign-in screen, /v/track/:code verification views, and /v/form/:slug intake pages without exposing internal file storage endpoints, public-branding.js registers two handlers:
createPublicBrandingGatewayHandler: ServesGETandHEADrequests for/v/lattice-brand.svg(and fallback/v/favicon_no_exist.ico) withContent-Type: image/svg+xml; charset=utf-8,Cache-Control: public, max-age=86400, andX-Content-Type-Options: nosniff.createSystemSettingsBrandingMiddleware: WrapssystemSettings:get. When the caller is unauthenticated or the logo references the seeded default/files/main/main/attachments/1.png(nocobase-logo), it rewriteslogo.urlandlogo.previewto/v/lattice-brand.svgand setslogo.titletoLatticeDX.
At the Nginx edge (infra/config/nginx/10-lattice-public-routes.sh), public routes proxy /.well-known/agent-card.json, /v/form, /v/track, /v/mobile, and /track to the application upstream while issuing a 302 redirect from /form to /v/form. Both BuilderShell and MultiPortalSettingsPage preserve the Powered by NocoBase attribution linking to https://www.nocobase.com in compliance with NocoBase 2.2.50 Clause 5.2.
Error Reference & Troubleshooting
| HTTP Status | Error Message | Resolution |
|---|---|---|
400 | Portal slug must match /^[a-z0-9](?:[a-z0-9-]{0,35}[a-z0-9])$/ or Portal slug is reserved | Use 2–37 lowercase alphanumeric/hyphen characters and avoid the 11 RESERVED_SLUGS. |
400 | Cannot delete built-in portal | Never call latticePortals:destroy on admin-layout-model or mobile-layout-model. |
403 | Portal administration permission required | Caller must hold root, allowConfigure: true, or pm / pm.* snippets. |
409 | Portal with this slug already exists or Portal route already exists | uid, routeName, or routePath already exists in uiLayouts; supply uid to update instead of creating. |
