nex-multitenant-saas-fastapi
by Ch1n4 G3nd4x
Prevent data leaks with auto-injected SQLAlchemy tenant scoping and Cloudflare Access auth for FastAPI SaaS apps.
- Enforce row-level isolation so devs can't accidentally query other tenants.
- Secure a FastAPI backend using Cloudflare Access JWT authentication.
- Create an auditable 'Owner' dashboard that safely queries across all tenants.
$19
· or 95 creditsSecure checkout via Stripe
Included in download
- Enforce row-level isolation so devs can't accidentally query other tenants.
- Secure a FastAPI backend using Cloudflare Access JWT authentication.
- terminal automation included
Sample input
Set up a new FastAPI SaaS core with multi-tenancy, using Cloudflare Access for auth and an initial tenant named 'Acme Corp'.
Sample output
I've generated the multitenant-core/ package. It includes:
app/database.py: SQLAlchemy listener for auto-filtering queries.app/dependencies.py: Cloudflare JWT verification & tenant context injection.app/models/:UserandTenantbase models.
Run python -m app.scripts.seed_tenant to begin.
nex-multitenant-saas-fastapi
by Ch1n4 G3nd4x
Prevent data leaks with auto-injected SQLAlchemy tenant scoping and Cloudflare Access auth for FastAPI SaaS apps.
$19
· or 95 creditsSecure checkout via Stripe
Included in download
- Enforce row-level isolation so devs can't accidentally query other tenants.
- Secure a FastAPI backend using Cloudflare Access JWT authentication.
- terminal automation included
- Instant install
Sample input
Set up a new FastAPI SaaS core with multi-tenancy, using Cloudflare Access for auth and an initial tenant named 'Acme Corp'.
Sample output
I've generated the multitenant-core/ package. It includes:
app/database.py: SQLAlchemy listener for auto-filtering queries.app/dependencies.py: Cloudflare JWT verification & tenant context injection.app/models/:UserandTenantbase models.
Run python -m app.scripts.seed_tenant to begin.
About This Skill
Multi-Tenant Security for FastAPI
Building a multi-tenant SaaS requires more than just adding a tenant_id column; it requires a bulletproof architecture that prevents data leaks by design. This skill generates a production-ready multi-tenancy core for FastAPI and SQLAlchemy that implements row-level isolation at the database layer.
What it does
- Automatic Row-Level Isolation: Uses a SQLAlchemy event listener to automatically inject
WHERE tenant_idinto every query. Developers literally cannot forget to scope a read. - "Secure by Default" Failure: The system defaults to a null tenant context. If a tenant isn't identified, queries return zero rows instead of leaking data across tenants.
- Auditable Escape Hatches: Provides an explicit
no_tenant_scope()context manager for cross-tenant admin operations, requiring a logged reason for every bypass. - Cloudflare Access Integration: Bundles JWT authentication with fallbacks for local development and trusted-network header modes.
- Role-Based Access Control (RBAC): Includes three pre-defined roles (Owner, Partner, Client Viewer) with logic to handle global vs. scoped access permissions.
Why use this skill?
Instead of manually writing .filter(tenant_id=...) on every single endpoint—a process prone to human error—this skill applies isolation globally. It solves the "noisy neighbor" problem and data leakage concerns before you write your first business logic route. It is based on the proven architecture used in high-scale SaaS products.
Supported Stack
- FastAPI (Async)
- SQLAlchemy 2.0+ (Async)
- Pydantic v2 (Settings & Validation)
- Cloudflare Access (Auth)
- PostgreSQL (Shared database, row-level isolation)
Use Cases
- Enforce row-level isolation so devs can't accidentally query other tenants.
- Secure a FastAPI backend using Cloudflare Access JWT authentication.
- Create an auditable 'Owner' dashboard that safely queries across all tenants.
- Implement role-based access for Owners, Partners, and scoped Client Viewers.
How to Install
mkdir -p ~/.claude/skills && curl -sL https://www.agensi.io/api/install/nex-multitenant-saas-fastapi -o /tmp/nex-multitenant-saas-fastapi.zip && unzip -o /tmp/nex-multitenant-saas-fastapi.zip -d ~/.claude/skills && rm /tmp/nex-multitenant-saas-fastapi.zipFree skills install directly. Paid skills require purchase - use the download button above after buying.
Reviews
No reviews yet - be the first to share your experience.
Only users who have downloaded or purchased this skill can leave a review.
Early access skill
Be the first to review this skill.
Only users who have downloaded or purchased this skill can leave a review.
Security Scanned
Passed automated security review
Permissions
Allowed Hosts
File Scopes
Creator
Founder of Nex AI. I build production-grade Claude Skills from systems that actually run: multi-tenant SaaS, Telegram agents, Raspberry Pi infrastructure, 3D multiplayer rooms. Every skill ships battle-tested patterns, not theory. 33+ open source skills published, commercial catalog growing.
Frequently Asked Questions
Learn More About AI Agent Skills
More Premium Skills
gtm-engine
High-conversion sales outreach, SaaS agreements, and marketing collateral for revenue-focused AI agents.
designing-hybrid-context-layers
Architects the right retrieval strategy for every query — teaching your agent when to use RAG, a knowledge graph, or a temporal index instead of defaulting to vector search for everything.
consumer-motivation-analyzer
Go beyond surface-level feedback to uncover the psychological drivers and hidden motivations behind buyer behavior.
keyword-research
Transform URLs or product lists into SEO keyword research packs with Google Ads data and intent-based clustering.