System design
Multi-Tenant App Design: Keep Each Customer's Data Separate
A multi-tenant app serves several customers through shared software. The critical requirement is that each customer sees only the information and actions they are authorized to use. This must be enforced on the server, not just by hiding controls.
Define the tenant boundary
Decide whether a tenant is an individual, company or project. A company may contain several users with different roles. Write down how membership is granted and removed before implementing shared records.
Keep the authenticated user, tenant membership and record ownership distinct. A user can belong to two organizations without every record becoming shared between them. Require an explicit current context when an action could affect either organization.
Scope every data operation
Apply tenant checks to reads, writes, searches, exports and file downloads. It is easy to protect a detail page while forgetting an autocomplete endpoint or a bulk export. Review the complete route inventory.
Do not trust a tenant ID supplied by the browser on its own. Resolve allowed memberships from the session and verify that the target record belongs to an authorized tenant before returning or changing it.
Test isolation deliberately
Create two fictional tenants with similarly named records. Attempt cross-tenant access by changing record IDs and download links. Test a former member whose access was removed while a browser tab remained open.
Check caches and background jobs too. A cache key without tenant context can leak a correct response to the wrong user. A queued task must preserve the intended tenant and recheck relevant permissions when it executes.
Limit administrative access
Document which support roles can access customer data and for what purpose. Log consequential administrative actions. Avoid using a universal administrator credential for routine customer-facing operations.
CloudWira project separation and supported app permissions are useful boundaries, but a custom multi-tenant workflow still needs explicit design and testing. Confirm the platform's supported model before promising organization-level features that your app has not implemented.
Write down what a tenant actually means
A tenant might be a company, a team or an individual account. Choose the boundary that matches the product. In a client portal, one company may have several users who share selected records, while a consultant can work with several companies. Model those memberships explicitly. Treating every signed-in user as equivalent makes it difficult to distinguish shared work from another customer's private data.
For every record type, define which tenant owns it and which roles can read, create, change or export it. The server should derive the active tenant from a verified membership. A tenant identifier in a URL is useful routing information, but it is not proof of access. Recheck membership when a user switches organizations, follows an old link or resumes an expired session.
Check all the routes that can return information
Isolation must apply to lists, search suggestions, file downloads, exports and background jobs. A detail page may be secure while an export includes every tenant's rows. A search endpoint may leak names or counts even when it hides the full record. Review the complete request path and make the scoped query the default rather than relying on each page developer to remember a filter.
Include storage and caching in the design. File paths should not become public merely because the database row is private. Cached responses must include the relevant identity scope or avoid caching private content. Logs and error messages should not reveal another tenant's fields. When an asynchronous job runs later, carry a verified tenant reference and recheck the permission needed for the operation.
Build a deliberate cross-tenant test matrix
Create tenants A and B with separate users and records. While signed in as A, try B's record identifier in reads, updates, downloads and exports. Test a user removed from a team, a role changed during a session and a signed-out request. Confirm that a denied response contains no private payload, not just a generic error alongside leaked data.
Repeat the matrix after adding a new endpoint or administrative feature. Use synthetic data and record the expected result for each role. A tenant boundary should fail closed when a membership lookup is unavailable. Avoid tests that merely inspect whether a filter string exists in code; exercise the actual response and stored result so you catch routing and query mistakes together.
Keep support access narrow and accountable
Operators may need to investigate a customer issue, but broad access should be intentional. Give administrative actions separate permissions, record why support access was used and limit the information shown. Do not grant an AI assistant global account access simply because it helps support staff write replies. The human operator's role and the model's tool scope can be different.
For a CloudWira-hosted interface, verify managed collection permissions and any external backend tenant checks independently. Publishing a page does not change private data into public content, and hiding a menu does not enforce a tenant boundary. Before onboarding a second real customer, complete the two-tenant test. Isolation becomes much harder to retrofit after records and files have accumulated without clear ownership.
Is a difficult-to-guess identifier enough protection?
No. An identifier can reduce accidental discovery, but it does not establish that the requester belongs to the correct tenant. The server must verify membership and permission for the requested operation. Test using a known identifier from another synthetic tenant. The request should be denied even though the test deliberately removes any guessing difficulty.
Keep this case in the release suite for every route that exposes tenant data. Include search, exports and attachments, because they can use different handlers from the main detail page. When support needs access, grant it through an explicit administrative role with a useful audit reference. Do not weaken the ordinary tenant boundary to make an investigation convenient. Clear ownership and consistent authorization remain the core of isolation.