# tirthpshah/pexl architecture

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

- Interactive diagram: https://gitdiagram.com/tirthpshah/pexl
- Repository: https://github.com/tirthpshah/pexl

## Overview

##### Project type and purpose
- This is a full-stack Next.js (React) web application, bootstrapped with create-next-app.
- It provides a user-authenticated dashboard for file uploads/management, order processing (including payments), and shop listings.

##### File structure
- Top-level folders:
- src/app – Next.js “app router” directory containing:
– api – serverless route handlers for auth, payments, files, orders, shops, uploads, user roles.
– page.tsx, layout.tsx, metadata.ts, CSS – client-side pages and global styling.
- src/components – React UI components (NavBar, PaymentForm, dashboard items, etc.).
- src/lib – shared logic: MongoDB connection, auth options, utility functions, custom hooks.
- src/types – TypeScript definitions.
- Configuration files: next.config.js/ts, tsconfig.json, ESLint, PostCSS.
- package.json, lockfile, CI/CD implied by Vercel deployment.

##### README
- Confirms Next.js app, dev scripts, default routing model, Vercel deployment recommendation.

- Orange for external services
- Gray for database/storage
- Related API routes in a single “API Layer” container, subdivided by domain.

##### Detail level
- Essential routes (auth, files, orders, shops, upload, user-role).
- Interaction patterns (e.g., User → SignIn → NextAuth → DB).
- That static assets (public folder) are served via CDN, not hitting the API layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Web Browser"]:::client

    subgraph "Frontend (Next.js App Router)"
        direction TB
        NextApp["Next.js Frontend"]:::frontend
        Home["Home Page"]:::frontend
        Layout["Layout & Metadata"]:::frontend
        SignIn["Sign-in Page"]:::frontend
        Checkout["Checkout Page"]:::frontend
        Confirmation["Order Confirmation Page"]:::frontend
        Instructions["Instructions Page"]:::frontend
        Stationery["Stationery Page"]:::frontend
        NextApp --> Home
        NextApp --> Layout
        NextApp --> SignIn
        NextApp --> Checkout
        NextApp --> Confirmation
        NextApp --> Instructions
        NextApp --> Stationery
    end

    subgraph "API Layer (src/app/api)"
        direction TB
        Auth["Auth Service"]:::backend
        Payment["Payment Service"]:::backend
        File["File Service"]:::backend
        Upload["Upload Service"]:::backend
        Order["Order Service"]:::backend
        Shop["Shop Service"]:::backend
        UserRole["UserRole Service"]:::backend
    end

    subgraph "Shared Library (src/lib)"
        direction TB
        AuthLib["Auth & Session Library"]:::lib
        DBConn["Database Connection"]:::lib
        Utils["Utilities & Business Logic"]:::lib
        Hooks["Custom Hooks"]:::lib
    end

    DB["MongoDB"]:::db
    Stripe["Stripe"]:::external
    FileStorage["File Storage"]:::external
    CDN["Static Assets CDN"]:::cdn

    Browser --> NextApp
    Browser --> CDN
    NextApp --> Auth
    NextApp --> Payment
    NextApp --> File
    NextApp --> Upload
    NextApp --> Order
    NextApp --> Shop
    NextApp --> UserRole

    Auth --> AuthLib
    Payment --> Utils
    File --> DBConn
    Upload --> DBConn
    Order --> Utils
    Shop --> DBConn
    UserRole --> DBConn

    DBConn --> DB
    AuthLib --> DB
    Order --> DB
    File --> DB
    Shop --> DB
    UserRole --> DB

    Payment --> Stripe
    File --> FileStorage
    Upload --> FileStorage

    click NextApp "https://github.com/tirthpshah/pexl/tree/main/src/app"
    click Layout "https://github.com/tirthpshah/pexl/blob/main/src/app/layout.tsx"
    click Home "https://github.com/tirthpshah/pexl/blob/main/src/app/page.tsx"
    click SignIn "https://github.com/tirthpshah/pexl/blob/main/src/app/auth/signin/page.tsx"
    click Checkout "https://github.com/tirthpshah/pexl/blob/main/src/app/checkout/page.tsx"
    click Confirmation "https://github.com/tirthpshah/pexl/blob/main/src/app/confirmation/page.tsx"
    click Instructions "https://github.com/tirthpshah/pexl/blob/main/src/app/instructions/page.tsx"
    click Stationery "https://github.com/tirthpshah/pexl/blob/main/src/app/stationary/page.tsx"
    click CDN "https://github.com/tirthpshah/pexl/tree/main/public/"
    click Auth "https://github.com/tirthpshah/pexl/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click Payment "https://github.com/tirthpshah/pexl/blob/main/src/app/api/create-payment-intent/route.ts"
    click File "https://github.com/tirthpshah/pexl/blob/main/src/app/api/files/route.ts"
    click Upload "https://github.com/tirthpshah/pexl/blob/main/src/app/api/upload/route.ts"
    click Order "https://github.com/tirthpshah/pexl/blob/main/src/app/api/orders/route.ts"
    click Shop "https://github.com/tirthpshah/pexl/blob/main/src/app/api/shops/route.ts"
    click UserRole "https://github.com/tirthpshah/pexl/blob/main/src/app/api/user-role/route.ts"
    click AuthLib "https://github.com/tirthpshah/pexl/blob/main/src/lib/auth.ts"
    click DBConn "https://github.com/tirthpshah/pexl/blob/main/src/lib/mongodb.ts"
    click Utils "https://github.com/tirthpshah/pexl/blob/main/src/lib/utils.ts"
    click Hooks "https://github.com/tirthpshah/pexl/blob/main/src/lib/hooks/useShops.ts"

    classDef client fill:#E3F2FD,stroke:#64B5F6,color:#0D47A1
    classDef frontend fill:#BBDEFB,stroke:#2196F3,color:#0D47A1
    classDef backend fill:#C8E6C9,stroke:#4CAF50,color:#1B5E20
    classDef lib fill:#E1F5FE,stroke:#03A9F4,color:#01579B
    classDef db fill:#EEEEEE,stroke:#9E9E9E,color:#424242
    classDef external fill:#FFE0B2,stroke:#FF9800,color:#E65100
    classDef cdn fill:#F5F5F5,stroke:#BDBDBD,color:#424242
```
