# codersoumya007/perfume-shop architecture

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

- Interactive diagram: https://gitdiagram.com/codersoumya007/perfume-shop
- Repository: https://github.com/codersoumya007/perfume-shop

## Overview

##### Project Type and Purpose
- The project is an e-commerce website (specifically for perfumes) with a clear separation between the back end and front end.
- Its purpose is to offer product listings, reviews, and likely shopping functionalities.
- The back end manages data through controllers, services, models, and routes while the front end provides the user interface built with React (given files such as App.jsx, main.jsx, and the use of Vite and Tailwind CSS).

##### Key Components Identified from the File Tree
a. BackEnd:
- Server Setup:
- server.js – likely initializes the Express server.
- vercel.json – indicates deployment configuration.
- Configurations:
- Configs/db.js – sets up the database connection.
- Controllers:
- Controllers for products (productController.js) and reviews (reviewController.js).
- Models:
- Data models for Products and Reviews.
- Routes:
- API routing definitions (ProductRoutes.js and ReviewRoutes.js).
- Services:
- Business logic layer (ProductService.js and ReviewService.js) handling interactions between controllers and models.
- Utility Functions:
- asyncHandler.js – utility for managing async operations and error handling.
b. FrontEnd:
- Application Layout and Components:
- Main React file (App.jsx) and entry point (main.jsx).
- Various components for the homepage, navigation bar, product cards, and product detail page.
- Styling and Configuration:
- Tailwind (tailwind.config.js) and Vite (vite.config.js) configurations.
- Public assets (images, thumbnails) and static assets (index.html).

##### Relationships and Interactions
- The Client (browser user) interacts with the FrontEnd, which is built with React. It communicates with the BackEnd via HTTP calls (likely RESTful APIs).
- The BackEnd provides endpoints (defined in the Routes directory) that execute controller logic.
- Controllers make use of service functions to process requests and interact with databases through Models.
- The Configs/db.js represents the database configuration component, even if the actual database isn’t visible in the file tree.
- Utility functions (asyncHandler.js) support error handling across asynchronous code execution.
- Deployment and environment-specific configuration are handled via files like vercel.json and package management files.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between the front end and back end.
- MVC-Like Pattern: In the BackEnd, Controllers manage API requests, Models represent data, and Services encapsulate business logic.
- Component-Based UI: The FrontEnd is structured around reusable React components.
- Emphasis on maintainability and scalability through clear directory separation and configuration management.

- On the FrontEnd side, show the user interface components with a boundary indicating “React Components” and highlight the use of Tailwind CSS for styling.
- An external element for the database (even if abstract) connected to models.
- Optionally, note deployment aspects (like Vercel) in a separate corner.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (Browser)"]:::frontend

    subgraph "FrontEnd (React/Vite Application)"
        FE1["Main Application (App.jsx)"]:::frontend
        FE2["Entry Point (main.jsx)"]:::frontend
        subgraph "UI Components"
            FE3["HomePage"]:::frontend
            FE4["Navbar"]:::frontend
            FE5["ProductCard"]:::frontend
            FE6["Product Page"]:::frontend
        end
        FE7["Tailwind CSS Config"]:::config
        FE8["Vite Config"]:::config
        FE9["HTML Template (index.html)"]:::config
    end

    subgraph "BackEnd (Express Server)"
        BE1["Server Setup (server.js)"]:::backend
        BE2["Deployment Config (vercel.json)"]:::backend
        BE3["Database Configuration (db.js)"]:::config

        subgraph "Controllers"
            BE4["Product Controller"]:::backend
            BE5["Review Controller"]:::backend
        end

        subgraph "Routes"
            BE6["Product Routes"]:::backend
            BE7["Review Routes"]:::backend
        end

        subgraph "Services"
            BE8["Product Service"]:::backend
            BE9["Review Service"]:::backend
        end

        subgraph "Models"
            BE10["Product Model"]:::db
            BE11["Review Model"]:::db
        end

        BE12["Utility (asyncHandler.js)"]:::backend
    end

    %% Relationships
    Client -->|"loads"| FE1
    FE1 -->|"initializes"| FE2
    FE1 -->|"renders"| FE3
    FE1 -->|"renders"| FE4
    FE1 -->|"renders"| FE5
    FE1 -->|"renders"| FE6
    FE1 -->|"uses"| FE7
    FE1 -->|"uses"| FE8
    FE1 -->|"renders"| FE9
    FE1 -->|"API-call"| BE6
    FE1 -->|"API-call"| BE7

    BE1 -->|"configures"| BE2
    BE6 -->|"routes"| BE4
    BE7 -->|"routes"| BE5
    BE4 -->|"calls"| BE8
    BE5 -->|"calls"| BE9
    BE8 -->|"invokes"| BE10
    BE9 -->|"invokes"| BE11
    BE10 -->|"connects"| BE3
    BE11 -->|"connects"| BE3
    BE4 -->|"uses"| BE12
    BE5 -->|"uses"| BE12

    %% Styles
    classDef frontend fill:#b3e5fc,stroke:#0277bd,stroke-width:2px;
    classDef backend fill:#ffcdd2,stroke:#c62828,stroke-width:2px;
    classDef config fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef db fill:#dcedc8,stroke:#558b2f,stroke-width:2px;

    %% Click Events
    click BE1 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/server.js"
    click BE2 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/vercel.json"
    click BE3 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Configs/db.js"
    click BE4 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Controllers/productController.js"
    click BE5 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Controllers/reviewController.js"
    click BE6 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Routes/ProductRoutes.js"
    click BE7 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Routes/ReviewRoutes.js"
    click BE8 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Services/ProductService.js"
    click BE9 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Services/ReviewService.js"
    click BE10 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Models/Products.js"
    click BE11 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/Models/Reviews.js"
    click BE12 "https://github.com/codersoumya007/perfume-shop/blob/main/BackEnd/utils/asyncHandler.js"
    click FE1 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/App.jsx"
    click FE2 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/main.jsx"
    click FE3 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/Components/HomePage.jsx"
    click FE4 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/Components/Navbar.jsx"
    click FE5 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/Components/ProductCard.jsx"
    click FE6 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/src/Components/ProductPage.jsx"
    click FE7 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/tailwind.config.js"
    click FE8 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/vite.config.js"
    click FE9 "https://github.com/codersoumya007/perfume-shop/blob/main/FrontEnd/index.html"
```
