How shivay00001/10_saas_architecture works
Purpose and Current Scope
This repository is intended as a production-oriented multi-tenant SaaS backend covering tenant isolation, subscriptions, feature flags, and usage billing. The checked-in implementation is currently much narrower: only the tenant-isolation package is present under src/tenants/isolation.py; the billing, feature, limits, models, onboarding, and main-module paths described in README.md are absent from the file tree.
Entry Points and Packaging
The declared quick-start command is python -m src.main, but src/main.py is not present. The available Python package boundary is src/__init__.py, with tenant functionality exposed beneath src/tenants/__init__.py. Dependency and package metadata should be sourced from pyproject.toml.
Relevant paths:
• src/__init__.py
• src/tenants/__init__.py
• pyproject.toml
Tenant Isolation Core
src/tenants/isolation.py is the sole implementation-level domain component and therefore the current architectural center. It should be treated as the boundary responsible for preventing cross-tenant data access and for carrying tenant context into downstream persistence or service operations.
Relevant paths:
• src/tenants/isolation.py
• src/tenants/__init__.py
Intended SaaS Domain Stages
The README defines the planned domain pipeline: tenant setup and isolation; subscription-plan and billing lifecycle; feature entitlement evaluation; and usage measurement/limit enforcement. These stages are conceptual only until the corresponding packages are added. A planner should not infer implementation APIs or dependencies for them from the README.
Documented-but-missing boundaries:
• Tenant models/onboarding: src/tenants/models.py, src/tenants/onboarding.py
• Billing/metering/Stripe: src/billing/plans.py, src/billing/metering.py, src/billing/stripe.py
• Feature flags and limits: src/features/flags.py, src/limits/
Primary Control and Data Flow
The currently supportable flow is package initialization into tenant-isolation logic: callers import from src/src.tenants, establish or supply tenant-scoped context, and invoke isolation behavior before tenant-owned data is accessed. No API server, persistence adapter, queue consumer, billing webhook handler, or executable application entry point exists in the checked-in tree.
Relevant paths:
• src/__init__.py
• src/tenants/isolation.py
Runtime and Deployment Boundary
The project is containerized and includes a Compose deployment topology. Dockerfile defines the application image boundary, while docker-compose.yml defines local or multi-container orchestration. GitHub Actions deployment automation is located in .github/workflows/deploy.yml; its exact target infrastructure is not derivable from the supplied tree alone.
Relevant paths:
• Dockerfile
• docker-compose.yml
• .github/workflows/deploy.yml
External Services and Gaps
Stripe is named as the intended billing integration in README.md, but no Stripe client or billing implementation exists in the repository. Likewise, no database, cache, identity provider, or message broker is represented by source paths. Any graph plan should model these as future integration nodes rather than existing runtime dependencies.
Main entry points: src/__init__.py src package · isolation.py Tenant isolation · Dockerfile Application image · tenants/__init__.py tenants package
Components 14
Current implementation
- src package · Available top-level package boundary.
src/__init__.py - tenants package
src/tenants/__init__.py - Tenant isolation · Prevents cross-tenant access before downstream operations.
src/tenants/isolation.py - Library callers · Supply or establish tenant-scoped context.
Planned SaaS boundaries
README-documented boundaries not present in the tree.
- Tenant models
- Tenant onboarding
- Billing and metering
- Stripe integration · No client implementation exists.
- Feature entitlements
- Usage limits
Packaging and delivery
- Package metadata · Defines dependencies and package metadata.
pyproject.toml - Application image
Dockerfile - Compose topology
docker-compose.yml - Deployment workflow · Deployment target is unspecified.
.github/workflows/deploy.yml
Connections 14
- Library callers → src package: import
- src package → tenants package: exposes
- tenants package → Tenant isolation: exports
- Library callers → Tenant isolation: establishes tenant context
- Tenant isolation → Tenant models: would scope
- Tenant onboarding → Tenant models: creates
- Tenant models → Billing and metering: subscription lifecycle
- Billing and metering → Stripe integration: integrates
- Billing and metering → Feature entitlements: determines entitlements
- Feature entitlements → Usage limits: governs usage
- Package metadata → src package: packages
- Application image → src package: contains
- Compose topology → Application image: runs
- Deployment workflow → Application image: deploys