multitenant
Skill108 starsChanged 6 days agoMITView on GitHub
Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.
In this repository61 other files it gives its agents.
- docs/AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- .claude/references/angular/CLAUDE.mdCLAUDE.md
- .claude/references/flutter/CLAUDE.mdCLAUDE.md
- .claude/references/laravel/CLAUDE.mdCLAUDE.md
- .claude/references/paperclip/CLAUDE.mdCLAUDE.md
- .claude/references/reactnative/CLAUDE.mdCLAUDE.md
- .claude/references/svelte/CLAUDE.mdCLAUDE.md
- .claude/references/symfony/CLAUDE.mdCLAUDE.md
- .claude/references/vite/CLAUDE.mdCLAUDE.md
- .claude/references/vuejs/CLAUDE.mdCLAUDE.md
- aggregatesSkill
- api-gatewaySkill
- architectSkill
- architecture-clean-dddSkill
- architectureSkill
- asyncSkill
- atomic-tasksSkill
- coding-standardsSkill
- cqrsSkill
- ddd-patternsSkill
- debug-methodicalSkill
- design-md-conventionSkill
- docker-hadolintSkill
- doctrine-extensionsSkill
- documentationSkill
- domain-eventsSkill
- dynamic-workflowsSkill
- ecosystem-toolsSkill
- edge-computingSkill
- event-drivenSkill
- git-workflowSkill
- graphqlSkill
- i18nSkill
- kiss-dry-yagniSkill
- monorepoSkill
- navigationSkill
- observabilitySkill
- parallel-worktreesSkill
- performanceSkill
- quality-toolsSkill
- remotionSkill
- security-flutterSkill
- security-reactnativeSkill
- security-reactSkill
- securitySkill
- security-symfonySkill
- socratic-brainstormSkill
- solid-principlesSkill
- state-managementSkill
- sub-agents-patternsSkill
- testing-flutterSkill
- testing-pythonSkill
- testing-reactnativeSkill
- testing-reactSkill
- testingSkill
- testing-symfonySkill
- toolingSkill
- value-objectsSkill
- wasmSkill
- The first 60 shown.
The file
Files
Multitenant — Quick Reference
Servir plusieurs clients (tenants) sur la même base de code avec isolation stricte et un coût d'infra contrôlé.
Trois tiers d'isolation
| Tier | Isolation | Coût | Cas d'usage |
| Tier 1 — Shared schema | colonne tenant_id partout, filtres SQL automatiques | Faible | Startups, free / petits clients |
| Tier 2 — Dedicated schema | un schéma PostgreSQL par tenant | Moyen | SMB, clients exigeants |
| Tier 3 — Dedicated DB | une base entière par tenant | Élevé | Enterprise, compliance stricte (HDS, FedRAMP) |
Règle de migration : commencer Tier 1, migrer un client en Tier 2/3 quand il représente > 20 % du revenu OU exige un SLA spécifique.
Cinq invariants non-négociables
tenant_idpropagé à chaque requête (AsyncLocalStorage / SecurityContext / middleware).- PostgreSQL Row-Level Security (RLS) activé sur TOUTES les tables. Filet de sécurité contre un oubli applicatif.
- Tests d'isolation obligatoires. Tenant A ne doit jamais lire/écrire les données de B — y compris via tri, requête nuée, agrégat.
- Audit trail isolé par tenant. Pas de log multi-tenant cross-référencé sans permission explicite.
- Field-level encryption sur PII / secrets sensibles (Halite PHP, Eloquent Casts, libsodium).
Pattern minimal — Shared schema + RLS
ALTER TABLE invoices ADD COLUMN tenant_id UUID NOT NULL;
ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation ON invoices
USING (tenant_id = current_setting('app.tenant_id')::uuid);// Symfony — middleware qui set la variable session pour RLS
$conn->executeStatement(
'SET LOCAL app.tenant_id = :tid',
['tid' => $tenantId]
);Anti-patterns critiques
- ❌ Oublier le filtre
tenant_iddans une requête raw → fuite cross-tenant. - ❌ Cache Redis sans préfixe tenant → données de A retournées à B.
- ❌ Job worker async qui perd le
tenant_id→ impossible de retrouver le contexte. - ❌ Signed URLs / tokens sans
tenant_iddans le payload → utilisable cross-tenant. - ❌ Field encryption avec une clé unique partagée → compromission = exposition totale (préférer keys per tenant).
RBAC / ABAC
- RBAC : rôles globaux (
admin,member,viewer) suffisent pour 80 % des cas. - ABAC : passer à des policies (Casbin, Cerbos, OPA) quand les règles dépendent d'attributs (région, montant, statut).
Pour aller plus loin
Patterns détaillés par tier, migration tier 1 → tier 2 sans downtime, tests d'isolation (Pest + tenant fixtures), RBAC/ABAC, exemples Laravel + Symfony, checklists par phase : voir
@.claude/skills/multitenant/REFERENCE.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

