Multi-Tenant Architecture in Pilardin SaaS: A Practical Build Checklist
A step-by-step guide to designing tenant isolation, encryption boundaries, and access controls for a multi-tenant Pilardin SaaS deployment without breaking RAG or live-system integrations.
What you will end up with — and what to prepare
By the end of this build, you should have a Pilardin SaaS workspace where every customer, business unit, or regulated project is a first-class tenant. That means a shared control plane for provisioning and billing, but tenant-scoped data paths for document ingestion, retrieval, live-system connectors, and Matrix modules. The practical outcome is not just a tenant_id column. It is a repeatable way to answer three questions: which tenant owns this object, which key protects it, and which identity is allowed to use it. You will also have an onboarding path that can be tested before the first paying tenant arrives.
The prerequisites are organizational as much as technical. Define your tenant hierarchy before provisioning: is a tenant a company, a department, or a regulated environment with separate residency rules? Classify data that will enter RAG and live connectors, because public support articles and payroll records cannot share the same isolation assumptions. Confirm whether customers require bring-your-own-key, dedicated storage, or in-country residency. Finally, name owners for identity, encryption, platform operations, and audit evidence. Without those decisions, multi-tenancy becomes a set of ad hoc filters that are hard to verify and harder to sell.
Define tenant boundaries before you write infrastructure code
Start with a written boundary model rather than a database diagram. For each object in Pilardin — users, documents, embeddings, connector credentials, conversation history, Matrix module runs, and audit events — record the tenant scope and the lifecycle owner. Decide which resources are shared, which are logically isolated in a shared cluster, and which require dedicated infrastructure. This is where commercial promises meet architecture: a customer asking for strict residency or a separate encryption key is really asking for a different isolation tier. Put that tier in the contract and in the provisioning template, not only in a security FAQ.
A useful pattern is to separate the control plane from the data plane. The control plane handles tenant metadata, plans, feature flags, and provisioning; the data plane handles documents, vector indexes, model calls, and connector traffic. The control plane can be shared, but every request into the data plane must carry a verified tenant context. If you use shared tables, enforce tenant scope in the data access layer and add database-level row security where possible. If you use dedicated databases or buckets per tenant, automate their creation and deletion so operations do not become a manual checklist.
- Shared schema with row-level security — best for many small tenants and fast onboarding / Dedicated database — best for regulated tenants or noisy-neighbor risk.
- Shared vector index with tenant metadata — best for cost efficiency / Per-tenant index or namespace — best for strict retrieval isolation and simpler deletion.
- Platform-managed keys — best for standard SaaS / Customer-managed keys or BYOK — best for tenants with contractual key-control requirements.
Isolate data paths across RAG, connectors, and Matrix modules
RAG is where tenant isolation is easiest to claim and easiest to break. Every document chunk, embedding, metadata field, and retrieval query needs a tenant identifier that is enforced at write time and checked at read time. Do not rely on the model prompt to keep tenants apart. Apply tenant filters in the retrieval layer, keep separate namespaces or indexes when the isolation tier requires it, and test that a query from tenant A cannot return a chunk from tenant B even when the semantic similarity is high. Document deletion also needs to be tenant-scoped: removing a tenant should remove its chunks, embeddings, source files, and cache entries, not just hide them from the UI.
Live-system connectors and Matrix modules add credentials and runtime state. Store connector secrets in a tenant-scoped secret manager, and scope OAuth grants or API keys to the smallest set of resources. When a Matrix module runs, pass tenant context explicitly and avoid global caches that can leak state between runs. Logs deserve the same discipline: structured audit events should include tenant ID, actor, action, and object, but log aggregation must prevent one tenant's operators from reading another tenant's events. If you offer on-premise AI or a hybrid deployment, keep the same boundary model so a tenant can move between hosted and dedicated environments without redesigning the permission model.
- Documents and chunks — tenant-scoped object paths, metadata filters, and deletion jobs.
- Connectors — tenant-owned credentials, scoped tokens, and separate sync schedules.
- Matrix modules — explicit tenant context, isolated runtime state, and per-tenant quotas.
Build identity, access, and key-management boundaries
Tenant isolation fails if identity is ambiguous. Use OIDC or SAML for enterprise customers and map each authenticated session to a tenant membership with roles. Do not let a user switch tenants by changing a request parameter without re-authorizing the session. Apply role-based access control for common roles such as tenant admin, analyst, and auditor, and use attribute-based rules for sensitive cases such as residency or project-level access. Service accounts and API clients need tenant-scoped credentials, rotation policies, and audit trails. If your product supports organizational AI agents or AI employees, treat their permissions as delegated identity, not as a superuser shortcut.
Encryption should reinforce the boundary model. At minimum, use envelope encryption with per-tenant data keys wrapped by a platform key, and record which key protects which data class. For tenants with stricter requirements, support customer-managed keys or dedicated key stores. Key rotation must be testable and must not require downtime. Access to keys should be separated from application operators, because the ability to decrypt tenant data is effectively the ability to read it. Add audit events for key use, admin impersonation, cross-tenant support access, and permission changes. These are the controls enterprise buyers will ask about during security review, and they are much cheaper to build before the first integration than after.
- Authentication — federated SSO with tenant-aware session claims.
- Authorization — RBAC for routine roles plus ABAC for residency and project boundaries.
- Keys — per-tenant data keys, rotation, and optional BYOK.
- Audit — immutable events for cross-tenant access and administrative actions.
Make onboarding and operations repeatable
A multi-tenant architecture is only finished when a new tenant can be provisioned, configured, tested, and retired through a repeatable path. Treat tenant provisioning as code: create the tenant record, assign the isolation tier, configure identity, provision storage and vector namespaces, set quotas, and seed default roles from a template. The same template should produce the evidence needed for support and audit, such as tenant ID, region, key reference, and enabled modules. Avoid one-off scripts for enterprise customers; they become hidden dependencies that break during upgrades.
Operations need tenant-aware observability. Dashboards should show usage, error rates, ingestion lag, connector health, and model spend by tenant without exposing one tenant's content to another. Set rate limits and quotas per tenant so a single workload cannot degrade shared services. Plan the offboarding path early: revoke credentials, stop connectors, delete or export data according to contract, rotate keys, and retain only the audit records you are required to keep. In Pilardin, this operational discipline matters because the platform combines document chat, live-system connections, and specialized Matrix modules in one workspace; each surface can create tenant data and each must honor the same boundaries.
Implementation checklist: from tenant model to verified isolation
Work through this checklist in order. Items one through three decide the commercial and security shape of the build; items four through eight enforce it in the product; items nine through twelve make it operable and provable. Do not mark the architecture complete until the final isolation test has been run against a realistic tenant configuration, including at least one tenant with stricter residency or key requirements.
- Write the tenant model: company, department, region, isolation tier, and data-residency requirements.
- Classify data types entering RAG, connectors, conversations, and Matrix modules; mark the highest sensitivity for each tenant.
- Choose the isolation tier per tenant: shared schema with row security, dedicated database, dedicated bucket, or hybrid.
- Define identity claims and enforce tenant membership on every API request; re-authorize when a user switches tenant.
- Scope document ingestion, embeddings, vector search, and deletion jobs by tenant; test cross-tenant retrieval with adversarial queries.
- Put connector credentials in a tenant-scoped secret store and restrict OAuth scopes or API keys to the minimum required.
- Isolate Matrix module runtime state and pass tenant context explicitly; add per-tenant quotas and timeouts.
- Implement envelope encryption with per-tenant data keys; document key ownership, rotation, and optional BYOK.
- Build tenant provisioning as code with templates for roles, storage, modules, quotas, and audit settings.
- Add audit events for cross-tenant support access, admin impersonation, key use, and permission changes.
- Create tenant-aware dashboards and alerts for usage, errors, ingestion lag, connector health, and spend.
- Run an isolation test before launch: attempt to read, retrieve, export, and delete another tenant's data from every surface.
Common mistakes that break tenant isolation
Most multi-tenant failures are not exotic attacks; they are small shortcuts that become cross-tenant paths. The most common is filtering only in the UI while the API trusts a tenant ID from the client. Another is adding tenant metadata to documents but forgetting embeddings, caches, exports, and logs. Teams also underestimate connector credentials, which often carry broader scope than the product needs, and support impersonation, which can bypass normal access checks if it is not separately audited.
- Trusting a client-supplied tenant ID instead of deriving it from the authenticated session.
- Using a shared vector index without enforced metadata filters and deletion tests.
- Leaving connector secrets in application configuration rather than a tenant-scoped secret manager.
- Giving support or AI agents broad cross-tenant access without time limits, approvals, and audit events.
- Treating key rotation and tenant offboarding as manual runbooks that are never rehearsed.
How you know the build is done
The build is done when every Pilardin object has an owner, every request has a verified tenant context, and every isolation claim can be demonstrated with a test or audit record. A new tenant should be provisionable from a template in minutes for standard tiers, while stricter tiers should have explicit approval and key-management steps. Support staff should be able to help a tenant without seeing another tenant's data. Customers should be able to export or delete their data according to contract, and your team should be able to prove that deletion removed the relevant chunks, embeddings, credentials, and caches.
Use a final acceptance review with engineering, security, and customer success. Confirm that RAG, live connectors, and Matrix modules all honor the same boundary model. Confirm that logs and dashboards are tenant-aware without leaking content. Confirm that encryption keys and audit events are documented in the security package. If you need a starting point for commercial tiers or module boundaries, review /pricing and /matrix before your first enterprise security review. The goal is not to claim multi-tenancy; it is to make tenant isolation boring, repeatable, and easy to verify.
FAQ
These are the questions that come up most often when teams move from a single-tenant pilot to a multi-tenant Pilardin SaaS design.
Do we need a separate database for every tenant in Pilardin SaaS?
Not necessarily. Many SaaS products can run many tenants in a shared database with enforced tenant scope and row-level security, provided that every data access path is tested. A dedicated database or bucket makes sense for tenants with strict residency requirements, heavy workloads, or contractual isolation terms. The important decision is to define isolation tiers up front and make the tier explicit in provisioning, pricing, and security documentation.
How should RAG retrieval enforce tenant isolation?
Apply tenant filters at write time and read time, not in the prompt. Store tenant identity with every chunk and embedding, enforce it in the retrieval service, and use separate namespaces or indexes when the isolation tier requires them. Test with adversarial queries that try to retrieve another tenant's content using similar language. Also test deletion, because a tenant offboarding process that leaves embeddings behind is still a cross-tenant data exposure.
What is the minimum viable key-management model for multi-tenant Pilardin?
Use envelope encryption with per-tenant data keys wrapped by a platform key, separate key administration from application operations, and document rotation and recovery procedures. Add customer-managed keys or BYOK for tenants that require them. Audit key use and administrative access. The goal is to ensure that decrypting one tenant's data does not require exposing another tenant's key material or giving every operator broad key access.
How do we test multi-tenant isolation before launch?
Build a test matrix that covers every surface: document upload, retrieval, conversation history, connector credentials, Matrix module runs, exports, logs, and deletion. Attempt cross-tenant reads, searches, exports, and deletes using both the UI and the API. Include support impersonation and service-account paths. Rerun the suite after any change to authentication, retrieval, caching, or connector scopes. A successful test is evidence, not just a green build.
Can on-premise or hybrid deployments reuse the same architecture?
Yes, and they should reuse the same tenant boundary model. The difference is usually key custody, network placement, and operational ownership. Keep tenant identity, retrieval filters, connector scopes, and audit events consistent across hosted, dedicated, and on-premise AI environments so a tenant can move between deployment models without a redesign. Document which controls the customer owns and which Pilardin operates in each model.
Related
- Как спроектировать управление кредитами и потреблением ИИ-сервисов в Pilardin: чек-лист
- Arquitectura multiinquilino en Pilardin SaaS: checklist para aislar datos, RAG y costos
- Mandantenfähigkeit für Pilardin SaaS bauen: Checkliste für Datenisolation, RAG und Kosten
- Architecture multi-tenant chez Pilardin SaaS : isoler les données sans démultiplier les coûts
- Pilardin يطوّر بنية متعددة المستأجرين: العزل ينتقل من الواجهة إلى الاسترجاع
- مدیریت اعتبار و مصرف خدمات هوش مصنوعی در Pilardin چگونه طراحی میشود؟