# yosp313/swift-find architecture

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

- Interactive diagram: https://gitdiagram.com/yosp313/swift-find
- Repository: https://github.com/yosp313/swift-find

## Overview

##### Main System Components

a) Frontend Layer (Client)
- Next.js Application
- Sanity CMS Integration
- Shopping Cart System
- Product Pages
- Authentication UI

b) Backend Layer (Server)
- Express.js Server
- Authentication System (Passport.js)
- Payment Processing (Stripe)
- Database Layer
- API Routes

c) External Services
- Sanity CMS
- Stripe Payment Gateway
- Database (SQL, based on Drizzle migrations)

**┌─ Next.js Frontend ─────────────────┐**
- Product Pages                   │
- Shopping Cart                   │
- Authentication UI               │
- Payment Integration             │
- ┘

**┌─ Express.js Server ───────────────┐**
- Auth Controllers               │
- Cart Controllers               │
- Payment Controllers            │
- User Controllers              │
- ┘

**┌─ External Services ─┐  ┌─ Database ─┐**
- Sanity CMS      │  │ SQL DB     │
- Stripe          │  └────────────┘
- ┘

##### Connection Flows

- Client → Server (REST API calls)
- Server → Database (Data persistence)
- Client → Sanity CMS (Content fetching)
- Server → Stripe (Payment processing)

##### Technical Details

Annotations for:
- TypeScript usage across all layers
- Tailwind CSS styling
- Next.js routing structure
- Database migration system
- API endpoint groupings

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Frontend["Next.js Frontend"]:::frontend
        ProductPages["Product Pages"]:::frontend
        ShoppingCart["Shopping Cart"]:::frontend
        AuthUI["Authentication UI"]:::frontend
        PaymentUI["Payment Integration"]:::frontend
        SanityIntegration["Sanity Integration"]:::frontend
    end

    subgraph Server
        Express["Express.js Server"]:::backend
        AuthController["Auth Controllers"]:::backend
        CartController["Cart Controllers"]:::backend
        PaymentController["Payment Controllers"]:::backend
        UserController["User Controllers"]:::backend
    end

    subgraph External
        SanityCMS["Sanity CMS"]:::external
        Stripe["Stripe Gateway"]:::external
    end

    subgraph Database
        SQL["SQL Database"]:::database
        Migrations["DB Migrations"]:::database
    end

    %% Connections
    Frontend --> Express
    ProductPages --> Express
    ShoppingCart --> CartController
    AuthUI --> AuthController
    PaymentUI --> PaymentController
    SanityIntegration --> SanityCMS

    Express --> SQL
    AuthController --> SQL
    CartController --> SQL
    PaymentController --> Stripe
    UserController --> SQL

    Migrations --> SQL

    %% Click Events
    click Frontend "https://github.com/yosp313/Swift-Find/tree/main/Client/src/app"
    click ShoppingCart "https://github.com/yosp313/Swift-Find/tree/main/Client/src/app/shopping-cart"
    click ProductPages "https://github.com/yosp313/Swift-Find/tree/main/Client/src/app/products"
    click AuthController "https://github.com/yosp313/Swift-Find/blob/main/Server/src/config/passport.ts"
    click Express "https://github.com/yosp313/Swift-Find/blob/main/Server/src/index.ts"
    click PaymentController "https://github.com/yosp313/Swift-Find/blob/main/Server/src/controllers/paymentController.ts"
    click SQL "https://github.com/yosp313/Swift-Find/tree/main/Server/src/config/db"
    click Express "https://github.com/yosp313/Swift-Find/tree/main/Server/src/routes"
    click SanityIntegration "https://github.com/yosp313/Swift-Find/tree/main/Client/src/utils/sanity"
    click SanityCMS "https://github.com/yosp313/Swift-Find/tree/main/CMS"
    click Stripe "https://github.com/yosp313/Swift-Find/blob/main/Server/src/config/stripe.ts"
    click CartController "https://github.com/yosp313/Swift-Find/blob/main/Server/src/controllers/cartController.ts"
    click UserController "https://github.com/yosp313/Swift-Find/blob/main/Server/src/controllers/userControllers.ts"
    click AuthUI "https://github.com/yosp313/Swift-Find/tree/main/Client/src/components/logout"
    click Migrations "https://github.com/yosp313/Swift-Find/tree/main/Server/src/config/db/migrations"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black
    classDef database fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        External_L["External Services"]:::external
        Database_L["Database"]:::database
    end
```
