# amedutambour/fullstack-next15 architecture

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

- Interactive diagram: https://gitdiagram.com/amedutambour/fullstack-next15
- Repository: https://github.com/amedutambour/fullstack-next15

## Overview

##### Project type and purpose
- This is a full-stack e-commerce / content-driven web application built with Next.js App Router.
- It provides:
- A public shopping site (product listings, cart, checkout, blog, contact)
- A user area (order history, profile)
- An admin CMS (product & article management, analytics, orders, users)
- Serverless API endpoints for auth, products, uploads, webhooks
- Data persistence via Prisma + a relational database
- Integrations with Stripe, PayPal, an email service, and Uploadthing for file storage

##### File structure
- Top-level “app/” folder holds your Next.js pages (App Router) organized into route segments:
- (auth), (root) for public flows
- /user for end-user account pages
- /admin for CMS
- “app/api/” contains serverless route handlers: auth (NextAuth), products CRUD, uploads, Stripe webhooks
- “db/” + “prisma/” hold Prisma client, migration files, seed scripts, and your data model definitions
- “lib/actions/” encapsulate business logic (cart, order, user, product actions) separated from route code
- “components/” holds reusable UI components (shared, admin, ui primitives)
- “email/” templates for transactional emails
- Additional config: middleware.ts, next.config.ts, Tailwind, PostCSS, TypeScript

##### README
- Confirms Next.js as the framework.
- Standard dev / build / deploy instructions.

##### Diagramming recommendations
- Blue for UI/Pages
- Green for API/Business Logic
- Orange for Data
- Purple for External Services

##### Detail
- Break out key modules: Authentication, Product Management, Order Processing, CMS Admin, Email Notifications, File Upload
- Your middleware (apiAuthMiddleware) as a cross-cutting component on API calls
- Stateful vs stateless parts (e.g., sessions stored via NextAuth, ephemeral serverless functions)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend (Next.js App Router)" 
        direction TB
        PublicSite["Public Shopping Site<br>(Product Listings, Cart, Checkout, Blog, Contact)"]:::frontend
        UserArea["User Area<br>(Order History, Profile)"]:::frontend
        AdminCMS["Admin CMS<br>(Product & Article Management, Analytics, Orders, Users)"]:::frontend
        UIComponents["UI Components<br>(shared, admin, ui primitives)"]:::frontend
        GlobalStyles["Global Styles & Assets<br>(CSS, Images)"]:::frontend
    end

    Browser["Browser / Client"]:::frontend
    Browser -->|"renders pages"| PublicSite
    Browser -->|"renders pages"| UserArea
    Browser -->|"renders pages"| AdminCMS

    %% API Layer
    subgraph "API Layer (Serverless Functions)" 
        direction TB
        Middleware["apiAuthMiddleware"]:::api
        AuthRoute["NextAuth Route<br>(app/api/auth/[...nextauth])"]:::api
        LoginRoute["Login Endpoint<br>(app/api/auth/login)"]:::api
        ProductsListCreate["Products List/Create<br>(app/api/products)"]:::api
        ProdDetail["Product CRUD Detail<br>(app/api/products/[id])"]:::api
        DeclareSale["Declare Sale<br>(app/api/products/[id]/declare-sale)"]:::api
        ReleaseSale["Release Sale<br>(app/api/products/[id]/release)"]:::api
        BlockUnblock["Block/Unblock<br>(app/api/products/[id]/block)"]:::api
        UploadRoute["Uploadthing Route<br>(app/api/uploadthing)"]:::api
        UploadCore["Uploadthing Core<br>(app/api/uploadthing/core)"]:::api
        StripeWebhook["Stripe Webhook<br>(app/api/webhooks/stripe)"]:::api
    end

    PublicSite -->|"fetch REST"| ProductsListCreate
    UserArea -->|"fetch REST"| AuthRoute
    UserArea -->|"fetch REST"| ProductsListCreate
    AdminCMS -->|"manage via API"| ProdDetail
    AdminCMS -->|"manage via API"| DeclareSale
    AdminCMS -->|"manage via API"| ReleaseSale
    AdminCMS -->|"manage via API"| BlockUnblock

    %% Business Logic Layer
    subgraph "Business Logic (lib/actions)" 
        direction TB
        ArticleActions["article.actions.ts"]:::api
        CartActions["cart.actions.ts"]:::api
        ContactActions["contact.actions.ts"]:::api
        OrderActions["order.actions.ts"]:::api
        ProductActions["product.actions.ts"]:::api
        UserActions["user.actions.ts"]:::api
    end

    Middleware --> AuthRoute
    Middleware --> LoginRoute
    Middleware --> ProductsListCreate
    Middleware --> ProdDetail
    Middleware --> DeclareSale
    Middleware --> ReleaseSale
    Middleware --> BlockUnblock

    AuthRoute -->|calls| UserActions
    LoginRoute -->|calls| UserActions
    ProductsListCreate -->|calls| ProductActions
    ProdDetail -->|calls| ProductActions
    DeclareSale -->|calls| ProductActions
    ReleaseSale -->|calls| ProductActions
    BlockUnblock -->|calls| ProductActions
    UploadRoute -->|calls| CartActions
    UploadCore -->|calls| ProductActions
    StripeWebhook -->|calls| OrderActions
    StripeWebhook -->|calls| UserActions
    ContactActions -- triggers --> OrderActions

    %% Database Layer
    subgraph "Database (Prisma + SQL)" 
        direction TB
        PrismaClient["db/prisma.ts"]:::db
        SeedScripts["db/seed.ts & sample-data.ts"]:::db
        Schema["prisma/schema/schema.prisma & migrations"]:::db
    end

    ArticleActions -->|SQL via Prisma| PrismaClient
    CartActions -->|SQL via Prisma| PrismaClient
    ContactActions -->|SQL via Prisma| PrismaClient
    OrderActions -->|SQL via Prisma| PrismaClient
    ProductActions -->|SQL via Prisma| PrismaClient
    UserActions -->|SQL via Prisma| PrismaClient

    %% External Services
    subgraph "External Services" 
        direction TB
        Stripe["Stripe"]:::external
        PayPal["PayPal SDK"]:::external
        EmailService["Email Service"]:::external
        FileStorage["Uploadthing Service"]:::external
    end

    ProductActions -->|"Stripe SDK/API"| Stripe
    OrderActions -->|"PayPal SDK/API"| PayPal
    ContactActions -->|"send email"| EmailService
    UploadRoute -->|"upload API"| FileStorage
    UploadCore -->|"upload API"| FileStorage

    %% Click Events
    click PublicSite "https://github.com/amedutambour/fullstack-next15/tree/main/app/(root)"
    click UserArea "https://github.com/amedutambour/fullstack-next15/tree/main/app/user"
    click AdminCMS "https://github.com/amedutambour/fullstack-next15/tree/main/app/admin"
    click AuthRoute "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/auth/[...nextauth]/route.ts"
    click LoginRoute "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/auth/login/route.ts"
    click ProductsListCreate "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/products/route.ts"
    click ProdDetail "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/products/[identifier]/route.ts"
    click DeclareSale "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/products/[identifier]/declare-sale/route.ts"
    click ReleaseSale "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/products/[identifier]/release/route.ts"
    click BlockUnblock "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/products/[identifier]/block/route.ts"
    click UploadRoute "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/uploadthing/route.ts"
    click UploadCore "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/uploadthing/core.ts"
    click StripeWebhook "https://github.com/amedutambour/fullstack-next15/blob/main/app/api/webhooks/stripe/route.ts"
    click ArticleActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/article.actions.ts"
    click CartActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/cart.actions.ts"
    click ContactActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/contact.actions.ts"
    click OrderActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/order.actions.ts"
    click ProductActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/product.actions.ts"
    click UserActions "https://github.com/amedutambour/fullstack-next15/blob/main/lib/actions/user.actions.ts"
    click PrismaClient "https://github.com/amedutambour/fullstack-next15/blob/main/db/prisma.ts"
    click SeedScripts "https://github.com/amedutambour/fullstack-next15/blob/main/db/seed.ts"
    click Schema "https://github.com/amedutambour/fullstack-next15/blob/main/prisma/schema/schema.prisma"
    click Middleware "https://github.com/amedutambour/fullstack-next15/blob/main/app/middlewares/apiAuthMiddleware.ts"
    click EmailService "https://github.com/amedutambour/fullstack-next15/blob/main/email/index.tsx"
    click FileStorage "https://github.com/amedutambour/fullstack-next15/blob/main/lib/uploadthing.ts"
    click PayPal "https://github.com/amedutambour/fullstack-next15/blob/main/lib/paypal.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef api fill:#d4edda,stroke:#333,stroke-width:1px
    classDef db fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#e2d6f2,stroke:#333,stroke-width:1px
```
