# joschan21/casecobra architecture

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

- Interactive diagram: https://gitdiagram.com/joschan21/casecobra
- Repository: https://github.com/joschan21/casecobra

## Overview

##### Main System Components

A. Client Layer
- Next.js 14 Frontend (src/app directory)
- UI Components (src/components)
- Phone Case Configurator (src/app/configure)

B. API Layer
- Authentication endpoints (src/app/api/auth)
- File upload handling (src/app/api/uploadthing)
- Webhook handlers (src/app/api/webhooks)

C. Service Layer
- Authentication (Kinde Auth)
- File Storage (UploadThing)
- Payment Processing (Stripe)
- Email Service (for thank-you emails)

D. Data Layer
- PostgreSQL Database (via Prisma ORM)

##### Component Relationships

a) User Flow Path:
**Landing Page → Authentication → Configurator → Checkout → Thank You Page**

b) Data Flow Paths:
**Client → API Routes → Services → Database**

##### Specific Implementation Details

Key architectural elements:

A. Frontend Architecture:
- Next.js app router structure
- Configurator components:
- Design
- Preview
- Upload
- Dashboard for order management
- UI component library (shadcn-ui)

B. Backend Services:
- Prisma ORM connection
- Kinde Auth integration
- Stripe payment processing
- UploadThing file handling

##### Important Flows to Highlight

- Authentication flow
- Phone case configuration process
- Order processing
- Admin dashboard access
- File upload handling
- Payment processing
- Email notification system

##### Technical Stack Callouts

- Next.js 14
- TypeScript
- Tailwind CSS
- PostgreSQL
- Prisma ORM
- Kinde Auth
- Stripe
- UploadThing

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        LP["Landing Page"]:::frontend
        CONF["Phone Case Configurator"]:::frontend
        DASH["Dashboard"]:::frontend
        UI["UI Components"]:::frontend
        
        subgraph Configurator["Configurator Components"]
            direction TB
            DES["Design Module"]:::frontend
            PREV["Preview Module"]:::frontend
            UPL["Upload Module"]:::frontend
        end
    end

    subgraph API["API Layer"]
        direction TB
        AUTH_API["Authentication API"]:::api
        UPLOAD_API["File Upload API"]:::api
        WEBHOOK["Webhook Handler"]:::api
    end

    subgraph Services["Service Layer"]
        direction TB
        KINDE["Kinde Auth"]:::service
        UPLOADTHING["UploadThing"]:::service
        STRIPE["Stripe Payment"]:::service
        EMAIL["Email Service"]:::service
    end

    subgraph Data["Data Layer"]
        direction TB
        DB[(PostgreSQL)]:::database
        PRISMA["Prisma ORM"]:::database
    end

    %% Relationships
    LP --> CONF
    CONF --> DASH
    Configurator --> UI
    
    Client --> API
    API --> Services
    Services --> Data
    PRISMA --> DB

    %% Click Events
    click LP "https://github.com/joschan21/casecobra/blob/master/src/app/page.tsx"
    click DASH "https://github.com/joschan21/casecobra/blob/master/src/app/dashboard/page.tsx"
    click DES "https://github.com/joschan21/casecobra/blob/master/src/app/configure/design/DesignConfigurator.tsx"
    click PREV "https://github.com/joschan21/casecobra/blob/master/src/app/configure/preview/DesignPreview.tsx"
    click UPL "https://github.com/joschan21/casecobra/blob/master/src/app/configure/upload/page.tsx"
    click AUTH_API "https://github.com/joschan21/casecobra/blob/master/src/app/api/auth/[kindeAuth]/route.ts"
    click UPLOAD_API "https://github.com/joschan21/casecobra/blob/master/src/app/api/uploadthing/route.ts"
    click WEBHOOK "https://github.com/joschan21/casecobra/blob/master/src/app/api/webhooks/route.ts"
    click PRISMA "https://github.com/joschan21/casecobra/blob/master/prisma/schema.prisma"
    click UI "https://github.com/joschan21/casecobra/tree/master/src/components"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef service fill:#eab308,color:white
    classDef database fill:#a855f7,color:white

    %% Legend
    subgraph Legend
        direction TB
        F["Frontend"]:::frontend
        A["API"]:::api
        S["Service"]:::service
        D["Database"]:::database
    end
```
