# pranjalpruthi/pdsr architecture

> Architecture diagram of the GitHub repository pranjalpruthi/pdsr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranjalpruthi/pdsr
- Repository: https://github.com/pranjalpruthi/pdsr

## Overview

##### Main Components

A. Frontend Layer:
- Client-Side Components (React/Next.js)
- Public Pages (/, /sign-in, /sign-up)
- Protected Dashboard (/dashboard/*)
- Auth Components
- UI Components Library
- Payment Flow Pages (success/cancel)

B. Backend Layer:
- API Routes
- Auth Webhook Handler
- Payment Routes
- Protected API Endpoints

C. External Services:
- Clerk (Authentication)
- Stripe (Payments)
- Supabase (Database)
- Prisma (ORM)

**[Client Layer]**
- ↕
**[Server Layer]**
- ↕
**[External Services]**

##### Detailed Component Relationships

Frontend → Backend:
- API route connections
- Protected routes with auth middleware
- Form submissions and data fetching paths

Backend → External Services:
- Auth verification flows with Clerk
- Payment processing with Stripe
- Database operations through Prisma to Supabase

##### Implementation Details

**[📱] Frontend Components**
**[🔒] Auth Protected Routes**
**[⚡] API Endpoints**
**[💾] Database**
**[🔌] External Services**
**[🔄] Middleware**

##### Key Relationships to Highlight

- Auth flow: Client → Clerk → Middleware → Protected Routes
- Payment flow: Client → Stripe → Webhook → Database
- Data flow: Client → API Routes → Prisma → Supabase

##### Additional Elements

- Error handling paths
- Rate limiting implementation
- Environment variable dependencies
- Webhook processing flows

- Security boundaries
- Data flow directions
- Service interactions
- State management
- Cache layers (if any)
- API boundaries

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        PublicPages["Public Pages"]
        AuthPages["Auth Pages"]:::auth
        DashboardPages["Dashboard Pages"]:::dashboard
        PaymentPages["Payment Pages"]:::payment
        UIComponents["UI Components"]:::ui
    end

    subgraph Server
        APIRoutes["API Routes"]
        AuthWebhook["Auth Webhook"]:::auth
        PaymentWebhook["Payment Webhook"]:::payment
        RateLimiter["Rate Limiter"]:::security
        AuthMiddleware["Auth Middleware"]:::security
    end

    subgraph External
        Clerk["Clerk Auth"]:::external
        Stripe["Stripe Payments"]:::external
        Supabase["Supabase DB"]:::external
        Prisma["Prisma ORM"]:::external
    end

    %% Relationships
    PublicPages --> APIRoutes
    AuthPages --> Clerk
    DashboardPages --> APIRoutes
    PaymentPages --> Stripe
    
    APIRoutes --> AuthMiddleware
    AuthMiddleware --> RateLimiter
    RateLimiter --> Prisma
    
    AuthWebhook --> Clerk
    PaymentWebhook --> Stripe
    
    Prisma --> Supabase

    %% Click Events
    click AuthPages "https://github.com/pranjalpruthi/pdsr/tree/main/app/(auth)"
    click DashboardPages "https://github.com/pranjalpruthi/pdsr/tree/main/app/dashboard"
    click PaymentPages "https://github.com/pranjalpruthi/pdsr/blob/main/app/success/page.tsx"
    click UIComponents "https://github.com/pranjalpruthi/pdsr/tree/main/components/ui"
    click AuthWebhook "https://github.com/pranjalpruthi/pdsr/blob/main/app/api/auth/webhook/route.ts"
    click PaymentWebhook "https://github.com/pranjalpruthi/pdsr/blob/main/app/api/payments/webhook/route.ts"
    click RateLimiter "https://github.com/pranjalpruthi/pdsr/blob/main/lib/ratelimiter.ts"
    click AuthMiddleware "https://github.com/pranjalpruthi/pdsr/blob/main/middleware.ts"
    click Prisma "https://github.com/pranjalpruthi/pdsr/blob/main/prisma/schema.prisma"

    %% Styling
    classDef auth fill:#f9f,stroke:#333
    classDef dashboard fill:#9cf,stroke:#333
    classDef payment fill:#fc9,stroke:#333
    classDef security fill:#f99,stroke:#333
    classDef external fill:#ccc,stroke:#333
    classDef ui fill:#9fc,stroke:#333

    %% Legend
    subgraph Legend
        L1["Authentication"]:::auth
        L2["Dashboard"]:::dashboard
        L3["Payment"]:::payment
        L4["Security"]:::security
        L5["External Services"]:::external
        L6["UI Components"]:::ui
    end
```
