# kaso45/coffeeproject architecture

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

- Interactive diagram: https://gitdiagram.com/kaso45/coffeeproject
- Repository: https://github.com/kaso45/coffeeproject

## Overview

##### Main Components

A. Frontend Layer:
- Client-Side Components (EJS Views)
- Static Assets (public folder)
- Client-Side JavaScript
- Bootstrap UI Framework

B. Backend Layer:
- Express.js Server (app.js)
- Authentication System
- Controllers Layer
- Models Layer
- Middleware Layer

C. Database Layer:
- MongoDB (indicated by the database.js configuration)

D. External Services:
- Vercel Deployment Platform
- Docker Container System

**┌─ Client Tier ─────────────────────┐**
- EJS Templates                   │
- Bootstrap UI                    │
- Static Assets (CSS/JS/Images)   │
- ┬───────────────────┘
- ↕ HTTP/HTTPS
**┌─ Application Tier ─────────────────┐**
- ┌─ Routes Layer ─────────────────┐ │
- Auth Routes                  │ │
- Product Routes              │ │
- Cart Routes                 │ │
- ┘ │
- ┌─ Controllers Layer ───────────┐ │
- Auth Controller            │ │
- Product Controller         │ │
- Cart Controller            │ │
- ┘ │
- ┌─ Middleware Layer ───────────┐  │
- Upload Middleware          │  │
- ┘ │
- ┬───────────────────┘
- ↕
**┌─ Data Tier ──────────────────────┐**
- ┌─ Models ───────────────────┐   │
- User Model              │   │
- Product Model           │   │
- Cart Model             │   │
- ┘   │
- MongoDB Database                 │
- ┘

##### Important Relationships to Highlight

A. Frontend-Backend Integration:
- How the EJS views communicate with controllers
- Static asset serving paths
- Authentication flows

B. Data Flow:
- User authentication path
- Product browsing and cart operations
- Image upload handling

C. External Service Integration:
- Docker containerization boundary
- Vercel deployment workflow

##### Infrastructure Elements

- Docker container boundaries
- Environment configuration
- Static file serving
- Database connections

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        Views["EJS Views"]
        Static["Static Assets"]
        Bootstrap["Bootstrap UI"]
        ClientJS["Client JavaScript"]
    end

    subgraph Server["Application Layer"]
        Express["Express Server"]
        
        subgraph Routes["Routes Layer"]
            AuthRoutes["Auth Routes"]
            ProductRoutes["Product Routes"]
            CartRoutes["Cart Routes"]
        end
        
        subgraph Controllers["Controllers Layer"]
            AuthController["Auth Controller"]
            ProductController["Product Controller"]
            CartController["Cart Controller"]
        end
        
        subgraph Middleware["Middleware Layer"]
            UploadMiddleware["Upload Middleware"]
        end
    end

    subgraph Data["Data Layer"]
        Database["MongoDB Database"]
        subgraph Models["Data Models"]
            UserModel["User Model"]
            ProductModel["Product Model"]
            CartModel["Cart Model"]
        end
    end

    subgraph Infrastructure["Infrastructure"]
        Docker["Docker Container"]
        Vercel["Vercel Platform"]
    end

    %% Relationships
    Views --> Express
    Static --> Express
    Express --> Routes
    Routes --> Controllers
    Controllers --> Models
    Models --> Database
    UploadMiddleware --> Controllers

    %% Component Mappings
    click Express "https://github.com/Kaso45/CoffeeProject/blob/main/app.js"
    click Database "https://github.com/Kaso45/CoffeeProject/blob/main/config/database.js"
    click AuthController "https://github.com/Kaso45/CoffeeProject/blob/main/controllers/authControllers.js"
    click ProductController "https://github.com/Kaso45/CoffeeProject/blob/main/controllers/productController.js"
    click CartController "https://github.com/Kaso45/CoffeeProject/blob/main/controllers/cartController.js"
    click UploadMiddleware "https://github.com/Kaso45/CoffeeProject/blob/main/middlewares/uploadMiddleware.js"
    click UserModel "https://github.com/Kaso45/CoffeeProject/blob/main/models/User.js"
    click ProductModel "https://github.com/Kaso45/CoffeeProject/blob/main/models/Product.js"
    click CartModel "https://github.com/Kaso45/CoffeeProject/blob/main/models/Cart.js"
    click Views "https://github.com/Kaso45/CoffeeProject/tree/main/view/layouts"
    click Static "https://github.com/Kaso45/CoffeeProject/tree/main/public"
    click Bootstrap "https://github.com/Kaso45/CoffeeProject/tree/main/public/bootstrap"
    click ClientJS "https://github.com/Kaso45/CoffeeProject/tree/main/public/js"
    click AuthRoutes "https://github.com/Kaso45/CoffeeProject/blob/main/routes/auth.js"
    click CartRoutes "https://github.com/Kaso45/CoffeeProject/blob/main/routes/cartRoutes.js"
    click ProductRoutes "https://github.com/Kaso45/CoffeeProject/blob/main/routes/productRoutes.js"
    click Docker "https://github.com/Kaso45/CoffeeProject/tree/main/Dockerfile"
    click Vercel "https://github.com/Kaso45/CoffeeProject/blob/main/vercel.json"

    %% Styling
    classDef client fill:#a8d1ff
    classDef server fill:#90EE90
    classDef data fill:#FFE5B4
    classDef infra fill:#E6E6FA

    class Views,Static,Bootstrap,ClientJS client
    class Express,AuthRoutes,ProductRoutes,CartRoutes,AuthController,ProductController,CartController,UploadMiddleware server
    class Database,UserModel,ProductModel,CartModel data
    class Docker,Vercel infra
```
