# sadmann7/skateshop architecture

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

- Interactive diagram: https://gitdiagram.com/sadmann7/skateshop
- Repository: https://github.com/sadmann7/skateshop

## Overview

##### Main System Components

a) Frontend Layer
- Next.js 14 App Router Structure
- Lobby Section (public-facing storefront)
- Dashboard Section (seller/admin interface)
- Auth Section (authentication flows)
- Checkout Section (cart and payment flows)

b) API Layer
- API Routes (/api)
- Webhook handlers
- Email services
- Image generation (OG)
- File upload endpoints

c) Database Layer
- Drizzle ORM
- PlanetScale Database
- Schema relationships for:
- Products
- Orders
- Customers
- Stores
- Carts
- Categories

d) External Services
- Clerk (Authentication)
- Stripe (Payments)
- uploadthing (File Storage)
- Resend (Email)
- Contentlayer (Content Management)

##### Component Relationships

a) Client-Server Flow
- Frontend components → API Routes → Database
- Authentication flow through Clerk
- Payment flow through Stripe
- File upload flow through uploadthing

b) Data Flow
- Product management flow
- Order processing flow
- Cart management flow
- Content delivery flow

##### Specific Implementation Details

a) Next.js App Router Structure (Blue)
- Route groups: (auth), (dashboard), (checkout), (lobby)
- Dynamic routes with parameters
- API routes structure

b) Database Schema (Green)
- Main tables and their relationships
- Fields and foreign keys
- Indexes and constraints

c) External Services Integration (Orange)
- Auth flows with Clerk
- Payment processing with Stripe
- File storage with uploadthing
- Email handling with Resend

##### Architectural Patterns

Following patterns:

- Next.js App Router architecture
- Server-side rendering strategy
- API route organization
- Database schema design
- Content management workflow
- Authentication flow
- Payment processing flow

##### Implementation Notes

Notes regarding:

- Environment variables and configuration
- Development vs. production considerations
- Security implementations
- Performance optimizations
- Scaling considerations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        Lobby["Lobby Section"]
        Dashboard["Dashboard Section"]
        Auth["Auth Section"]
        Checkout["Checkout Section"]
        UIComponents["UI Components"]
        LayoutComponents["Layout Components"]
        CheckoutComponents["Checkout Components"]
        DataTables["Data Tables"]
    end

    subgraph APILayer
        WebhookHandlers["Webhook Handlers"]
        EmailServices["Email Services"]
        ImageGen["Image Generation"]
        FileUpload["File Upload"]
    end

    subgraph DatabaseLayer
        DrizzleORM["Drizzle ORM"]
        PlanetScale[(PlanetScale DB)]
        Schema["Schema Definitions"]
        Migrations["Database Migrations"]
    end

    subgraph ExternalServices
        Clerk["Clerk Auth"]
        Stripe["Stripe Payments"]
        Uploadthing["Uploadthing Storage"]
        Resend["Resend Email"]
        Contentlayer["Contentlayer CMS"]
    end

    subgraph BusinessLogic
        Actions["Actions"]
        Queries["Queries"]
        Validations["Validations"]
    end

    subgraph Content
        Blog["Blog Content"]
        Pages["Pages Content"]
        Authors["Authors Content"]
    end

    %% Relationships
    Lobby --> APILayer
    Dashboard --> APILayer
    Auth --> APILayer
    Checkout --> APILayer
    APILayer --> BusinessLogic
    BusinessLogic --> DatabaseLayer
    DatabaseLayer --> PlanetScale
    APILayer --> ExternalServices
    Content --> Contentlayer
    
    %% Click events
    click Lobby "https://github.com/sadmann7/skateshop/tree/main/src/app/(lobby)"
    click Dashboard "https://github.com/sadmann7/skateshop/tree/main/src/app/(dashboard)"
    click Auth "https://github.com/sadmann7/skateshop/tree/main/src/app/(auth)"
    click Checkout "https://github.com/sadmann7/skateshop/tree/main/src/app/(checkout)"
    click WebhookHandlers "https://github.com/sadmann7/skateshop/tree/main/src/app/api/webhooks"
    click EmailServices "https://github.com/sadmann7/skateshop/tree/main/src/app/api/email"
    click ImageGen "https://github.com/sadmann7/skateshop/tree/main/src/app/api/og"
    click FileUpload "https://github.com/sadmann7/skateshop/tree/main/src/app/api/uploadthing"
    click DrizzleORM "https://github.com/sadmann7/skateshop/blob/main/drizzle.config.ts"
    click Schema "https://github.com/sadmann7/skateshop/tree/main/src/db/schema"
    click Migrations "https://github.com/sadmann7/skateshop/blob/main/src/db/migrate.ts"
    click UIComponents "https://github.com/sadmann7/skateshop/tree/main/src/components/ui"
    click LayoutComponents "https://github.com/sadmann7/skateshop/tree/main/src/components/layouts"
    click CheckoutComponents "https://github.com/sadmann7/skateshop/tree/main/src/components/checkout"
    click DataTables "https://github.com/sadmann7/skateshop/tree/main/src/components/data-table"
    click Actions "https://github.com/sadmann7/skateshop/tree/main/src/lib/actions"
    click Queries "https://github.com/sadmann7/skateshop/tree/main/src/lib/queries"
    click Validations "https://github.com/sadmann7/skateshop/tree/main/src/lib/validations"
    click Blog "https://github.com/sadmann7/skateshop/tree/main/src/content/blog"
    click Pages "https://github.com/sadmann7/skateshop/tree/main/src/content/pages"
    click Authors "https://github.com/sadmann7/skateshop/tree/main/src/content/authors"
    click Stripe "https://github.com/sadmann7/skateshop/blob/main/src/lib/stripe.ts"
    click Uploadthing "https://github.com/sadmann7/skateshop/blob/main/src/lib/uploadthing.ts"
    click Resend "https://github.com/sadmann7/skateshop/blob/main/src/lib/resend.ts"
    click Contentlayer "https://github.com/sadmann7/skateshop/blob/main/contentlayer.config.ts"

    classDef frontend fill:#2563eb,color:white
    classDef api fill:#dc2626,color:white
    classDef database fill:#16a34a,color:white
    classDef external fill:#ea580c,color:white
    classDef business fill:#6d28d9,color:white
    classDef content fill:#db2777,color:white

    class Lobby,Dashboard,Auth,Checkout,UIComponents,LayoutComponents,CheckoutComponents,DataTables frontend
    class WebhookHandlers,EmailServices,ImageGen,FileUpload api
    class DrizzleORM,PlanetScale,Schema,Migrations database
    class Clerk,Stripe,Uploadthing,Resend,Contentlayer external
    class Actions,Queries,Validations business
    class Blog,Pages,Authors content
```
