# sk394/cuisine-connect architecture

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

- Interactive diagram: https://gitdiagram.com/sk394/cuisine-connect
- Repository: https://github.com/sk394/cuisine-connect

## Overview

##### Main System Components

a. Frontend Layer (Next.js Application)
- Client-side components (/frontend/src/components)
- Page routes (/frontend/src/app)
- Authentication flows (/frontend/src/app/auth)
- Dashboard features (/frontend/src/app/dashboard)
- API integration layer (/frontend/src/app/api)

b. Backend Layer (Node.js/Express)
- Controllers (/backend/Controller)
- Routes (/backend/routes)
- Database configuration (/backend/DB)

c. Database Layer
- Prisma ORM (both frontend and backend have prisma schemas)
- Underlying database (likely PostgreSQL based on Prisma usage)

##### Key Interactions to Highlight

- Client-server communication between frontend and backend
- API routes handling (both Next.js API routes and backend Express routes)
- Database interactions through Prisma
- Authentication flows (NextAuth.js integration)
- File upload flows (UploadThing integration)

##### Specific Components

Frontend:
- Next.js Pages and Routes
- Authentication Components
- Recipe Management Components
- Dashboard Components
- UI Component Library
- State Management (React Query provider)
- Theme Provider
- Session Provider

Backend:
- Recipe Controller
- User Controller
- Bookmark Controller
- Comment Controller
- Rating Controller
- Route Handlers
- Database Connection Layer

##### Infrastructure Elements
- Docker containers (indicated by Dockerfile presence)
- Development environment setup
- API endpoints structure

##### Database Layer

- Component types and their representations
- Any abbreviated terms or symbols

Keep the abstraction level high enough to be understandable but detailed enough to show the key architectural decisions, especially the dual-prisma setup and the separation of concerns between frontend and backend services.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph FrontendLayer["Frontend Application Layer"]
        direction TB
        NextApp["Next.js Application"]
        Components["UI Components"]:::frontend
        Auth["Authentication System"]:::auth
        Dashboard["Dashboard"]:::frontend
        StateManagement["React Query Provider"]:::frontend
        ThemeProvider["Theme Provider"]:::frontend
        SessionProvider["Session Provider"]:::auth
        UILib["UI Component Library"]:::frontend
        RecipeManagementFE["Recipe Management Frontend"]:::frontend
    end

    subgraph APILayer["API Layer"]
        direction TB
        NextAPIRoutes["Next.js API Routes"]:::api
        FileUpload["UploadThing Integration"]:::external
        ExpressRoutes["Express Routes"]:::api
    end

    subgraph BackendLayer["Service Layer"]
        direction TB
        RecipeController["Recipe Controller"]:::backend
        UserController["User Controller"]:::backend
        BookmarkController["Bookmark Controller"]:::backend
        CommentController["Comment Controller"]:::backend
        RatingController["Rating Controller"]:::backend
    end

    subgraph DataLayer["Data Access Layer"]
        direction TB
        PrismaFE["Frontend Prisma"]:::database
        PrismaBE["Backend Prisma"]:::database
        DBConfig["Database Config"]:::database
    end

    subgraph Database
        PostgreSQL[(PostgreSQL)]:::database
    end

    %% Connections
    Browser --> NextApp
    NextApp --> Components
    NextApp --> Auth
    NextApp --> Dashboard
    NextApp --> StateManagement
    NextApp --> ThemeProvider
    NextApp --> SessionProvider
    NextApp --> UILib
    NextApp --> RecipeManagementFE
    
    Components --> NextAPIRoutes
    Auth --> NextAPIRoutes
    Dashboard --> NextAPIRoutes
    RecipeManagementFE --> NextAPIRoutes
    
    NextAPIRoutes --> FileUpload
    NextAPIRoutes --> ExpressRoutes
    
    ExpressRoutes --> RecipeController
    ExpressRoutes --> UserController
    ExpressRoutes --> BookmarkController
    ExpressRoutes --> CommentController
    ExpressRoutes --> RatingController
    
    RecipeController --> PrismaBE
    UserController --> PrismaBE
    BookmarkController --> PrismaBE
    CommentController --> PrismaBE
    RatingController --> PrismaBE
    
    NextAPIRoutes --> PrismaFE
    PrismaFE --> PostgreSQL
    PrismaBE --> PostgreSQL
    DBConfig --> PostgreSQL

    %% Click Events
    click Components "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/components"
    click Auth "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/app/auth"
    click Dashboard "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/app/dashboard"
    click StateManagement "https://github.com/sk394/cuisine-connect/blob/master/frontend/providers/react-query-provider.jsx"
    click ThemeProvider "https://github.com/sk394/cuisine-connect/blob/master/frontend/providers/theme-provider.jsx"
    click SessionProvider "https://github.com/sk394/cuisine-connect/blob/master/frontend/providers/session-provider.jsx"
    click UILib "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/components/ui"
    click RecipeManagementFE "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/components/recipes"
    click NextAPIRoutes "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/app/api"
    click FileUpload "https://github.com/sk394/cuisine-connect/tree/master/frontend/src/app/api/uploadthing"
    click ExpressRoutes "https://github.com/sk394/cuisine-connect/tree/master/backend/routes"
    click RecipeController "https://github.com/sk394/cuisine-connect/blob/master/backend/Controller/RecipeController.js"
    click CommentController "https://github.com/sk394/cuisine-connect/blob/master/backend/Controller/CommentController.js"
    click RatingController "https://github.com/sk394/cuisine-connect/blob/master/backend/Controller/RatingController.js"
    click BookmarkController "https://github.com/sk394/cuisine-connect/blob/master/backend/Controller/BookmarkController.js"
    click DBConfig "https://github.com/sk394/cuisine-connect/blob/master/backend/DB/db.config.js"
    click PrismaFE "https://github.com/sk394/cuisine-connect/blob/master/frontend/prisma/schema.prisma"
    click PrismaBE "https://github.com/sk394/cuisine-connect/blob/master/backend/prisma/schema.prisma"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef database fill:#FFC107,color:black
    classDef api fill:#FF5722,color:white
    classDef auth fill:#9C27B0,color:white
    classDef external fill:#FF9800,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DB["Database Component"]:::database
        API["API Component"]:::api
        Auth["Auth Component"]:::auth
        External["External Service"]:::external
    end
```
