# rafaelaraujo02/fsw-store architecture

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

- Interactive diagram: https://gitdiagram.com/rafaelaraujo02/fsw-store
- Repository: https://github.com/rafaelaraujo02/fsw-store

## Overview

##### Project type and purpose
- This is a full-stack, e-commerce web application built on Next.js.
- It uses server-side rendering (SSR) and server actions (`src/actions/checkout.ts`) for checkout processing, NextAuth for authentication (`src/app/api/auth/[...nextauth]`), and Prisma ORM to manage a relational database (via `prisma/schema.prisma`).
- It provides product listings, categories, individual product pages, a shopping cart, user auth, and checkout.

##### File structure
- Top-level configuration: ESLint, Tailwind, PostCSS, Next.js (`next.config.js`), TypeScript (`tsconfig.json`).
- `prisma/`: database schema, migrations, seed script → relational database (e.g., PostgreSQL).
- `src/app/`: Next.js “App Router” directory containing route segments:
- `(home)`, `/catalog`, `/category/[slug]`, `/product/[slug]`
- API routes under `src/app/api/auth` for NextAuth.
- `src/components/ui`: shared React UI components (header, footer, product list, cart).
- `src/actions`: server actions (checkout).
- `src/lib`: utility modules for Prisma client and auth helpers.
- `src/providers`: React context providers (auth and cart state).

##### README for additional insights
- Emphasizes use of Next.js features (SSR/SSG, API routes, font optimization).
- Deploys on Vercel.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Browser"]:::frontend
    subgraph "Client Layer"
        ReactClient["React Client Components"]:::frontend
        Providers["Context Providers\n(Auth, Cart)"]:::frontend
    end
    Browser --> ReactClient
    Browser --> Providers

    ReactClient --> AppRouter
    Providers --> AppRouter

    %% Server Layer
    subgraph "Server Layer"
        AppRouter["Next.js App Router\n(src/app/)"]:::backend

        subgraph "Frontend Routes"
            Home["Home Page"]:::frontend
            Catalog["Catalog Page"]:::frontend
            Category["Category Page"]:::frontend
            Product["Product Page"]:::frontend
        end

        subgraph "API Routes"
            AuthAPI["NextAuth API\n(/api/auth)"]:::backend
            CheckoutAction["Checkout Action"]:::backend
        end
    end

    AppRouter -->|SSR/SSG| Home
    AppRouter -->|SSR/SSG| Catalog
    AppRouter -->|SSR/SSG| Category
    AppRouter -->|SSR/SSG| Product
    AppRouter --> AuthAPI
    AppRouter --> CheckoutAction

    %% Database Layer
    ORM["Prisma ORM"]:::database
    DB["Database\n(PostgreSQL)"]:::database

    AuthAPI --> ORM
    CheckoutAction --> ORM
    ORM --> DB

    subgraph "Prisma Schema"
        Schema["schema.prisma"]:::database
        Migrations["migrations/"]:::database
        Seed["seed.ts"]:::database
    end
    Schema --> Migrations
    Migrations --> Seed

    %% Utilities & Helpers
    subgraph "Utilities & Lib"
        AuthLib["Auth Helpers"]:::backend
        Utils["General Utils"]:::backend
        ProductHelpers["Product Helpers"]:::backend
        CategoryIcons["Category Icons"]:::backend
    end
    AuthAPI --> AuthLib
    AppRouter --> Utils
    AppRouter --> ProductHelpers
    AppRouter --> CategoryIcons

    %% Shared UI Components
    subgraph "Shared UI Components"
        UI["UI Components"]:::frontend
    end
    AppRouter --> UI
    Providers --> UI

    %% External Services
    PaymentGateway["Payment Gateway"]:::external
    PaymentWebhook["Payment Webhook"]:::external
    CDN["CDN / Static Assets"]:::external

    CheckoutAction -->|POST payment intent| PaymentGateway
    PaymentGateway -->|webhook callback| AuthAPI
    CDN -->|serves static assets| AppRouter

    %% Click Events
    click AppRouter "https://github.com/rafaelaraujo02/fsw-store/tree/master/src/app/"
    click Home "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/(home)/page.tsx"
    click Home "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/(home)/components/categories.tsx"
    click Home "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/(home)/components/category-item.tsx"
    click Home "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/(home)/components/promo-banner.tsx"
    click Catalog "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/catalog/page.tsx"
    click Catalog "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/catalog/components/category-item.tsx"
    click Category "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/category/[slug]/page.tsx"
    click Product "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/product/[slug]/page.tsx"
    click Product "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/product/[slug]/components/product-image.tsx"
    click Product "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/product/[slug]/components/product-info.tsx"
    click UI "https://github.com/rafaelaraujo02/fsw-store/tree/master/src/components/ui/"
    click AuthAPI "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/app/api/auth/[...nextauth]/route.ts"
    click CheckoutAction "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/actions/checkout.ts"
    click ORM "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/lib/prisma.ts"
    click Schema "https://github.com/rafaelaraujo02/fsw-store/blob/master/prisma/schema.prisma"
    click Migrations "https://github.com/rafaelaraujo02/fsw-store/tree/master/prisma/migrations/"
    click Seed "https://github.com/rafaelaraujo02/fsw-store/blob/master/prisma/seed.ts"
    click AuthLib "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/lib/auth.ts"
    click Utils "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/lib/utils.ts"
    click ProductHelpers "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/helpers/product.ts"
    click CategoryIcons "https://github.com/rafaelaraujo02/fsw-store/blob/master/src/constants/category-icon.tsx"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#0D47A1,stroke-width:1px,color:#0D47A1
    classDef backend fill:#C8E6C9,stroke:#1B5E20,stroke-width:1px,color:#1B5E20
    classDef database fill:#FFE0B2,stroke:#E65100,stroke-width:1px,color:#E65100
    classDef external fill:#E1BEE7,stroke:#4A148C,stroke-width:1px,color:#4A148C
```
