# samshersingh1/logistics-supply-tracking architecture

> Architecture diagram of the GitHub repository samshersingh1/logistics-supply-tracking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samshersingh1/logistics-supply-tracking
- Repository: https://github.com/samshersingh1/logistics-supply-tracking

## Overview

##### Project type and purpose
- This is a full-stack web application for a logistics supply chain management system.
- Frontend: React.js + Tailwind CSS; Backend: Node.js + Express; Database: MongoDB; File storage: Pinata/IPFS (and Cloudinary in config).
- Core feature: secure OTP-based product handoffs between seller, multiple middlemen, and buyer, with role-based access and real-time status tracking.

##### File structure
- Top-level directories:
- Backend/ – Express monolith with MVC-style organization:
– config/ (DB, Cloudinary)
– controllers/ (authController, orderController, productController)
– routes/ (AuthRoutes, orderRoutes, productRoutes)
– middleware/ (authMiddleware, errorHandling, fileUpload)
– models/ (User, Order, Product)
– utils/ (AsyncHandling, CloudinaryConfig, ResponseHandling, logger)
– index.js, route.js as the main entry and router aggregator
- fronted/ – React app (note the typo) with:
– public/ (static HTML, manifest)
– src/ (App.js, components, pages, context, styles, assets)
- Notice: separate context for authentication, protected routes, and domain pages (AddProduct, Orders, Transactions, etc.)

##### README for additional insights
- Flow: seller → generateTransferOTP → send OTP → middleman → verifyOtp → confirmTransfer → next node, etc.
- Roles: Seller, Middleman(s), Delivery Admin, Buyer
- External services: Pinata for file storage; MongoDB as persistence; JWT + cookies for auth; OTP logic internal REST endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        WebClient["Web Client (React App)"]:::frontend
        AuthContext["AuthContext"]:::frontend
        ProtectedRoute["ProtectedRoute"]:::frontend
        Navbar["Navbar"]:::frontend
        subgraph "Pages"
            direction TB
            HomePage["HomePage"]:::frontend
            LoginPage["LoginPage"]:::frontend
            SignupPage["SignupPage"]:::frontend
            ProfilePage["ProfilePage"]:::frontend
            AddProductPage["AddProductPage"]:::frontend
            ProductsPage["ProductsPage"]:::frontend
            OrdersPage["OrdersPage"]:::frontend
            TransactionsPage["TransactionsPage"]:::frontend
            DeliveryDashboard["DeliveryDashboard"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        API["API Gateway / Backend Server"]:::backend
        Router["Router Aggregator"]:::backend

        subgraph "Routing Layer"
            direction TB
            AuthRoutes["AuthRoutes"]:::backend
            OrderRoutes["OrderRoutes"]:::backend
            ProductRoutes["ProductRoutes"]:::backend
        end

        subgraph "Controller Layer"
            direction TB
            AuthController["AuthController"]:::backend
            OrderController["OrderController"]:::backend
            ProductController["ProductController"]:::backend
        end

        subgraph "Middleware"
            direction TB
            AuthMiddleware["authMiddleware"]:::backend
            ErrorHandling["errorHandlingMiddleware"]:::backend
            UploadMiddleware["uploadMiddleware"]:::backend
        end

        subgraph "Utils"
            direction TB
            AsyncHandling["AsyncHandling"]:::backend
            CloudinaryConfig["CloudinaryConfig"]:::backend
            ResponseHandling["ResponseHandling"]:::backend
            LoggerUtil["logger"]:::backend
        end

        subgraph "Config"
            direction TB
            DBConfig["db.js"]:::backend
            CloudConfig["connectCloudnery.js"]:::backend
        end

        subgraph "Models"
            direction TB
            UserModel["User"]:::backend
            OrderModel["Order"]:::backend
            ProductModel["Product"]:::backend
        end
    end

    %% External Services & DB
    MongoDB["MongoDB"]:::db
    Pinata["Pinata/IPFS"]:::external
    Cloudinary["Cloudinary"]:::external
    LogFiles["Logs (combined.log, error.log)"]:::external

    %% Connections - Frontend to Backend
    WebClient -->|"uses"| AuthContext
    AuthContext -->|"provides auth state"| ProtectedRoute
    Navbar -->|"navigation"| WebClient
    HomePage -->|"renders"| WebClient
    LoginPage -->|"renders"| WebClient
    SignupPage -->|"renders"| WebClient
    ProfilePage -->|"renders"| WebClient
    AddProductPage -->|"renders"| WebClient
    ProductsPage -->|"renders"| WebClient
    OrdersPage -->|"renders"| WebClient
    TransactionsPage -->|"renders"| WebClient
    DeliveryDashboard -->|"renders"| WebClient
    ProtectedRoute -->|"guards routes"| Pages

    WebClient -->|"HTTP(S) requests"| API

    %% Backend internal flow
    API --> Router
    Router --> AuthRoutes
    Router --> OrderRoutes
    Router --> ProductRoutes
    AuthRoutes --> AuthController
    OrderRoutes --> OrderController
    ProductRoutes --> ProductController

    AuthController --> AuthMiddleware
    OrderController --> AsyncHandling
    OrderController --> ResponseHandling
    OrderController -->|"OTP Logic"| AsyncHandling
    ProductController --> ResponseHandling

    UploadMiddleware --> CloudinaryConfig
    CloudConfig --> CloudinaryConfig
    CloudinaryConfig --> Cloudinary

    AuthController --> UserModel
    OrderController --> OrderModel
    ProductController --> ProductModel

    UserModel --> MongoDB
    OrderModel --> MongoDB
    ProductModel --> MongoDB

    LoggerUtil --> LogFiles

    %% File storage interactions
    OrderController -->|"file upload"| UploadMiddleware
    UploadMiddleware --> Pinata
    UploadMiddleware --> Cloudinary

    %% Class Definitions
    classDef frontend fill:#E3F2FD,stroke:#42A5F5,color:#0D47A1;
    classDef backend fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20;
    classDef db fill:#FFF3E0,stroke:#FFA726,color:#E65100;
    classDef external fill:#ECEFF1,stroke:#90A4AE,color:#37474F;

    %% Click Events
    click WebClient "https://github.com/samshersingh1/logistics-supply-tracking/tree/main/fronted/src"
    click AuthContext "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/context/AuthContext.js"
    click ProtectedRoute "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/components/ProtectedRoute.js"
    click Navbar "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/components/Navbar.js"
    click HomePage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/HomePage.js"
    click LoginPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/LoginPage.js"
    click SignupPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/SignupPage.js"
    click ProfilePage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/ProfilePage.js"
    click AddProductPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/AddProductPage.js"
    click ProductsPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/ProductsPage.js"
    click OrdersPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/OrdersPage.js"
    click TransactionsPage "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/TransactionsPage.js"
    click DeliveryDashboard "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/fronted/src/pages/DeliveryDashboard.js"
    click API "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/index.js"
    click Router "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/route.js"
    click AuthController "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/controllers/authController.js"
    click AuthRoutes "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/routes/AuthRoutes.js"
    click AuthMiddleware "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/middleware/authMiddleware.js"
    click OrderController "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/controllers/orderController.js"
    click OrderRoutes "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/routes/orderRoutes.js"
    click ProductController "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/controllers/productController.js"
    click ProductRoutes "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/routes/productRoutes.js"
    click AsyncHandling "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/utils/AsyncHandling.js"
    click UploadMiddleware "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/middleware/uploadMiddleware.js"
    click CloudConfig "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/config/connectCloudnery.js"
    click CloudinaryConfig "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/utils/CloudinaryConfig.js"
    click DBConfig "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/config/db.js"
    click UserModel "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/models/User.js"
    click OrderModel "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/models/Order.js"
    click ProductModel "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/models/Product.js"
    click ResponseHandling "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/utils/ResponseHandling.js"
    click ErrorHandling "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/middleware/errorHandlingMiddleware.js"
    click LoggerUtil "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/utils/logger.js"
    click LogFiles "https://github.com/samshersingh1/logistics-supply-tracking/blob/main/Backend/logs/combined.log"
```
