# saumyajeet-varma/urbancarry-ecommerce-backend-ssr architecture

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

- Interactive diagram: https://gitdiagram.com/saumyajeet-varma/urbancarry-ecommerce-backend-ssr
- Repository: https://github.com/saumyajeet-varma/urbancarry-ecommerce-backend-ssr

## Overview

##### Main Components

A. Client Layer
- Browser/Client Interface
- Static Assets (public folder)
- Images
- JavaScript files
- Stylesheets

B. Application Layer
- Views (EJS Templates)
- Routes Layer
- Controllers Layer
- Middleware Layer
- Models Layer

C. Data Layer
- Database Connection
- Authentication System

##### Component Relationships

**Client → Routes → Middleware → Controllers → Models → Database**
- ↓
- Views

##### Detailed Component Breakdown

- Images
- JavaScript files
- CSS files
- To "Views (EJS)" showing templates:
- admin.ejs
- createProduct.ejs
- index.ejs
- register.ejs
- shop.ejs

- Main Router (index.js)
- Users Router
- Products Router
- Owners Router

- Authentication Middleware (isLoggedIn.js)
- Multer Configuration (file uploads)

- Auth Controller
- Connection to respective routes

- User Model
- Product Model
- Owner Model

- Database Connection
- Relationship with Models

##### Additional Elements

- Authentication Flow:
- Authentication middleware interaction

- File Upload Flow:
- Multer configuration
- File storage path

##### Key Architectural Patterns to Highlight

- MVC Pattern implementation
- Middleware chain
- Authentication flow
- Static file serving
- Template rendering
- Database interactions

##### Technologies to Highlight

- Node.js/Express.js
- EJS templating
- MongoDB/Mongoose (implied by model structure)
- JWT (implied by token generation)
- Multer for file uploads

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Browser/Client Interface"]
        StaticAssets["Static Assets"]:::static
        click StaticAssets "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/tree/main/public"
        Images["Images"]:::static
        click Images "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/tree/main/public/images"
        JS["JavaScript Files"]:::static
        click JS "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/tree/main/public/javascripts"
        CSS["Stylesheets"]:::static
        click CSS "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/tree/main/public/stylesheets"
        StaticAssets --> Images
        StaticAssets --> JS
        StaticAssets --> CSS
    end

    subgraph Views
        Templates["EJS Templates"]:::view
        click Templates "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/tree/main/views"
        AdminView["admin.ejs"]:::view
        click AdminView "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/views/admin.ejs"
        CreateProduct["createProduct.ejs"]:::view
        click CreateProduct "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/views/createProduct.ejs"
        IndexView["index.ejs"]:::view
        click IndexView "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/views/index.ejs"
        RegisterView["register.ejs"]:::view
        click RegisterView "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/views/register.ejs"
        ShopView["shop.ejs"]:::view
        click ShopView "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/views/shop.ejs"
        Templates --> AdminView
        Templates --> CreateProduct
        Templates --> IndexView
        Templates --> RegisterView
        Templates --> ShopView
    end

    subgraph Routes
        MainRouter["Main Router"]:::route
        click MainRouter "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/routes/index.js"
        UsersRouter["Users Router"]:::route
        click UsersRouter "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/routes/usersRouter.js"
        ProductsRouter["Products Router"]:::route
        click ProductsRouter "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/routes/productsRouter.js"
        OwnersRouter["Owners Router"]:::route
        click OwnersRouter "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/routes/ownersRouter.js"
    end

    subgraph Middleware
        AuthMiddleware["Authentication Middleware"]:::middleware
        click AuthMiddleware "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/middlewares/isLoggedIn.js"
        MulterConfig["Multer Configuration"]:::middleware
        click MulterConfig "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/config/multerConfig.js"
    end

    subgraph Controllers
        AuthController["Auth Controller"]:::controller
        click AuthController "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/controllers/authController.js"
    end

    subgraph Models
        UserModel["User Model"]:::model
        click UserModel "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/models/userModel.js"
        ProductModel["Product Model"]:::model
        click ProductModel "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/models/productModel.js"
        OwnerModel["Owner Model"]:::model
        click OwnerModel "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/models/ownerModel.js"
    end

    subgraph Database
        DBConnection["Database Connection"]:::database
        click DBConnection "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/config/databaseConnection.js"
    end

    subgraph Utils
        TokenGen["Token Generation"]:::util
        click TokenGen "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/utils/generateToken.js"
    end

    AppEntry["Application Entry Point"]:::entry
    click AppEntry "https://github.com/Saumyajeet-Varma/UrbanCarry-Ecommerce-Backend-SSR/blob/main/app.js"

    Browser --> StaticAssets
    Browser --> AppEntry
    AppEntry --> Routes
    Routes --> Middleware
    Middleware --> Controllers
    Controllers --> Models
    Models --> DBConnection
    Controllers --> Templates
    AuthMiddleware --> TokenGen

    classDef static fill:#3498db,stroke:#2980b9,color:#fff
    classDef view fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef route fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef middleware fill:#f1c40f,stroke:#f39c12,color:#fff
    classDef controller fill:#e67e22,stroke:#d35400,color:#fff
    classDef model fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef database fill:#34495e,stroke:#2c3e50,color:#fff
    classDef util fill:#1abc9c,stroke:#16a085,color:#fff
    classDef entry fill:#95a5a6,stroke:#7f8c8d,color:#fff
```
