# kanchan191184/e-shop-website architecture

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

- Interactive diagram: https://gitdiagram.com/kanchan191184/e-shop-website
- Repository: https://github.com/kanchan191184/e-shop-website

## Overview

##### Project type and purpose
- This is a full-stack e-commerce “e-cShop” web application built with a React (Vite) frontend, backed by Firebase/Firestore for data storage and a lightweight Node.js server for Stripe payment processing.
- Purpose: Display product catalog, allow browsing, “favorite” toggling, cart management, and handle checkout via Stripe, all backed by a real-time Firestore database.

##### File structure
- Top-level:
- public, index.html – static assets and HTML entry
- src – React application code
- server – Node.js/Express endpoint for Stripe payments
- config, hooks, services, context – client-side configuration (Firebase), custom React hooks, API wrapper functions, global state
- package.json, vite.config.js – client dependencies and build config
- .env-sample, README.md – environment variables and setup guide
- Patterns:
- Component-based React (pages vs. reusable components)
- Context API for cart state management
- Service layer (src/services) abstracts Firestore queries
- SCSS modules for scoped styling

##### README for additional insights
- Firebase used for all product data (CRUD via Firestore SDK).
- Stripe secret key in server/.env for payment endpoint.
- Two separate processes: `npm run dev` for client on 5173, `node server/server.js` for backend on 4242.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global entities
    Browser["Static Assets<br/>(public/, index.html)"]:::frontend

    %% Frontend Application
    subgraph "Frontend (React App)"
        direction TB
        Main["src/main.jsx"]:::frontend
        App["src/App.jsx"]:::frontend
        IndexSCSS["src/index.scss"]:::config
        AppSCSS["src/App.scss"]:::config

        subgraph "Pages"
            direction TB
            HomePage["HomePage"]:::frontend
            FeaturedPage["FeaturedPage"]:::frontend
            ProductListingPage["ProductListingPage"]:::frontend
            ProductDetailsPage["ProductDetailsPage"]:::frontend
            CartPage["CartPage"]:::frontend
            FavouritePage["FavouritePage"]:::frontend
        end

        subgraph "Components"
            direction TB
            NavBar["NavBar"]:::frontend
            Button["Button"]:::frontend
            CarouselBanner["CarouselBanner"]:::frontend
            ProductSection["ProductSection"]:::frontend
            ProductList["ProductList"]:::frontend
            ProductCard["ProductCard"]:::frontend
            ProductDescription["ProductDescription"]:::frontend
            CartWidget["Cart Widget"]:::frontend
        end

        subgraph "State & Services"
            direction TB
            CartContext["CartContext"]:::frontend
            FirestoreConfig["firestore.js"]:::config
            ProductServices["product-services.js"]:::backend
            UseQuery["useQuery.jsx"]:::frontend
        end

        subgraph "SCSS Partials"
            direction TB
            Partials["_colors.scss,_mixins.scss,_typography.scss"]:::config
        end
    end

    %% Backend Application
    subgraph "Backend (Node.js/Express)"
        direction TB
        Server["server.js"]:::backend
    end

    %% External Services
    StripeAPI["Stripe API"]:::external
    FirestoreDB["Firestore Database"]:::db

    %% Environment & Build Config
    subgraph "Env & Build"
        direction TB
        EnvSample[".env-sample"]:::config
        ViteConfig["vite.config.js"]:::config
        PackageJSON["package.json"]:::config
    end

    %% Connections
    Browser --> Main
    Main --> App
    App --> HomePage
    App --> FeaturedPage
    App --> ProductListingPage
    App --> ProductDetailsPage
    App --> CartPage
    App --> FavouritePage
    App --> NavBar
    App --> Button
    App --> CarouselBanner
    App --> ProductSection
    App --> ProductList
    App --> ProductCard
    App --> ProductDescription
    App --> CartWidget
    CartContext --> App
    App --> FirestoreDB
    FirestoreConfig --> App
    ProductServices --> FirestoreDB
    UseQuery --> ProductServices
    HomePage --> ProductServices
    FeaturedPage --> ProductServices
    ProductListingPage --> ProductServices
    ProductDetailsPage --> ProductServices
    CartPage --> ProductServices
    FavouritePage --> ProductServices
    App --> Server
    Server --> StripeAPI
    Server --> FirestoreDB

    %% Click Events
    click Browser "https://github.com/kanchan191184/e-shop-website/tree/main/public/"
    click Main "https://github.com/kanchan191184/e-shop-website/blob/main/src/main.jsx"
    click App "https://github.com/kanchan191184/e-shop-website/blob/main/src/App.jsx"
    click IndexSCSS "https://github.com/kanchan191184/e-shop-website/blob/main/src/index.scss"
    click AppSCSS "https://github.com/kanchan191184/e-shop-website/blob/main/src/App.scss"
    click HomePage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/HomePage"
    click FeaturedPage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/FeaturedPage"
    click ProductListingPage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/ProductPage"
    click ProductDetailsPage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/ProductDetailsPage"
    click CartPage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/CartPage"
    click FavouritePage "https://github.com/kanchan191184/e-shop-website/tree/main/src/pages/FavouritePage"
    click NavBar "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/NavBar"
    click Button "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/Button"
    click CarouselBanner "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/CarouselBanner"
    click ProductSection "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/ProductSection"
    click ProductList "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/ProductList"
    click ProductCard "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/ProductCard"
    click ProductDescription "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/ProductDescription"
    click CartWidget "https://github.com/kanchan191184/e-shop-website/tree/main/src/components/Cart"
    click CartContext "https://github.com/kanchan191184/e-shop-website/blob/main/src/context/CartContext.jsx"
    click FirestoreConfig "https://github.com/kanchan191184/e-shop-website/blob/main/src/config/firestore.js"
    click ProductServices "https://github.com/kanchan191184/e-shop-website/blob/main/src/services/product-services.js"
    click UseQuery "https://github.com/kanchan191184/e-shop-website/blob/main/src/hooks/useQuery.jsx"
    click Partials "https://github.com/kanchan191184/e-shop-website/tree/main/src/scss/partials"
    click Server "https://github.com/kanchan191184/e-shop-website/blob/main/server/server.js"
    click EnvSample "https://github.com/kanchan191184/e-shop-website/blob/main/.env-sample"
    click ViteConfig "https://github.com/kanchan191184/e-shop-website/blob/main/vite.config.js"
    click PackageJSON "https://github.com/kanchan191184/e-shop-website/blob/main/package.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0275d8,color:#000
    classDef backend fill:#FFE0B2,stroke:#FFB74D,color:#000
    classDef db fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef external fill:#E1BEE7,stroke:#9C27B0,color:#000
    classDef config fill:#F0F0F0,stroke:#999,color:#000
```
