# constilcompany/constil-marketing-portal architecture

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

- Interactive diagram: https://gitdiagram.com/constilcompany/constil-marketing-portal
- Repository: https://github.com/constilcompany/constil-marketing-portal

## Overview

Paybue Viral Growth is a role-based administration and subscription-management dashboard backed by Supabase. Users authenticate, enter protected dashboard workflows, and manage growth operations such as managers, influencers, coupons, payouts, analytics, and customer subscriptions. The README also documents the package-pricing, trial, coupon, Stripe checkout, and payment-verification journey for a separate user panel. Evidence is limited to the README and sampled source/index references; unsampled feature implementations and their internal calls are not asserted.

Main entry points: [`src/App.tsx`](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/App.tsx) (Dashboard application), [`supabase/functions/user-api/index.ts`](https://github.com/constilcompany/constil-marketing-portal/blob/main/supabase/functions/user-api/index.ts) (Subscription REST API), [`src/contexts/AuthContext.tsx`](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/contexts/AuthContext.tsx) (Authentication and roles), [`src/pages/MockCheckoutPage.tsx`](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/MockCheckoutPage.tsx) (Checkout and payment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_app["Dashboard application<br/>[App.tsx]"]
  node_auth["Authentication and roles<br/>[AuthContext.tsx]"]
  node_layout["Role-based navigation"]
end

subgraph group_growth["Growth operations"]
  node_manager_admin["Manager administration<br/>[ManagersPage.tsx]"]
  node_influencer_admin["Influencer management"]
  node_coupons["Coupon management<br/>[CouponsPage.tsx]"]
  node_analytics["Analytics<br/>[AnalyticsPage.tsx]"]
  node_wallet["Wallet and ledger<br/>[WalletPage.tsx]"]
  node_dashboard_stats["Dashboard statistics"]
end

subgraph group_billing["Subscriptions and billing"]
  node_package_admin["Package administration"]
  node_credit_config["Credit configuration"]
  node_pricing["Plan pricing<br/>[PricingPage.tsx]"]
  node_checkout["Checkout and payment"]
  node_payment_success["Payment confirmation"]
  node_subscription_admin["Subscription management"]
  node_my_subscription["Customer subscription"]
end

subgraph group_services["Backend services"]
  node_supabase_client["Supabase client<br/>[client.ts]"]
  node_supabase_data[("Supabase data and auth<br/>[types.ts]")]
  node_user_api["Subscription REST API<br/>[index.ts]"]
end

node_staff(("Staff user"))
node_stripe["Stripe"]

node_staff -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"routes to"| node_manager_admin
node_app -->|"routes to"| node_coupons
node_app -->|"routes to"| node_influencer_admin
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_wallet
node_app -->|"routes to"| node_package_admin
node_app -->|"routes to"| node_credit_config
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_payment_success
node_app -->|"routes to"| node_subscription_admin
node_app -->|"routes to"| node_my_subscription
node_auth -->|"authenticates via"| node_supabase_client
node_auth -->|"reads and writes"| node_supabase_data
node_dashboard_stats -->|"queries"| node_supabase_client
node_package_admin -.->|"manages packages"| node_user_api
node_pricing -->|"fetches plans"| node_user_api
node_pricing -->|"starts checkout"| node_checkout
node_checkout -->|"creates session"| node_stripe
node_stripe -->|"redirects after payment"| node_payment_success
node_payment_success -->|"verifies payment"| node_user_api
node_my_subscription -->|"checks subscription"| node_user_api

click node_app "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/App.tsx"
click node_auth "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/contexts/AuthContext.tsx"
click node_layout "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/components/DashboardLayout.tsx"
click node_manager_admin "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/ManagersPage.tsx"
click node_influencer_admin "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/InfluencersPage.tsx"
click node_coupons "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CouponsPage.tsx"
click node_analytics "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/AnalyticsPage.tsx"
click node_wallet "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/WalletPage.tsx"
click node_dashboard_stats "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/hooks/use-query-helpers.ts"
click node_package_admin "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CreditPackagesPage.tsx"
click node_credit_config "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CreditConfigPage.tsx"
click node_pricing "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/PricingPage.tsx"
click node_checkout "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/MockCheckoutPage.tsx"
click node_payment_success "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/PaymentSuccessPage.tsx"
click node_subscription_admin "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/SubscriptionsPage.tsx"
click node_my_subscription "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/MySubscriptionPage.tsx"
click node_supabase_client "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/integrations/supabase/client.ts"
click node_supabase_data "https://github.com/constilcompany/constil-marketing-portal/blob/main/src/integrations/supabase/types.ts"
click node_user_api "https://github.com/constilcompany/constil-marketing-portal/blob/main/supabase/functions/user-api/index.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_app,node_auth,node_layout,node_staff toneBlue
class node_manager_admin,node_influencer_admin,node_coupons,node_analytics,node_wallet,node_dashboard_stats toneAmber
class node_package_admin,node_credit_config,node_pricing,node_checkout,node_payment_success,node_subscription_admin,node_my_subscription toneMint
class node_supabase_client,node_supabase_data,node_user_api toneRose
class node_stripe toneIndigo
```

## Components

### Access and navigation

- [Dashboard application](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication and roles](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Role-based navigation](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/components/DashboardLayout.tsx): `src/components/DashboardLayout.tsx`

### Growth operations

- [Manager administration](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/ManagersPage.tsx): `src/pages/ManagersPage.tsx`
- [Influencer management](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/InfluencersPage.tsx): `src/pages/InfluencersPage.tsx`
- [Coupon management](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CouponsPage.tsx): `src/pages/CouponsPage.tsx`
- [Analytics](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/AnalyticsPage.tsx): `src/pages/AnalyticsPage.tsx`
- [Wallet and ledger](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/WalletPage.tsx): `src/pages/WalletPage.tsx`
- [Dashboard statistics](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/hooks/use-query-helpers.ts): `src/hooks/use-query-helpers.ts`

### Subscriptions and billing

- [Package administration](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CreditPackagesPage.tsx): `src/pages/CreditPackagesPage.tsx`
- [Credit configuration](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/CreditConfigPage.tsx): `src/pages/CreditConfigPage.tsx`
- [Plan pricing](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/PricingPage.tsx): `src/pages/PricingPage.tsx`
- [Checkout and payment](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/MockCheckoutPage.tsx): `src/pages/MockCheckoutPage.tsx`
- [Payment confirmation](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/PaymentSuccessPage.tsx): `src/pages/PaymentSuccessPage.tsx`
- [Subscription management](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/SubscriptionsPage.tsx): `src/pages/SubscriptionsPage.tsx`
- [Customer subscription](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/pages/MySubscriptionPage.tsx): `src/pages/MySubscriptionPage.tsx`

### Backend services

- [Supabase client](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Supabase data and auth](https://github.com/constilcompany/constil-marketing-portal/blob/main/src/integrations/supabase/types.ts): `src/integrations/supabase/types.ts`
- [Subscription REST API](https://github.com/constilcompany/constil-marketing-portal/blob/main/supabase/functions/user-api/index.ts): `supabase/functions/user-api/index.ts`

### Other components

- **Staff user**
- **Stripe**

## Connections

- Staff user → Dashboard application: uses (evidence: `src/App.tsx`)
- Dashboard application → Authentication and roles: provides auth (evidence: `src/App.tsx`)
- Dashboard application → Manager administration: routes to (evidence: `src/App.tsx`)
- Dashboard application → Coupon management: routes to (evidence: `src/App.tsx`)
- Dashboard application → Influencer management: routes to (evidence: `src/App.tsx`)
- Dashboard application → Analytics: routes to (evidence: `src/App.tsx`)
- Dashboard application → Wallet and ledger: routes to (evidence: `src/App.tsx`)
- Dashboard application → Package administration: routes to (evidence: `src/App.tsx`)
- Dashboard application → Credit configuration: routes to (evidence: `src/App.tsx`)
- Dashboard application → Checkout and payment: routes to (evidence: `src/App.tsx`)
- Dashboard application → Payment confirmation: routes to (evidence: `src/App.tsx`)
- Dashboard application → Subscription management: routes to (evidence: `src/App.tsx`)
- Dashboard application → Customer subscription: routes to (evidence: `src/App.tsx`)
- Authentication and roles → Supabase client: authenticates via (evidence: `src/contexts/AuthContext.tsx`)
- Authentication and roles → Supabase data and auth: reads and writes (evidence: `src/contexts/AuthContext.tsx`)
- Dashboard statistics → Supabase client: queries (evidence: `src/hooks/use-query-helpers.ts`)
- Package administration → Subscription REST API: manages packages
- Plan pricing → Subscription REST API: fetches plans
- Plan pricing → Checkout and payment: starts checkout
- Checkout and payment → Stripe: creates session
- Stripe → Payment confirmation: redirects after payment
- Payment confirmation → Subscription REST API: verifies payment
- Customer subscription → Subscription REST API: checks subscription
