# shivay00001/10_saas_architecture architecture

> Architecture diagram of the GitHub repository shivay00001/10_saas_architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivay00001/10_saas_architecture
- Repository: https://github.com/shivay00001/10_saas_architecture

## Overview

#### 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`](https://github.com/shivay00001/10_saas_architecture/blob/main/src/__init__.py) (src package), [`src/tenants/isolation.py`](https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/isolation.py) (Tenant isolation), [`Dockerfile`](https://github.com/shivay00001/10_saas_architecture/blob/main/Dockerfile) (Application image), [`src/tenants/__init__.py`](https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/__init__.py) (tenants package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_current["Current implementation"]
  node_src_package["src package<br/>Python package<br/>[__init__.py]"]
  node_tenants_package["tenants package<br/>Python package<br/>[__init__.py]"]
  node_isolation{{"Tenant isolation<br/>tenant context boundary<br/>[isolation.py]"}}
  node_callers(("Library callers<br/>consumer"))
end

subgraph group_planned["Planned SaaS boundaries"]
  node_tenant_models["Tenant models<br/>planned domain boundary"]
  node_tenant_onboarding["Tenant onboarding<br/>planned domain boundary"]
  node_billing["Billing and metering<br/>planned domain boundary"]
  node_stripe["Stripe integration<br/>planned external integration"]
  node_features["Feature entitlements<br/>planned domain boundary"]
  node_limits["Usage limits<br/>planned domain boundary"]
end

subgraph group_delivery["Packaging and delivery"]
  node_package_metadata["Package metadata<br/>Python packaging<br/>[pyproject.toml]"]
  node_container_image["Application image<br/>container build"]
  node_compose["Compose topology<br/>container orchestration<br/>[docker-compose.yml]"]
  node_deploy_workflow["Deployment workflow<br/>CI/CD automation<br/>[deploy.yml]"]
end

node_callers -->|"import"| node_src_package
node_src_package -->|"exposes"| node_tenants_package
node_tenants_package -->|"exports"| node_isolation
node_callers -->|"establishes tenant context"| node_isolation
node_isolation -.->|"would scope"| node_tenant_models
node_tenant_onboarding -.->|"creates"| node_tenant_models
node_tenant_models -.->|"subscription lifecycle"| node_billing
node_billing -.->|"integrates"| node_stripe
node_billing -.->|"determines entitlements"| node_features
node_features -.->|"governs usage"| node_limits
node_package_metadata -->|"packages"| node_src_package
node_container_image -->|"contains"| node_src_package
node_compose -->|"runs"| node_container_image
node_deploy_workflow -->|"deploys"| node_container_image

click node_src_package "https://github.com/shivay00001/10_saas_architecture/blob/main/src/__init__.py"
click node_tenants_package "https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/__init__.py"
click node_isolation "https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/isolation.py"
click node_package_metadata "https://github.com/shivay00001/10_saas_architecture/blob/main/pyproject.toml"
click node_container_image "https://github.com/shivay00001/10_saas_architecture/blob/main/Dockerfile"
click node_compose "https://github.com/shivay00001/10_saas_architecture/blob/main/docker-compose.yml"
click node_deploy_workflow "https://github.com/shivay00001/10_saas_architecture/blob/main/.github/workflows/deploy.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_src_package,node_tenants_package,node_isolation,node_callers toneBlue
class node_tenant_models,node_tenant_onboarding,node_billing,node_stripe,node_features,node_limits toneAmber
class node_package_metadata,node_container_image,node_compose,node_deploy_workflow toneMint
```

## Components

### Current implementation

- [src package](https://github.com/shivay00001/10_saas_architecture/blob/main/src/__init__.py): Python package · Available top-level package boundary. · `src/__init__.py`
- [tenants package](https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/__init__.py): Python package · `src/tenants/__init__.py`
- [Tenant isolation](https://github.com/shivay00001/10_saas_architecture/blob/main/src/tenants/isolation.py): tenant context boundary · Prevents cross-tenant access before downstream operations. · `src/tenants/isolation.py`
- **Library callers**: consumer · Supply or establish tenant-scoped context.

### Planned SaaS boundaries

README-documented boundaries not present in the tree.

- **Tenant models**: planned domain boundary
- **Tenant onboarding**: planned domain boundary
- **Billing and metering**: planned domain boundary
- **Stripe integration**: planned external integration · No client implementation exists.
- **Feature entitlements**: planned domain boundary
- **Usage limits**: planned domain boundary

### Packaging and delivery

- [Package metadata](https://github.com/shivay00001/10_saas_architecture/blob/main/pyproject.toml): Python packaging · Defines dependencies and package metadata. · `pyproject.toml`
- [Application image](https://github.com/shivay00001/10_saas_architecture/blob/main/Dockerfile): container build · `Dockerfile`
- [Compose topology](https://github.com/shivay00001/10_saas_architecture/blob/main/docker-compose.yml): container orchestration · `docker-compose.yml`
- [Deployment workflow](https://github.com/shivay00001/10_saas_architecture/blob/main/.github/workflows/deploy.yml): CI/CD automation · Deployment target is unspecified. · `.github/workflows/deploy.yml`

## Connections

- 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
