# nextify-limited/saasfly architecture

> Architecture diagram of the GitHub repository nextify-limited/saasfly, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nextify-limited/saasfly
- Repository: https://github.com/nextify-limited/saasfly

## Overview

Saasfly is a Next.js SaaS starter with a public marketing and documentation site, user authentication, a customer dashboard, billing, and Kubernetes-cluster screens. The user-facing flow runs from public pricing or sign-in into authenticated dashboard features; billing operations are exposed through the API and Stripe webhooks update subscription records. The graph also preserves the documented i18n and SEO capabilities and the cluster and admin areas visible in the route tree. Several routes and API routers were not sampled, so their internal connections are omitted rather than inferred.

Main entry points: [`packages/api/src/router/stripe.ts`](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/stripe.ts) (Billing procedures), [`packages/stripe/src/webhooks.ts`](https://github.com/nextify-limited/saasfly/blob/main/packages/stripe/src/webhooks.ts) (Webhook processing), [`packages/auth/clerk.ts`](https://github.com/nextify-limited/saasfly/blob/main/packages/auth/clerk.ts) (Clerk authentication), [`packages/db/index.ts`](https://github.com/nextify-limited/saasfly/blob/main/packages/db/index.ts) (Application database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js experience"]
  node_public["Marketing site<br/>[page.tsx]"]
  node_content["Blog and docs<br/>[page.tsx]"]
  node_pricing["Pricing pages<br/>[page.tsx]"]
  node_login["Sign-in pages<br/>[page.tsx]"]
  node_dashboard["Customer dashboard<br/>[page.tsx]"]
  node_settings["Account settings<br/>[page.tsx]"]
  node_clusters["Cluster editor<br/>[page.tsx]"]
  node_admin["Admin dashboard<br/>[page.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Clerk authentication<br/>[clerk.ts]"]
  node_authproxy["Auth proxy<br/>[&#91;...auth&#93;.ts]"]
end

subgraph group_api["API and data"]
  node_trpc["tRPC context<br/>[trpc.ts]"]
  node_apiroot["API routers<br/>[root.ts]"]
  node_k8sapi["Cluster procedures<br/>[k8s.ts]"]
  node_customerapi["Customer procedures<br/>[customer.ts]"]
  node_authapi["Subscription query<br/>[auth.ts]"]
  node_database[("Application database<br/>[index.ts]")]
end

subgraph group_billing["Billing"]
  node_stripeapi["Billing procedures<br/>[stripe.ts]"]
  node_plans["Subscription plans<br/>[subscriptions.ts]"]
  node_stripe["Stripe integration<br/>[index.ts]"]
  node_webhookroute["Stripe webhook route<br/>[route.ts]"]
  node_webhooks["Webhook processing<br/>[webhooks.ts]"]
end

node_visitor(("Visitor"))

node_visitor -->|"visits"| node_public
node_visitor -->|"signs in"| node_login
node_visitor -->|"views plans"| node_pricing
node_visitor -.->|"uses app"| node_dashboard
node_dashboard -->|"uses identity"| node_auth
node_public -.->|"offers content"| node_content
node_pricing -.->|"displays plans"| node_plans
node_authproxy -.->|"forwards auth"| node_auth
node_login -.->|"authenticates"| node_auth
node_trpc -->|"invokes procedures"| node_apiroot
node_apiroot -->|"uses primitives"| node_trpc
node_authapi -->|"reads subscription"| node_database
node_stripeapi -->|"accesses records"| node_database
node_stripeapi -->|"uses billing"| node_stripe
node_stripeapi -->|"uses plan data"| node_plans
node_webhookroute -->|"verifies event"| node_stripe
node_webhookroute -->|"dispatches event"| node_webhooks
node_webhooks -->|"retrieves subscription"| node_stripe
node_webhooks -->|"updates customer"| node_database
node_clusters -.->|"uses procedures"| node_k8sapi

click node_public "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/page.tsx"
click node_content "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/blog/page.tsx"
click node_pricing "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/pricing/page.tsx"
click node_login "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(auth)/login/page.tsx"
click node_dashboard "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(dashboard)/dashboard/page.tsx"
click node_settings "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(dashboard)/dashboard/settings/page.tsx"
click node_clusters "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(editor)/editor/cluster/%5BclusterId%5D/page.tsx"
click node_admin "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/admin/(dashboard)/dashboard/page.tsx"
click node_auth "https://github.com/nextify-limited/saasfly/blob/main/packages/auth/clerk.ts"
click node_authproxy "https://github.com/nextify-limited/saasfly/blob/main/apps/auth-proxy/routes/%5B...auth%5D.ts"
click node_trpc "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/trpc.ts"
click node_apiroot "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/root.ts"
click node_k8sapi "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/k8s.ts"
click node_customerapi "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/customer.ts"
click node_authapi "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/auth.ts"
click node_database "https://github.com/nextify-limited/saasfly/blob/main/packages/db/index.ts"
click node_stripeapi "https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/stripe.ts"
click node_plans "https://github.com/nextify-limited/saasfly/blob/main/packages/common/src/subscriptions.ts"
click node_stripe "https://github.com/nextify-limited/saasfly/blob/main/packages/stripe/src/index.ts"
click node_webhookroute "https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/api/webhooks/stripe/route.ts"
click node_webhooks "https://github.com/nextify-limited/saasfly/blob/main/packages/stripe/src/webhooks.ts"

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_public,node_content,node_pricing,node_login,node_dashboard,node_settings,node_clusters,node_admin toneBlue
class node_auth,node_authproxy toneAmber
class node_trpc,node_apiroot,node_k8sapi,node_customerapi,node_authapi,node_database toneMint
class node_stripeapi,node_plans,node_stripe,node_webhookroute,node_webhooks toneRose
class node_visitor toneIndigo
```

## Components

### Next.js experience

- [Marketing site](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/page.tsx): `apps/nextjs/src/app/[lang]/(marketing)/page.tsx`
- [Blog and docs](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/blog/page.tsx): `apps/nextjs/src/app/[lang]/(marketing)/blog/page.tsx`
- [Pricing pages](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(marketing)/pricing/page.tsx): `apps/nextjs/src/app/[lang]/(marketing)/pricing/page.tsx`
- [Sign-in pages](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(auth)/login/page.tsx): `apps/nextjs/src/app/[lang]/(auth)/login/page.tsx`
- [Customer dashboard](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(dashboard)/dashboard/page.tsx): `apps/nextjs/src/app/[lang]/(dashboard)/dashboard/page.tsx`
- [Account settings](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(dashboard)/dashboard/settings/page.tsx): `apps/nextjs/src/app/[lang]/(dashboard)/dashboard/settings/page.tsx`
- [Cluster editor](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/%5Blang%5D/(editor)/editor/cluster/%5BclusterId%5D/page.tsx): `apps/nextjs/src/app/[lang]/(editor)/editor/cluster/[clusterId]/page.tsx`
- [Admin dashboard](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/admin/(dashboard)/dashboard/page.tsx): `apps/nextjs/src/app/admin/(dashboard)/dashboard/page.tsx`

### Identity and access

- [Clerk authentication](https://github.com/nextify-limited/saasfly/blob/main/packages/auth/clerk.ts): `packages/auth/clerk.ts`
- [Auth proxy](https://github.com/nextify-limited/saasfly/blob/main/apps/auth-proxy/routes/%5B...auth%5D.ts): `apps/auth-proxy/routes/[...auth].ts`

### API and data

- [tRPC context](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/trpc.ts): `packages/api/src/trpc.ts`
- [API routers](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/root.ts): `packages/api/src/root.ts`
- [Cluster procedures](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/k8s.ts): `packages/api/src/router/k8s.ts`
- [Customer procedures](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/customer.ts): `packages/api/src/router/customer.ts`
- [Subscription query](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/auth.ts): `packages/api/src/router/auth.ts`
- [Application database](https://github.com/nextify-limited/saasfly/blob/main/packages/db/index.ts): `packages/db/index.ts`

### Billing

- [Billing procedures](https://github.com/nextify-limited/saasfly/blob/main/packages/api/src/router/stripe.ts): `packages/api/src/router/stripe.ts`
- [Subscription plans](https://github.com/nextify-limited/saasfly/blob/main/packages/common/src/subscriptions.ts): `packages/common/src/subscriptions.ts`
- [Stripe integration](https://github.com/nextify-limited/saasfly/blob/main/packages/stripe/src/index.ts): `packages/stripe/src/index.ts`
- [Stripe webhook route](https://github.com/nextify-limited/saasfly/blob/main/apps/nextjs/src/app/api/webhooks/stripe/route.ts): `apps/nextjs/src/app/api/webhooks/stripe/route.ts`
- [Webhook processing](https://github.com/nextify-limited/saasfly/blob/main/packages/stripe/src/webhooks.ts): `packages/stripe/src/webhooks.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Marketing site: visits (evidence: `README.md`)
- Visitor → Sign-in pages: signs in (evidence: `README.md`)
- Visitor → Pricing pages: views plans (evidence: `README.md`)
- Visitor → Customer dashboard: uses app
- Customer dashboard → Clerk authentication: uses identity (evidence: `apps/nextjs/src/app/[lang]/(dashboard)/dashboard/page.tsx`)
- Marketing site → Blog and docs: offers content
- Pricing pages → Subscription plans: displays plans
- Auth proxy → Clerk authentication: forwards auth
- Sign-in pages → Clerk authentication: authenticates
- tRPC context → API routers: invokes procedures (evidence: `packages/api/src/root.ts`)
- API routers → tRPC context: uses primitives (evidence: `packages/api/src/root.ts`)
- Subscription query → Application database: reads subscription (evidence: `packages/api/src/router/auth.ts`)
- Billing procedures → Application database: accesses records (evidence: `packages/api/src/router/stripe.ts`)
- Billing procedures → Stripe integration: uses billing (evidence: `packages/api/src/router/stripe.ts`)
- Billing procedures → Subscription plans: uses plan data (evidence: `packages/api/src/router/stripe.ts`)
- Stripe webhook route → Stripe integration: verifies event (evidence: `apps/nextjs/src/app/api/webhooks/stripe/route.ts`)
- Stripe webhook route → Webhook processing: dispatches event (evidence: `apps/nextjs/src/app/api/webhooks/stripe/route.ts`)
- Webhook processing → Stripe integration: retrieves subscription (evidence: `packages/stripe/src/webhooks.ts`)
- Webhook processing → Application database: updates customer (evidence: `packages/stripe/src/webhooks.ts`)
- Cluster editor → Cluster procedures: uses procedures
