# minhdang0000/fashion-project architecture

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

- Interactive diagram: https://gitdiagram.com/minhdang0000/fashion-project
- Repository: https://github.com/minhdang0000/fashion-project

## Overview

##### Main components
- Admin Dashboard: Located under the “admin” directory. This part includes React components (e.g., Login, Navbar, Sidebar) and pages for managing products, orders, brands, suppliers, etc. It is likely used by the site administrators to manage inventory, orders, and other key aspects.
- Frontend (Customer Website): Found under the “frontend” directory. It uses React (with Vite, TailwindCSS, etc.) components and pages meant for regular users. Pages such as Home, Product, Cart, and Order indicate typical e-commerce functionality.
- Backend (API Server): In the “backend” folder you see Node.js-based backend code, including controllers, models, routes, middleware, and configuration files for MongoDB and Cloudinary. This part is responsible for the application’s business logic, database interactions, authentication, and serving data to the frontend and possibly the admin dashboard.
- Database & External Services: Although not explicitly named in the file tree, the “backend/config/mongodb.js” and “cloudinary.js” files imply that a MongoDB database and Cloudinary (for image storage) are integrated.

##### Architectural patterns and design principles
- Separation of concerns: The project clearly splits the client-side (admin vs. customer interfaces) from the server-side logic.
- MVC Pattern (or similar): The “backend” is organized into controllers, models, and routes, which follows a common pattern for Node/Express applications.
- API-first communication: Both client applications (admin and frontend) consume REST API endpoints provided by the backend.
- State management: The “frontend/src/context/ShopContext.jsx” suggests that a React context is used to manage application state (especially for shopping cart or user session data).

##### Detailed component breakdown
- Admin Dashboard:
- Components: Login, Navbar, Sidebar.
- Pages: Add, Brands, Invoices, List, Orders, SellStatistics, Suppliers.
- Technologies: React, Vite, TailwindCSS.
- Customer Frontend:
- Components: BestSeller, CartTotal, Footer, Hero, LatestCollection, Navbar, NewsletterBox, etc.
- Pages: Home, About, Cart, Collection, Contact, Login, Orders, Place Order, Product, Verify.
- Additional: Uses ShopContext for state management.
- Backend API:
- Controllers: Manage requests for cart, orders, products, and users.
- Models: Represent the schema for orders, products, and users.
- Routes: Provide endpoints for the various functionalities.
- Middleware: Includes authorization and file upload handling via multer.
- Configurations: Setup for MongoDB and Cloudinary.
- Technologies: Node.js, Express, MongoDB, and integration with external services.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client Applications
    subgraph "Admin Dashboard"
        AD["React Admin Dashboard"]:::client
        subgraph "Components"
            AD_C1["Login"]:::component
            AD_C2["Navbar"]:::component
            AD_C3["Sidebar"]:::component
        end
        subgraph "Pages"
            AD_P1["Add"]:::page
            AD_P2["Brands"]:::page
            AD_P3["Invoices"]:::page
            AD_P4["List"]:::page
            AD_P5["Orders"]:::page
            AD_P6["SellStatistics"]:::page
            AD_P7["Suppliers"]:::page
        end
    end

    subgraph "Customer Frontend"
        CF["React Customer Frontend"]:::client
        subgraph "Components"
            CF_C1["BestSeller"]:::component
            CF_C2["CartTotal"]:::component
            CF_C3["Footer"]:::component
            CF_C4["Hero"]:::component
            CF_C5["LatestCollection"]:::component
            CF_C6["Navbar"]:::component
            CF_C7["NewsletterBox"]:::component
        end
        subgraph "Pages"
            CF_P1["Home"]:::page
            CF_P2["About"]:::page
            CF_P3["Cart"]:::page
            CF_P4["Collection"]:::page
            CF_P5["Contact"]:::page
            CF_P6["Login"]:::page
            CF_P7["Orders"]:::page
            CF_P8["PlaceOrder"]:::page
            CF_P9["Product"]:::page
            CF_P10["Verify"]:::page
        end
        CF_Context["Shop Context"]:::component
    end

    %% Backend API
    subgraph "Backend API"
        BE["Express Backend API"]:::server
        subgraph "Controllers"
            BC1["CartController"]:::backend
            BC2["OrderController"]:::backend
            BC3["ProductController"]:::backend
            BC4["UserController"]:::backend
        end
        subgraph "Models"
            BM1["OrderModel"]:::backend
            BM2["ProductModel"]:::backend
            BM3["UserModel"]:::backend
        end
        subgraph "Routes"
            BR1["CartRoute"]:::backend
            BR2["OrderRoute"]:::backend
            BR3["ProductRoute"]:::backend
            BR4["UserRoute"]:::backend
        end
        subgraph "Middleware"
            BMW1["adminAuth"]:::backend
            BMW2["auth"]:::backend
            BMW3["multer"]:::backend
        end
        subgraph "Configurations"
            BCNF1["MongoDB Config"]:::backend
            BCNF2["Cloudinary Config"]:::backend
        end
        BE_ENTRY["Server.js"]:::backend
    end

    %% External Services
    subgraph "External Services"
        DBS["MongoDB Database"]:::db
        CLS["Cloudinary Service"]:::ext
    end

    %% Connections
    AD -->|"RESTAPICalls"| BE
    CF -->|"RESTAPICalls"| BE
    BE -->|"DBOperations"| DBS
    BE -->|"MediaUploads"| CLS

    %% Click Events - Admin Dashboard
    click AD "https://github.com/minhdang0000/fashion-project/tree/main/admin/"
    click AD_C1 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/components/Login.jsx"
    click AD_C2 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/components/Navbar.jsx"
    click AD_C3 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/components/Sidebar.jsx"
    click AD_P1 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/Add.jsx"
    click AD_P2 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/Brands.jsx"
    click AD_P3 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/Invoices.jsx"
    click AD_P4 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/List.jsx"
    click AD_P5 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/Orders.jsx"
    click AD_P6 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/SellStatistics.jsx"
    click AD_P7 "https://github.com/minhdang0000/fashion-project/blob/main/admin/src/pages/Suppliers.jsx"

    %% Click Events - Customer Frontend
    click CF "https://github.com/minhdang0000/fashion-project/tree/main/frontend/"
    click CF_C1 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/BestSeller.jsx"
    click CF_C2 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/CartTotal.jsx"
    click CF_C3 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/Footer.jsx"
    click CF_C4 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/Hero.jsx"
    click CF_C5 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/LatestCollection.jsx"
    click CF_C6 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/Navbar.jsx"
    click CF_C7 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/components/NewsletterBox.jsx"
    click CF_P1 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Home.jsx"
    click CF_P2 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/About.jsx"
    click CF_P3 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Cart.jsx"
    click CF_P4 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Collection.jsx"
    click CF_P5 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Contact.jsx"
    click CF_P6 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Login.jsx"
    click CF_P7 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Orders.jsx"
    click CF_P8 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/PlaceOrder.jsx"
    click CF_P9 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Product.jsx"
    click CF_P10 "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/pages/Verify.jsx"
    click CF_Context "https://github.com/minhdang0000/fashion-project/blob/main/frontend/src/context/ShopContext.jsx"

    %% Click Events - Backend API
    click BE "https://github.com/minhdang0000/fashion-project/tree/main/backend/"
    click BC1 "https://github.com/minhdang0000/fashion-project/blob/main/backend/controllers/cartController.js"
    click BC2 "https://github.com/minhdang0000/fashion-project/blob/main/backend/controllers/orderController.js"
    click BC3 "https://github.com/minhdang0000/fashion-project/blob/main/backend/controllers/productController.js"
    click BC4 "https://github.com/minhdang0000/fashion-project/blob/main/backend/controllers/userController.js"
    click BM1 "https://github.com/minhdang0000/fashion-project/blob/main/backend/models/orderModel.js"
    click BM2 "https://github.com/minhdang0000/fashion-project/blob/main/backend/models/productModel.js"
    click BM3 "https://github.com/minhdang0000/fashion-project/blob/main/backend/models/userModel.js"
    click BR1 "https://github.com/minhdang0000/fashion-project/blob/main/backend/routes/cartRoute.js"
    click BR2 "https://github.com/minhdang0000/fashion-project/blob/main/backend/routes/orderRoute.js"
    click BR3 "https://github.com/minhdang0000/fashion-project/blob/main/backend/routes/productRoute.js"
    click BR4 "https://github.com/minhdang0000/fashion-project/blob/main/backend/routes/userRoute.js"
    click BMW1 "https://github.com/minhdang0000/fashion-project/blob/main/backend/middleware/adminAuth.js"
    click BMW2 "https://github.com/minhdang0000/fashion-project/blob/main/backend/middleware/auth.js"
    click BMW3 "https://github.com/minhdang0000/fashion-project/blob/main/backend/middleware/multer.js"
    click BCNF1 "https://github.com/minhdang0000/fashion-project/blob/main/backend/config/mongodb.js"
    click BCNF2 "https://github.com/minhdang0000/fashion-project/blob/main/backend/config/cloudinary.js"
    click BE_ENTRY "https://github.com/minhdang0000/fashion-project/blob/main/backend/server.js"

    %% Class Definitions for Styles
    classDef client fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef component fill:#D1F2EB,stroke:#117864,stroke-width:2px;
    classDef page fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef server fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef backend fill:#FAD7A0,stroke:#BA4A00,stroke-width:2px;
    classDef db fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
    classDef ext fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;
```
