# webdevsimplified/parity-deals-clone architecture

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

- Interactive diagram: https://gitdiagram.com/webdevsimplified/parity-deals-clone
- Repository: https://github.com/webdevsimplified/parity-deals-clone

## Overview

This is a parity-pricing SaaS: merchants manage products and country-specific discounts, then embed a localized banner that presents purchasing-power offers to visitors. The dashboard also provides view analytics and subscription management. The graph follows the documented/import-indexed routes into database, permission, and payment services; sampled storage code confirms product, view, subscription, and cache responsibilities. Several form, auth, and webhook details are represented at subsystem level because their implementations were not sampled.

Main entry points: [`src/server/db/products.ts`](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/products.ts) (Product data service), [`src/server/db/subscription.ts`](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/subscription.ts) (Subscription service), [`src/server/db/productViews.ts`](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/productViews.ts) (View analytics service), [`src/server/permissions.ts`](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/permissions.ts) (Plan permissions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_merchant["Merchant experience"]
  node_marketing["Marketing site<br/>[page.tsx]"]
  node_auth["Sign-in and signup"]
  node_dashboard["Dashboard home<br/>[page.tsx]"]
  node_product_ui["Product management<br/>[ProductGrid.tsx]"]
  node_product_forms["Product configuration"]
  node_analytics["Analytics dashboard<br/>[page.tsx]"]
  node_charts["Analytics charts"]
end

subgraph group_banner["Visitor banner"]
  node_banner_api["Banner endpoint<br/>[route.ts]"]
  node_banner_render["Banner renderer<br/>[Banner.tsx]"]
end

subgraph group_billing["Plans and billing"]
  node_subscription_ui["Subscription page<br/>[page.tsx]"]
  node_stripe_actions["Stripe actions<br/>[stripe.ts]"]
  node_stripe_webhook["Stripe webhook<br/>[route.ts]"]
  node_clerk_webhook["Clerk webhook<br/>[route.ts]"]
  node_tier_rules["Subscription tiers"]
end

subgraph group_services["Application services"]
  node_product_actions["Product actions<br/>[products.ts]"]
  node_permissions["Plan permissions<br/>[permissions.ts]"]
end

subgraph group_data["Data and persistence"]
  node_products_db["Product data service<br/>[products.ts]"]
  node_views_db["View analytics service<br/>[productViews.ts]"]
  node_subscription_db["Subscription service<br/>[subscription.ts]"]
  node_users_db["User records<br/>[users.ts]"]
  node_database[("Postgres database<br/>[db.ts]")]
  node_schema["Domain schema<br/>[schema.ts]"]
  node_cache["Database cache<br/>[cache.ts]"]
end

node_merchant(("Merchant"))
node_site_visitor(("Merchant site visitor"))
node_clerk{{"Clerk identity"}}
node_stripe{{"Stripe"}}

node_merchant -->|"browses"| node_marketing
node_merchant -.->|"signs in"| node_auth
node_merchant -->|"manages"| node_dashboard
node_marketing -->|"shows plans"| node_tier_rules
node_dashboard -->|"loads products"| node_products_db
node_dashboard -->|"renders"| node_product_ui
node_dashboard -->|"checks access"| node_permissions
node_dashboard -->|"loads views"| node_views_db
node_product_ui -.->|"changes products"| node_product_actions
node_product_ui -->|"opens forms"| node_product_forms
node_product_actions -->|"updates products"| node_products_db
node_product_actions -->|"checks limits"| node_permissions
node_product_actions -->|"validates input"| node_products_db
node_analytics -->|"queries reports"| node_views_db
node_analytics -->|"loads products"| node_products_db
node_analytics -->|"checks access"| node_permissions
node_analytics -->|"renders charts"| node_charts
node_charts -.->|"displays data"| node_views_db
node_subscription_ui -->|"starts billing"| node_stripe_actions
node_subscription_ui -->|"reads plan"| node_subscription_db
node_stripe_actions -.->|"manages billing"| node_stripe
node_stripe_actions -->|"updates plan"| node_subscription_db
node_stripe_webhook -->|"updates subscription"| node_subscription_db
node_stripe_webhook -->|"resolves tier"| node_tier_rules
node_clerk -.->|"sends events"| node_clerk_webhook
node_clerk_webhook -->|"creates subscription"| node_subscription_db
node_clerk_webhook -->|"updates user"| node_users_db
node_tier_rules -->|"defines tiers"| node_subscription_db
node_site_visitor -.->|"requests banner"| node_banner_api
node_banner_api -->|"loads offer"| node_products_db
node_banner_api -->|"checks eligibility"| node_permissions
node_banner_api -->|"records view"| node_views_db
node_banner_api -->|"returns banner"| node_banner_render
node_banner_render -.->|"shows offer"| node_site_visitor
node_products_db -->|"reads and writes"| node_database
node_products_db -->|"uses tables"| node_schema
node_products_db -->|"caches queries"| node_cache
node_views_db -->|"reads and writes"| node_database
node_views_db -->|"uses tables"| node_schema
node_views_db -->|"caches queries"| node_cache
node_subscription_db -->|"reads and writes"| node_database
node_subscription_db -->|"uses tables"| node_schema
node_subscription_db -->|"caches queries"| node_cache
node_permissions -->|"counts products"| node_products_db
node_permissions -->|"counts visits"| node_views_db
node_permissions -->|"reads tier"| node_subscription_db

click node_marketing "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/(marketing)/page.tsx"
click node_dashboard "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/page.tsx"
click node_product_ui "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/_components/ProductGrid.tsx"
click node_product_forms "https://github.com/webdevsimplified/parity-deals-clone/tree/main/src/app/dashboard/_components/forms"
click node_analytics "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/analytics/page.tsx"
click node_charts "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/_components/charts/ViewsByDayChart.tsx"
click node_subscription_ui "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/subscription/page.tsx"
click node_stripe_actions "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/actions/stripe.ts"
click node_stripe_webhook "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/webhooks/stripe/route.ts"
click node_clerk_webhook "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/webhooks/clerk/route.ts"
click node_tier_rules "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/data/subscriptionTiers.ts"
click node_banner_api "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/products/%5BproductId%5D/banner/route.ts"
click node_banner_render "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/components/Banner.tsx"
click node_product_actions "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/actions/products.ts"
click node_permissions "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/permissions.ts"
click node_products_db "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/products.ts"
click node_views_db "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/productViews.ts"
click node_subscription_db "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/subscription.ts"
click node_users_db "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/users.ts"
click node_database "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/drizzle/db.ts"
click node_schema "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/drizzle/schema.ts"
click node_cache "https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/lib/cache.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_marketing,node_auth,node_dashboard,node_product_ui,node_product_forms,node_analytics,node_charts toneBlue
class node_banner_api,node_banner_render toneAmber
class node_subscription_ui,node_stripe_actions,node_stripe_webhook,node_clerk_webhook,node_tier_rules toneMint
class node_product_actions,node_permissions toneRose
class node_products_db,node_views_db,node_subscription_db,node_users_db,node_database,node_schema,node_cache,node_merchant,node_site_visitor,node_clerk,node_stripe toneIndigo
```

## Components

### Merchant experience

- [Marketing site](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/(marketing)/page.tsx): `src/app/(marketing)/page.tsx`
- **Sign-in and signup**
- [Dashboard home](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Product management](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/_components/ProductGrid.tsx): `src/app/dashboard/_components/ProductGrid.tsx`
- [Product configuration](https://github.com/webdevsimplified/parity-deals-clone/tree/main/src/app/dashboard/_components/forms): `src/app/dashboard/_components/forms`
- [Analytics dashboard](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/analytics/page.tsx): `src/app/dashboard/analytics/page.tsx`
- [Analytics charts](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/_components/charts/ViewsByDayChart.tsx): `src/app/dashboard/_components/charts/ViewsByDayChart.tsx`

### Visitor banner

- [Banner endpoint](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/products/%5BproductId%5D/banner/route.ts): `src/app/api/products/[productId]/banner/route.ts`
- [Banner renderer](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/components/Banner.tsx): `src/components/Banner.tsx`

### Plans and billing

- [Subscription page](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/dashboard/subscription/page.tsx): `src/app/dashboard/subscription/page.tsx`
- [Stripe actions](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/actions/stripe.ts): `src/server/actions/stripe.ts`
- [Stripe webhook](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/webhooks/stripe/route.ts): `src/app/api/webhooks/stripe/route.ts`
- [Clerk webhook](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/app/api/webhooks/clerk/route.ts): `src/app/api/webhooks/clerk/route.ts`
- [Subscription tiers](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/data/subscriptionTiers.ts): `src/data/subscriptionTiers.ts`

### Application services

- [Product actions](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/actions/products.ts): `src/server/actions/products.ts`
- [Plan permissions](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/permissions.ts): `src/server/permissions.ts`

### Data and persistence

- [Product data service](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/products.ts): `src/server/db/products.ts`
- [View analytics service](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/productViews.ts): `src/server/db/productViews.ts`
- [Subscription service](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/subscription.ts): `src/server/db/subscription.ts`
- [User records](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/server/db/users.ts): `src/server/db/users.ts`
- [Postgres database](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/drizzle/db.ts): `src/drizzle/db.ts`
- [Domain schema](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/drizzle/schema.ts): `src/drizzle/schema.ts`
- [Database cache](https://github.com/webdevsimplified/parity-deals-clone/blob/main/src/lib/cache.ts): `src/lib/cache.ts`

### Other components

- **Merchant**
- **Merchant site visitor**
- **Clerk identity**
- **Stripe**

## Connections

- Merchant → Marketing site: browses (evidence: `src/app/(marketing)/page.tsx`)
- Merchant → Sign-in and signup: signs in
- Merchant → Dashboard home: manages (evidence: `src/app/dashboard/page.tsx`)
- Marketing site → Subscription tiers: shows plans (evidence: `src/app/(marketing)/page.tsx`)
- Dashboard home → Product data service: loads products (evidence: `src/app/dashboard/page.tsx`)
- Dashboard home → Product management: renders (evidence: `src/app/dashboard/page.tsx`)
- Dashboard home → Plan permissions: checks access (evidence: `src/app/dashboard/page.tsx`)
- Dashboard home → View analytics service: loads views (evidence: `src/app/dashboard/page.tsx`)
- Product management → Product actions: changes products
- Product management → Product configuration: opens forms (evidence: `src/app/dashboard/_components/ProductGrid.tsx`)
- Product actions → Product data service: updates products (evidence: `src/server/actions/products.ts`)
- Product actions → Plan permissions: checks limits (evidence: `src/server/actions/products.ts`)
- Product actions → Product data service: validates input (evidence: `src/server/actions/products.ts`)
- Analytics dashboard → View analytics service: queries reports (evidence: `src/app/dashboard/analytics/page.tsx`)
- Analytics dashboard → Product data service: loads products (evidence: `src/app/dashboard/analytics/page.tsx`)
- Analytics dashboard → Plan permissions: checks access (evidence: `src/app/dashboard/analytics/page.tsx`)
- Analytics dashboard → Analytics charts: renders charts (evidence: `src/app/dashboard/analytics/page.tsx`)
- Analytics charts → View analytics service: displays data
- Subscription page → Stripe actions: starts billing (evidence: `src/app/dashboard/subscription/page.tsx`)
- Subscription page → Subscription service: reads plan (evidence: `src/app/dashboard/subscription/page.tsx`)
- Stripe actions → Stripe: manages billing
- Stripe actions → Subscription service: updates plan (evidence: `src/server/actions/stripe.ts`)
- Stripe webhook → Subscription service: updates subscription (evidence: `src/app/api/webhooks/stripe/route.ts`)
- Stripe webhook → Subscription tiers: resolves tier (evidence: `src/app/api/webhooks/stripe/route.ts`)
- Clerk identity → Clerk webhook: sends events
- Clerk webhook → Subscription service: creates subscription (evidence: `src/app/api/webhooks/clerk/route.ts`)
- Clerk webhook → User records: updates user (evidence: `src/app/api/webhooks/clerk/route.ts`)
- Subscription tiers → Subscription service: defines tiers (evidence: `src/server/db/subscription.ts`)
- Merchant site visitor → Banner endpoint: requests banner
- Banner endpoint → Product data service: loads offer (evidence: `src/app/api/products/[productId]/banner/route.ts`)
- Banner endpoint → Plan permissions: checks eligibility (evidence: `src/app/api/products/[productId]/banner/route.ts`)
- Banner endpoint → View analytics service: records view (evidence: `src/app/api/products/[productId]/banner/route.ts`)
- Banner endpoint → Banner renderer: returns banner (evidence: `src/app/api/products/[productId]/banner/route.ts`)
- Banner renderer → Merchant site visitor: shows offer
- Product data service → Postgres database: reads and writes (evidence: `src/server/db/products.ts`)
- Product data service → Domain schema: uses tables (evidence: `src/server/db/products.ts`)
- Product data service → Database cache: caches queries (evidence: `src/server/db/products.ts`)
- View analytics service → Postgres database: reads and writes (evidence: `src/server/db/productViews.ts`)
- View analytics service → Domain schema: uses tables (evidence: `src/server/db/productViews.ts`)
- View analytics service → Database cache: caches queries (evidence: `src/server/db/productViews.ts`)
- Subscription service → Postgres database: reads and writes (evidence: `src/server/db/subscription.ts`)
- Subscription service → Domain schema: uses tables (evidence: `src/server/db/subscription.ts`)
- Subscription service → Database cache: caches queries (evidence: `src/server/db/subscription.ts`)
- Plan permissions → Product data service: counts products (evidence: `src/server/permissions.ts`)
- Plan permissions → View analytics service: counts visits (evidence: `src/server/permissions.ts`)
- Plan permissions → Subscription service: reads tier (evidence: `src/server/permissions.ts`)
