# burakorkmez/onlyfans architecture

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

- Interactive diagram: https://gitdiagram.com/burakorkmez/onlyfans
- Repository: https://github.com/burakorkmez/onlyfans

## Overview

##### Main Components

a) Client-Side Layer:
- Next.js Frontend (src/app directory)
- Authentication UI Components
- Home Screen Components
- E-commerce Components
- Admin Dashboard
- Theme Provider
- TanStack Provider

b) Server-Side Layer:
- Next.js API Routes
- Authentication Handlers
- Webhook Handlers
- Server Actions

c) External Services:
- Kinde Auth (Authentication)
- Stripe (Payments)
- Cloudinary (Media Storage)
- Resend (Email Service)
- PostgreSQL Database

**┌─ Client Layer ─────────────────────┐**
- Public Pages                     │
- Protected Pages                  │
- Admin Dashboard                  │
- UI Components                    │
- ┬───────────────────┘
- ↓
**┌─ Application Layer ─────────────────┐**
- Next.js API Routes               │
- Server Actions                   │
- Email Templates                  │
- ┬───────────────────┘
- ↓
**┌─ Data Layer ──────────────────────┐**
- Prisma ORM                      │
- PostgreSQL Database             │
- ┬───────────────────┘
- ↓
**┌─ External Services ────────────────┐**
- Kinde Auth                      │
- Stripe                          │
- Cloudinary                      │
- Resend                          │
- ┘

##### Key Flows to Highlight

a) Authentication Flow:
- User → Kinde Auth → Callback → Protected Routes

b) Payment Flows:
- Subscription: User → Stripe Checkout → Webhook → Database
- One-time Purchase: User → Product Checkout → Webhook → Email

c) Content Management:
- Post Creation → Cloudinary → Database
- Comment/Like System → Database

##### Important Details

- Separation between public and protected routes
- Admin dashboard's special access
- Real-time features and data flow
- Webhook endpoints and their purposes
- Email notification triggers

##### Implementation Notes

- Next.js 14 App Router structure
- Server Components vs Client Components
- API route organization
- Database schema relationships
- External service integration points

Remember to:
- Use consistent styling
- Version numbers for major components
- Notes for important configuration requirements

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        PublicPages["Public Pages"]
        ProtectedPages["Protected Pages"]
        AuthUI["Authentication UI"]:::component
        HomeScreen["Home Screen"]:::component
        AdminDash["Admin Dashboard"]:::component
        ThemeP["Theme Provider"]:::component
        TanStackP["TanStack Provider"]:::component
        ECommerce["E-commerce Components"]:::component
        Profile["User Profile"]:::component
        Analytics["Analytics"]:::component
        Store["Store Management"]:::component
        Content["Content Management"]:::component
    end

    subgraph AppLayer
        API["Next.js API Routes"]
        ServerActions["Server Actions"]
        AuthHandlers["Auth Handlers"]:::component
        WebhookH["Webhook Handlers"]:::component
        EmailTemp["Email Templates"]:::component
        StripeInt["Stripe Integration"]:::component
    end

    subgraph DataLayer
        Prisma["Prisma ORM"]
        DB[(PostgreSQL)]:::component
    end

    subgraph ExternalServices
        KindeAuth["Kinde Auth"]
        Stripe["Stripe"]
        Cloudinary["Cloudinary"]
        Resend["Resend"]
    end

    %% Client Layer Connections
    AuthUI --> AuthHandlers
    HomeScreen --> ServerActions
    AdminDash --> ServerActions
    ECommerce --> StripeInt
    Profile --> ServerActions
    Content --> Cloudinary
    Store --> ServerActions
    Analytics --> ServerActions

    %% App Layer Connections
    AuthHandlers --> KindeAuth
    WebhookH --> Stripe
    EmailTemp --> Resend
    StripeInt --> Stripe
    ServerActions --> Prisma

    %% Data Layer Connections
    Prisma --> DB

    %% External Service Flows
    KindeAuth --> AuthHandlers
    Stripe --> WebhookH
    Cloudinary --> ServerActions
    Resend --> EmailTemp

    %% Styling
    classDef component fill:#f9f,stroke:#333,stroke-width:2px
    classDef external fill:#purple,stroke:#333
    classDef database fill:#yellow,stroke:#333

    %% Click Events
    click AuthUI "https://github.com/burakorkmez/onlyfans/blob/master/src/components/home/auth-screen/AuthScreen.tsx"
    click AuthHandlers "https://github.com/burakorkmez/onlyfans/blob/master/src/app/api/auth/[kindeAuth]/route.ts"
    click HomeScreen "https://github.com/burakorkmez/onlyfans/blob/master/src/components/home/home-screen/HomeScreen.tsx"
    click AdminDash "https://github.com/burakorkmez/onlyfans/blob/master/src/app/secret-dashboard/page.tsx"
    click ThemeP "https://github.com/burakorkmez/onlyfans/blob/master/src/providers/ThemeProvider.tsx"
    click TanStackP "https://github.com/burakorkmez/onlyfans/blob/master/src/providers/TanStackProvider.tsx"
    click StripeInt "https://github.com/burakorkmez/onlyfans/blob/master/src/lib/stripe.ts"
    click WebhookH "https://github.com/burakorkmez/onlyfans/blob/master/src/app/api/webhooks/stripe/route.ts"
    click EmailTemp "https://github.com/burakorkmez/onlyfans/tree/master/src/emails"
    click DB "https://github.com/burakorkmez/onlyfans/blob/master/src/db/prisma.ts"
    click ECommerce "https://github.com/burakorkmez/onlyfans/blob/master/src/app/merch/[id]/ProductCheckout.tsx"
    click Content "https://github.com/burakorkmez/onlyfans/blob/master/src/app/secret-dashboard/content/ContentTab.tsx"
    click Profile "https://github.com/burakorkmez/onlyfans/blob/master/src/app/update-profile/UpdateProfileForm.tsx"
    click Analytics "https://github.com/burakorkmez/onlyfans/blob/master/src/app/secret-dashboard/analytics/AnalyticsTab.tsx"
    click Store "https://github.com/burakorkmez/onlyfans/blob/master/src/app/secret-dashboard/store/StoreTab.tsx"
```
