# mhnipu/smart-shopper-galaxy architecture

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

- Interactive diagram: https://gitdiagram.com/mhnipu/smart-shopper-galaxy
- Repository: https://github.com/mhnipu/smart-shopper-galaxy

## Overview

##### Main Components
- Entry Point & Bootstrapping – Represent index.html and main.tsx as the starting block where the application is loaded and bootstrapped.
- Application Shell – Illustrate App.tsx as the main wrapper that configures routes, layouts, and context providers.
- UI Layout and Navigation – Include layout components (Navbar, Footer, UserMenu, etc.) showing the overall site structure.
- Domain-Specific Modules – Group components by functionalities:
▪ Home: Components like Hero, FeaturedProducts, CategorySection, NewsletterSignup, etc.
▪ Product: Elements such as ProductCard, ProductInfo, ProductOptions, ProductReviews, and others.
▪ Cart/Checkout: Components handling cart functionality and checkout (CartDrawer, PaymentMethodSelector).
▪ Chat & Search: Components for interactive features (ChatBot, ImageSearch, SmartSearch).
- Context Providers – Identify modules under src/context (AuthContext, CartContext, CurrencyContext, ThemeContext, WishlistContext) that manage global state.
- Utility & Hook Layers – Note the existence of custom hooks (e.g., use-mobile, use-toast) and utility functions (in src/lib and src/components/util) that support app logic.

##### Relationships & Interactions
- Component Hierarchy: Visually differentiate that pages (in src/pages) are composed of the modular UI components (found in src/components). For example, the ProductDetail page composes ProductCard, ProductImageGallery, ProductInfo, etc.
- Data & Event Flow: Mark how actions (like adding an item to the cart) move from UI components through context and hooks to update the global state.

##### Architectural Patterns & Design Principles
- Component-Based Design: Highlight the separation into reusable UI components (organized into domain-specific folders e.g., home, product, checkout).
- Separation of Concerns: Note the distinct responsibilities (Pages handling routes, Components handling UI, Context managing state, Hooks and Lib for logic/utilities).
- Responsive and Thematic Design: Indicate the role of Tailwind CSS and shadcn‑ui in styling, with ThemeToggle in the UI components.
- Single Page Application (SPA): Emphasize that routing is client‑side (React Router likely in use), with dedicated pages for various routes.

##### Technologies and Frameworks
- Vite – For rapid development and building the app.
- React & TypeScript – Core framework and language ensuring type safety.
- shadcn‑ui & Tailwind CSS – For UI components and styling.
- Node.js & npm – As part of the build and development environment (evidenced by package.json, package-lock.json, bun.lockb).

## Diagram (Mermaid)

```mermaid
graph TD
    ep["Entry Point: index.html"]:::entry
    bt["Bootstrapping: main.tsx"]:::entry
    app["Application Shell: App.tsx"]:::shell

    ep --> bt
    bt --> app

    %% UI Layout and Navigation Subgraph
    subgraph "UI Layout and Navigation"
        navbar["Navbar"]:::layout
        footer["Footer"]:::layout
        usermenu["UserMenu"]:::layout
    end

    %% Domain-Specific Modules
    subgraph "Domain-Specific Modules"
        %% Home Module
        subgraph "Home Module"
            hero["Hero"]:::module
            featured["FeaturedProducts"]:::module
            category["CategorySection"]:::module
            newsletter["NewsletterSignup"]:::module
        end
        %% Product Module
        subgraph "Product Module"
            productCard["ProductCard"]:::module
            productGallery["ProductImageGallery"]:::module
            productInfo["ProductInfo"]:::module
            productOptions["ProductOptions"]:::module
            productReviews["ProductReviews"]:::module
            productOthers["Other Product Components"]:::module
        end
        %% Cart/Checkout Module
        subgraph "Cart/Checkout Module"
            cartDrawer["CartDrawer"]:::module
            paymentSelector["PaymentMethodSelector"]:::module
            checkoutPage["Checkout Page"]:::module
            orderConfirmation["OrderConfirmation Page"]:::module
            wishlistPage["Wishlist Page"]:::module
        end
        %% Chat & Search Module
        subgraph "Chat & Search Module"
            chatBot["ChatBot"]:::module
            smartSearch["SmartSearch"]:::module
            imageSearch["ImageSearch"]:::module
        end
    end

    %% Context Providers Subgraph
    subgraph "Context Providers"
        authCtx["AuthContext"]:::context
        cartCtx["CartContext"]:::context
        currencyCtx["CurrencyContext"]:::context
        themeCtx["ThemeContext"]:::context
        wishlistCtx["WishlistContext"]:::context
    end

    %% Utility & Hooks Subgraph
    subgraph "Utility & Hooks"
        subgraph "Custom Hooks"
            useMobile["use-mobile"]:::util
            useToast["use-toast"]:::util
        end
        subgraph "Utility Functions"
            dataTs["data.ts"]:::util
            utilsTs["utils.ts"]:::util
            formatPrice["FormatPrice"]:::util
            scrollToTop["ScrollToTop"]:::util
        end
    end

    %% Connections from Application Shell to various layers
    app --> navbar
    app --> footer
    app --> usermenu
    app --> hero
    app --> productCard
    app --> cartDrawer
    app --> chatBot
    app --> authCtx
    app --> useMobile

    %% Additional relationship arrows
    navbar -->|"triggers"| authCtx
    productCard -->|"updates"| cartCtx
    cartDrawer -->|"updates"| cartCtx
    usermenu -->|"uses"| authCtx

    %% Class definitions for colors
    classDef entry fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef shell fill:#c0e0de,stroke:#008080,stroke-width:2px;
    classDef layout fill:#d0f0c0,stroke:#006400,stroke-width:2px;
    classDef module fill:#f0e68c,stroke:#daa520,stroke-width:2px;
    classDef context fill:#e6e6fa,stroke:#8a2be2,stroke-width:2px;
    classDef util fill:#ffe4e1,stroke:#ff1493,stroke-width:2px;

click ep "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/index.html"
click bt "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/main.tsx"
click app "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/App.tsx"

click navbar "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/layout/Navbar.tsx"
click footer "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/layout/Footer.tsx"
click usermenu "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/layout/UserMenu.tsx"

click hero "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/home/Hero.tsx"
click featured "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/home/FeaturedProducts.tsx"
click category "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/home/CategorySection.tsx"
click newsletter "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/home/NewsletterSignup.tsx"

click productCard "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/product/ProductCard.tsx"
click productGallery "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/product/ProductImageGallery.tsx"
click productInfo "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/product/ProductInfo.tsx"
click productOptions "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/product/ProductOptions.tsx"
click productReviews "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/product/ProductReviews.tsx"

click cartDrawer "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/cart/CartDrawer.tsx"
click paymentSelector "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/checkout/PaymentMethodSelector.tsx"
click checkoutPage "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/pages/Checkout.tsx"
click orderConfirmation "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/pages/OrderConfirmation.tsx"
click wishlistPage "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/pages/WishlistPage.tsx"

click chatBot "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/chat/ChatBot.tsx"
click smartSearch "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/search/SmartSearch.tsx"
click imageSearch "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/search/ImageSearch.tsx"

click authCtx "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/context/AuthContext.tsx"
click cartCtx "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/context/CartContext.tsx"
click currencyCtx "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/context/CurrencyContext.tsx"
click themeCtx "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/context/ThemeContext.tsx"
click wishlistCtx "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/context/WishlistContext.tsx"

click useMobile "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/hooks/use-mobile.tsx"
click useToast "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/hooks/use-toast.ts"
click dataTs "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/lib/data.ts"
click utilsTs "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/lib/utils.ts"
click formatPrice "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/util/FormatPrice.tsx"
click scrollToTop "https://github.com/mhnipu/smart-shopper-galaxy/blob/main/src/components/util/ScrollToTop.tsx"
```
