# rohitha97/flavor-haven architecture

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

- Interactive diagram: https://gitdiagram.com/rohitha97/flavor-haven
- Repository: https://github.com/rohitha97/flavor-haven

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (React + TypeScript)
- Main pages: Home, Menu, Cart, Orders, Login
- Components directory structure

b) API Layer:
- REST API endpoints organized by resource
- Authentication system (NextAuth)
- Payment processing integration

c) Data Layer:
- PostgreSQL Database
- Prisma ORM interface
- Data models (visible in prisma/schema.prisma)

**[Client Browser] → [Next.js Frontend (SSR)] → [API Routes] → [Database]**

**Pages (src/app/*):**
- Home (/)
- Menu (/menu)
- Cart (/cart)
- Orders (/orders)
- Product Details (/product/[id])
- Payment (/pay/[id])

- Authentication (/api/auth/*)
- Products (/api/products/*)
- Orders (/api/orders/*)
- Categories (/api/categories/*)
- Notifications (/api/notifications/*)
- Checkout (/api/(checkout)/*)

##### Key Interactions to Highlight

- User authentication flow
- Order placement process
- Payment processing sequence
- Real-time notifications

##### Component Relationships

Key relationships:
**[AuthProvider] → [Protected Routes]**
**[Cart] → [Checkout] → [Payment]**
**[Orders] → [Notifications]**
**[Products] → [Categories]**

##### Technical Details

Annotations for:
- Prisma ORM layer
- NextAuth configuration
- Docker container structure
- TypeScript types (from src/types)

##### Infrastructure Elements

Include:
- Docker container boundaries
- Database connections
- External service integrations (payment)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Browser["Web Browser"]
        Frontend["Next.js Frontend"]:::frontend
        
        subgraph Pages["Pages"]
            Home["/"]:::page
            Menu["/menu"]:::page
            Cart["/cart"]:::page
            click Cart "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/cart/page.tsx"
            Orders["/orders"]:::page
            click Orders "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/orders/page.tsx"
            ProductDetails["/product/[id]"]:::page
            click ProductDetails "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/product/[id]/page.tsx"
            Payment["/pay/[id]"]:::page
        end
        
        subgraph Components["UI Components"]
            AuthProvider["Auth Provider"]:::component
            click AuthProvider "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/AuthProvider.tsx"
            CartIcon["Cart Icon"]:::component
            click CartIcon "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/CartIcon.tsx"
            CheckoutForm["Checkout Form"]:::component
            click CheckoutForm "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/CheckoutForm.tsx"
            Notification["Notifications"]:::component
            click Notification "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/Notification.tsx"
            Navbar["Navigation Bar"]:::component
            click Navbar "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/Navbar.tsx"
            Footer["Footer"]:::component
            click Footer "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/components/Footer.tsx"
        end
    end

    subgraph API["API Layer"]
        direction TB
        subgraph Auth["Authentication"]
            NextAuth["NextAuth"]:::auth
            click NextAuth "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/auth/[...nextauth]/route.ts"
        end

        subgraph Resources["API Resources"]
            ProductsAPI["Products API"]:::api
            click ProductsAPI "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/products/route.ts"
            OrdersAPI["Orders API"]:::api
            click OrdersAPI "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/orders/route.ts"
            CategoriesAPI["Categories API"]:::api
            click CategoriesAPI "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/categories/route.ts"
            NotificationsAPI["Notifications API"]:::api
            click NotificationsAPI "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/notifications/route.ts"
        end

        subgraph Payment["Payment Processing"]
            CreateIntent["Create Intent"]:::payment
            click CreateIntent "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/(checkout)/create-intent/[orderId]/route.ts"
            ConfirmPayment["Confirm Payment"]:::payment
            click ConfirmPayment "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/app/api/(checkout)/confirm/[intentId]/route.ts"
        end
    end

    subgraph Data["Data Layer"]
        PostgreSQL["PostgreSQL Database"]:::database
        Prisma["Prisma ORM"]:::orm
        click Prisma "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/prisma/schema.prisma"
        Store["State Management"]:::store
        click Store "https://github.com/Rohitha97/FLAVOR-HAVEN/blob/main/src/utils/store.ts"
    end

    %% Connections
    Browser --> Frontend
    Frontend --> AuthProvider
    Frontend --> Pages
    Frontend --> Components
    
    AuthProvider --> NextAuth
    Cart --> CreateIntent
    CreateIntent --> ConfirmPayment
    
    ProductsAPI --> Prisma
    OrdersAPI --> Prisma
    CategoriesAPI --> Prisma
    NotificationsAPI --> Prisma
    
    Prisma --> PostgreSQL

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef page fill:#2ecc71,stroke:#27ae60,color:white
    classDef component fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
    classDef auth fill:#f1c40f,stroke:#f39c12,color:white
    classDef payment fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white
    classDef orm fill:#1abc9c,stroke:#16a085,color:white
    classDef store fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Frontend Components"]:::frontend
        L2["Pages"]:::page
        L3["UI Components"]:::component
        L4["API Endpoints"]:::api
        L5["Authentication"]:::auth
        L6["Payment Processing"]:::payment
        L7["Database"]:::database
        L8["ORM Layer"]:::orm
    end
```
