How webdevsimplified/parity-deals-clone works
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: products.ts Product data service · subscription.ts Subscription service · productViews.ts View analytics service · permissions.ts Plan permissions
Components 27
Merchant experience
- Marketing site
src/app/(marketing)/page.tsx - Sign-in and signup
- Dashboard home
src/app/dashboard/page.tsx - Product management
src/app/dashboard/_components/ProductGrid.tsx - Product configuration
src/app/dashboard/_components/forms - Analytics dashboard
src/app/dashboard/analytics/page.tsx - Analytics charts
src/app/dashboard/_components/charts/ViewsByDayChart.tsx
Visitor banner
- Banner endpoint
src/app/api/products/[productId]/banner/route.ts - Banner renderer
src/components/Banner.tsx
Plans and billing
- Subscription page
src/app/dashboard/subscription/page.tsx - Stripe actions
src/server/actions/stripe.ts - Stripe webhook
src/app/api/webhooks/stripe/route.ts - Clerk webhook
src/app/api/webhooks/clerk/route.ts - Subscription tiers
src/data/subscriptionTiers.ts
Application services
- Product actions
src/server/actions/products.ts - Plan permissions
src/server/permissions.ts
Data and persistence
- Product data service
src/server/db/products.ts - View analytics service
src/server/db/productViews.ts - Subscription service
src/server/db/subscription.ts - User records
src/server/db/users.ts - Postgres database
src/drizzle/db.ts - Domain schema
src/drizzle/schema.ts - Database cache
src/lib/cache.ts
Other components
- Merchant
- Merchant site visitor
- Clerk identity
- Stripe
Connections 46
- Merchant → Marketing site: browses
src/app/(marketing)/page.tsx - Merchant → Sign-in and signup: signs in
- Merchant → Dashboard home: manages
src/app/dashboard/page.tsx - Marketing site → Subscription tiers: shows plans
src/app/(marketing)/page.tsx - Dashboard home → Product data service: loads products
src/app/dashboard/page.tsx - Dashboard home → Product management: renders
src/app/dashboard/page.tsx - Dashboard home → Plan permissions: checks access
src/app/dashboard/page.tsx - Dashboard home → View analytics service: loads views
src/app/dashboard/page.tsx - Product management → Product actions: changes products
- Product management → Product configuration: opens forms
src/app/dashboard/_components/ProductGrid.tsx - Product actions → Product data service: updates products
src/server/actions/products.ts - Product actions → Plan permissions: checks limits
src/server/actions/products.ts - Product actions → Product data service: validates input
src/server/actions/products.ts - Analytics dashboard → View analytics service: queries reports
src/app/dashboard/analytics/page.tsx - Analytics dashboard → Product data service: loads products
src/app/dashboard/analytics/page.tsx - Analytics dashboard → Plan permissions: checks access
src/app/dashboard/analytics/page.tsx - Analytics dashboard → Analytics charts: renders charts
src/app/dashboard/analytics/page.tsx - Analytics charts → View analytics service: displays data
- Subscription page → Stripe actions: starts billing
src/app/dashboard/subscription/page.tsx - Subscription page → Subscription service: reads plan
src/app/dashboard/subscription/page.tsx - Stripe actions → Stripe: manages billing
- Stripe actions → Subscription service: updates plan
src/server/actions/stripe.ts - Stripe webhook → Subscription service: updates subscription
src/app/api/webhooks/stripe/route.ts - Stripe webhook → Subscription tiers: resolves tier
src/app/api/webhooks/stripe/route.ts - Clerk identity → Clerk webhook: sends events
- Clerk webhook → Subscription service: creates subscription
src/app/api/webhooks/clerk/route.ts - Clerk webhook → User records: updates user
src/app/api/webhooks/clerk/route.ts - Subscription tiers → Subscription service: defines tiers
src/server/db/subscription.ts - Merchant site visitor → Banner endpoint: requests banner
- Banner endpoint → Product data service: loads offer
src/app/api/products/[productId]/banner/route.ts - Banner endpoint → Plan permissions: checks eligibility
src/app/api/products/[productId]/banner/route.ts - Banner endpoint → View analytics service: records view
src/app/api/products/[productId]/banner/route.ts - Banner endpoint → Banner renderer: returns banner
src/app/api/products/[productId]/banner/route.ts - Banner renderer → Merchant site visitor: shows offer
- Product data service → Postgres database: reads and writes
src/server/db/products.ts - Product data service → Domain schema: uses tables
src/server/db/products.ts - Product data service → Database cache: caches queries
src/server/db/products.ts - View analytics service → Postgres database: reads and writes
src/server/db/productViews.ts - View analytics service → Domain schema: uses tables
src/server/db/productViews.ts - View analytics service → Database cache: caches queries
src/server/db/productViews.ts - Subscription service → Postgres database: reads and writes
src/server/db/subscription.ts - Subscription service → Domain schema: uses tables
src/server/db/subscription.ts - Subscription service → Database cache: caches queries
src/server/db/subscription.ts - Plan permissions → Product data service: counts products
src/server/permissions.ts - Plan permissions → View analytics service: counts visits
src/server/permissions.ts - Plan permissions → Subscription service: reads tier
src/server/permissions.ts