# allgoz/superwalls architecture

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

- Interactive diagram: https://gitdiagram.com/allgoz/superwalls
- Repository: https://github.com/allgoz/superwalls

## Overview

SuperWalls is a mobile-first online storefront with guest and registered checkout, online payment, customer accounts and a staff CMS. The main purchase path runs from browsing products through cart and checkout to a server-priced, stock-reserved order and payment, followed by order confirmation/tracking. Separate capabilities include editorial content, store administration, media uploads, analytics and external Supabase/Razorpay/R2 services. Edges are limited to README statements and shown source references; unsampled route and UI wiring is not inferred.

Main entry points: [`src/lib/server/checkout.ts`](https://github.com/allgoz/superwalls/blob/main/src/lib/server/checkout.ts) (Order creation), [`src/lib/server/db.ts`](https://github.com/allgoz/superwalls/blob/main/src/lib/server/db.ts) (Database access), [`src/app/api/checkout/route.ts`](https://github.com/allgoz/superwalls/blob/main/src/app/api/checkout/route.ts) (Checkout endpoint), [`src/app/api/payments/verify/route.ts`](https://github.com/allgoz/superwalls/blob/main/src/app/api/payments/verify/route.ts) (Payment endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_storefront["Storefront pages<br/>[page.tsx]"]
  node_cart["Cart<br/>[cart-view.tsx]"]
  node_customer_account["Customer accounts<br/>[auth.ts]"]
end

subgraph group_commerce["Commerce"]
  node_checkout_ui["Checkout flow<br/>[checkout-flow.tsx]"]
  node_checkout_api["Checkout endpoint<br/>[route.ts]"]
  node_checkout_service["Order creation<br/>[checkout.ts]"]
  node_pricing["Pricing rules<br/>[pricing.ts]"]
  node_payments["Payment adapters<br/>[index.ts]"]
  node_payment_routes["Payment endpoints<br/>[route.ts]"]
  node_orders["Order status and tracking<br/>[route.ts]"]
end

subgraph group_admin["Store administration"]
  node_admin_ui["Admin CMS<br/>[page.tsx]"]
  node_admin_client["Admin API client<br/>[client.ts]"]
  node_admin_ops["Admin operations<br/>[index.ts]"]
  node_admin_upload["Image upload endpoint<br/>[route.ts]"]
  node_media_storage["Media storage<br/>[media.ts]"]
end

subgraph group_content["Content and insights"]
  node_cms_blog["CMS pages and blog<br/>[content.ts]"]
  node_analytics["Shop analytics<br/>[analytics.ts]"]
end

subgraph group_platform["Server platform"]
  node_http["HTTP and errors<br/>[http.ts]"]
  node_auth["Server authentication<br/>[auth.ts]"]
  node_db_access["Database access<br/>[db.ts]"]
end

node_shopper(("Shopper"))
node_supabase_auth["Supabase Auth"]
node_database[("Supabase Postgres")]
node_r2[("Cloudflare R2")]
node_gtm["Google Tag Manager"]

node_shopper -->|"browses"| node_storefront
node_shopper -.->|"shops with"| node_cart
node_shopper -->|"checks out"| node_checkout_ui
node_checkout_ui -.->|"submits order"| node_checkout_api
node_checkout_api -->|"delegates to"| node_checkout_service
node_checkout_service -->|"calculates totals"| node_pricing
node_checkout_service -->|"queries"| node_db_access
node_db_access -->|"reads and writes"| node_database
node_checkout_service -->|"opens session"| node_payments
node_shopper -->|"pays online"| node_payment_routes
node_payment_routes -->|"uses adapter"| node_payments
node_payment_routes -->|"records payment"| node_db_access
node_shopper -->|"tracks order"| node_orders
node_customer_account -.->|"authenticates"| node_supabase_auth
node_auth -->|"validates token"| node_supabase_auth
node_admin_ui -.->|"uses mutations"| node_admin_client
node_admin_client -->|"calls operation"| node_admin_ops
node_admin_ui -->|"uploads media"| node_admin_upload
node_admin_upload -->|"stores image"| node_media_storage
node_media_storage -->|"writes objects"| node_r2
node_media_storage -->|"saves public URL"| node_database
node_shopper -->|"reads content"| node_cms_blog
node_storefront -.->|"emits shop events"| node_analytics
node_analytics -->|"pushes data layer"| node_gtm
node_checkout_api -->|"wraps response"| node_http
node_http -->|"rate limits"| node_db_access

click node_storefront "https://github.com/allgoz/superwalls/blob/main/src/app/(flow)/products/%5Bid%5D/page.tsx"
click node_cart "https://github.com/allgoz/superwalls/blob/main/src/components/cart/cart-view.tsx"
click node_checkout_ui "https://github.com/allgoz/superwalls/blob/main/src/components/checkout/checkout-flow.tsx"
click node_checkout_api "https://github.com/allgoz/superwalls/blob/main/src/app/api/checkout/route.ts"
click node_checkout_service "https://github.com/allgoz/superwalls/blob/main/src/lib/server/checkout.ts"
click node_pricing "https://github.com/allgoz/superwalls/blob/main/src/lib/commerce/pricing.ts"
click node_payments "https://github.com/allgoz/superwalls/blob/main/src/lib/server/payments/index.ts"
click node_payment_routes "https://github.com/allgoz/superwalls/blob/main/src/app/api/payments/verify/route.ts"
click node_orders "https://github.com/allgoz/superwalls/blob/main/src/app/api/orders/track/route.ts"
click node_customer_account "https://github.com/allgoz/superwalls/blob/main/src/lib/services/auth.ts"
click node_admin_ui "https://github.com/allgoz/superwalls/blob/main/src/app/admin/(panel)/products/page.tsx"
click node_admin_client "https://github.com/allgoz/superwalls/blob/main/src/lib/admin/client.ts"
click node_admin_ops "https://github.com/allgoz/superwalls/blob/main/src/lib/server/admin/ops/index.ts"
click node_admin_upload "https://github.com/allgoz/superwalls/blob/main/src/app/api/admin/upload/route.ts"
click node_media_storage "https://github.com/allgoz/superwalls/blob/main/src/lib/server/admin/media.ts"
click node_cms_blog "https://github.com/allgoz/superwalls/blob/main/src/lib/server/content.ts"
click node_analytics "https://github.com/allgoz/superwalls/blob/main/src/lib/analytics.ts"
click node_http "https://github.com/allgoz/superwalls/blob/main/src/lib/server/http.ts"
click node_auth "https://github.com/allgoz/superwalls/blob/main/src/lib/server/auth.ts"
click node_db_access "https://github.com/allgoz/superwalls/blob/main/src/lib/server/db.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_storefront,node_cart,node_customer_account toneBlue
class node_checkout_ui,node_checkout_api,node_checkout_service,node_pricing,node_payments,node_payment_routes,node_orders,node_database,node_r2 toneAmber
class node_admin_ui,node_admin_client,node_admin_ops,node_admin_upload,node_media_storage toneMint
class node_cms_blog,node_analytics toneRose
class node_http,node_auth,node_db_access,node_shopper,node_supabase_auth,node_gtm toneIndigo
```

## Components

### Storefront

- [Storefront pages](https://github.com/allgoz/superwalls/blob/main/src/app/(flow)/products/%5Bid%5D/page.tsx): `src/app/(flow)/products/[id]/page.tsx`
- [Cart](https://github.com/allgoz/superwalls/blob/main/src/components/cart/cart-view.tsx): `src/components/cart/cart-view.tsx`
- [Customer accounts](https://github.com/allgoz/superwalls/blob/main/src/lib/services/auth.ts): `src/lib/services/auth.ts`

### Commerce

- [Checkout flow](https://github.com/allgoz/superwalls/blob/main/src/components/checkout/checkout-flow.tsx): `src/components/checkout/checkout-flow.tsx`
- [Checkout endpoint](https://github.com/allgoz/superwalls/blob/main/src/app/api/checkout/route.ts): `src/app/api/checkout/route.ts`
- [Order creation](https://github.com/allgoz/superwalls/blob/main/src/lib/server/checkout.ts): `src/lib/server/checkout.ts`
- [Pricing rules](https://github.com/allgoz/superwalls/blob/main/src/lib/commerce/pricing.ts): `src/lib/commerce/pricing.ts`
- [Payment adapters](https://github.com/allgoz/superwalls/blob/main/src/lib/server/payments/index.ts): `src/lib/server/payments/index.ts`
- [Payment endpoints](https://github.com/allgoz/superwalls/blob/main/src/app/api/payments/verify/route.ts): `src/app/api/payments/verify/route.ts`
- [Order status and tracking](https://github.com/allgoz/superwalls/blob/main/src/app/api/orders/track/route.ts): `src/app/api/orders/track/route.ts`

### Store administration

- [Admin CMS](https://github.com/allgoz/superwalls/blob/main/src/app/admin/(panel)/products/page.tsx): `src/app/admin/(panel)/products/page.tsx`
- [Admin API client](https://github.com/allgoz/superwalls/blob/main/src/lib/admin/client.ts): `src/lib/admin/client.ts`
- [Admin operations](https://github.com/allgoz/superwalls/blob/main/src/lib/server/admin/ops/index.ts): `src/lib/server/admin/ops/index.ts`
- [Image upload endpoint](https://github.com/allgoz/superwalls/blob/main/src/app/api/admin/upload/route.ts): `src/app/api/admin/upload/route.ts`
- [Media storage](https://github.com/allgoz/superwalls/blob/main/src/lib/server/admin/media.ts): `src/lib/server/admin/media.ts`

### Content and insights

- [CMS pages and blog](https://github.com/allgoz/superwalls/blob/main/src/lib/server/content.ts): `src/lib/server/content.ts`
- [Shop analytics](https://github.com/allgoz/superwalls/blob/main/src/lib/analytics.ts): `src/lib/analytics.ts`

### Server platform

- [HTTP and errors](https://github.com/allgoz/superwalls/blob/main/src/lib/server/http.ts): `src/lib/server/http.ts`
- [Server authentication](https://github.com/allgoz/superwalls/blob/main/src/lib/server/auth.ts): `src/lib/server/auth.ts`
- [Database access](https://github.com/allgoz/superwalls/blob/main/src/lib/server/db.ts): `src/lib/server/db.ts`

### Other components

- **Shopper**
- **Supabase Auth**
- **Supabase Postgres**
- **Cloudflare R2**
- **Google Tag Manager**

## Connections

- Shopper → Storefront pages: browses (evidence: `README.md`)
- Shopper → Cart: shops with
- Shopper → Checkout flow: checks out (evidence: `README.md`)
- Checkout flow → Checkout endpoint: submits order
- Checkout endpoint → Order creation: delegates to (evidence: `src/app/api/checkout/route.ts`)
- Order creation → Pricing rules: calculates totals (evidence: `src/lib/server/checkout.ts`)
- Order creation → Database access: queries (evidence: `src/lib/server/checkout.ts`)
- Database access → Supabase Postgres: reads and writes (evidence: `README.md`)
- Order creation → Payment adapters: opens session (evidence: `src/lib/server/checkout.ts`)
- Shopper → Payment endpoints: pays online (evidence: `README.md`)
- Payment endpoints → Payment adapters: uses adapter (evidence: `src/app/api/payments/verify/route.ts`)
- Payment endpoints → Database access: records payment
- Shopper → Order status and tracking: tracks order (evidence: `README.md`)
- Customer accounts → Supabase Auth: authenticates
- Server authentication → Supabase Auth: validates token (evidence: `src/lib/server/auth.ts`)
- Admin CMS → Admin API client: uses mutations
- Admin API client → Admin operations: calls operation (evidence: `src/lib/admin/client.ts`)
- Admin CMS → Image upload endpoint: uploads media (evidence: `README.md`)
- Image upload endpoint → Media storage: stores image (evidence: `src/app/api/admin/upload/route.ts`)
- Media storage → Cloudflare R2: writes objects (evidence: `README.md`)
- Media storage → Supabase Postgres: saves public URL (evidence: `README.md`)
- Shopper → CMS pages and blog: reads content (evidence: `README.md`)
- Storefront pages → Shop analytics: emits shop events
- Shop analytics → Google Tag Manager: pushes data layer (evidence: `README.md`)
- Checkout endpoint → HTTP and errors: wraps response (evidence: `src/app/api/checkout/route.ts`)
- HTTP and errors → Database access: rate limits (evidence: `src/lib/server/http.ts`)
