# vuanh1810/e-commerce-website architecture

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

- Interactive diagram: https://gitdiagram.com/vuanh1810/e-commerce-website
- Repository: https://github.com/vuanh1810/e-commerce-website

## Overview

##### Project type and purpose
- This is a front-end-only e-commerce demo website built with static HTML pages, CSS styling, and vanilla JavaScript.
- The README describes a multi-page site (login, home, products, shopping) with client-side features: authentication, product toggles, search, cart management, and credit-card validation.

##### File structure
- Top level: five HTML pages (1login.html, 2welcome.html, 3dogs.html, 4cats.html, 5shopping.html) plus README and .gitignore.
- Directories:
- css/ — contains two stylesheets (1style-login.css for the login page, styles.css for the rest)
- js/ — contains two scripts (1main-login.js for login logic, main.js for site functionality)
- No backend code or server-side framework—this points to a purely client-rendered site served as static assets.

##### README for additional insights
- Pages: Login, Home (welcome), Dogs products, Cats products, Shopping cart.
- Features:
- Login form + validation (js/1main-login.js)
- More/less product details (main.js)
- Search bar filtering (main.js)
- /remove items in cart (main.js)
- Credit-card info validation (main.js)
- Cart contents (main.js)

a. Main components
- Client Web Browser (User Agent)
- Static Web Server / CDN (serves HTML, CSS, JS, images)
- Client-side Modules:
– Login Module (1login.html + 1style-login.css + 1main-login.js)
– Catalog Module (welcome, dogs, cats pages + styles.css + main.js)
– Cart Module (shopping page + styles.css + main.js)
– Shared Assets (img/, css/styles.css, js/main.js)
- External Services (optional—but implied for real-world deployment):
– Auth service (or localStorage/sessionStorage for demo)
– Payment Gateway API (for credit-card validation)
b. Relationships & data flow
- Browser requests HTML/CSS/JS from Static Server via HTTP(S).
- User interacts with login form → client-side script validates and stores token/session.
- Navigation between pages → browser fetches new HTML + shared CSS/JS from server or cache.
- Catalog pages invoke JavaScript to filter/search products (in-memory data or JSON).
- “Add to cart” actions update a client-side cart object (in memory, localStorage).
- “Checkout” invokes payment-gateway API over HTTPS.
c. Architectural patterns & design principles
- Separation of concerns: HTML for structure, CSS for style, JS for behavior.
- Modular JS: separate login script vs. main site script.
- Client-only MVC/Presentation logic—no server business logic.
d. Key technologies
- HTML5, CSS3, vanilla JavaScript (ES6)
- Static hosting (e.g., GitHub Pages, Netlify, Apache/Nginx + CDN)
- Optional: localStorage/sessionStorage, Fetch API for external calls

##### Elements
– Labels for each component (Browser, Static Server, Login Module, Catalog Module, Cart Module, Auth Service, Payment Gateway)
- HTTP GET/HTTP(S) from Browser → Static Server
- Event/Function calls inside Browser (UI → JS modules → localStorage)
- HTTPS POST from Browser → Payment Gateway API
- Orange cloud for external services (Auth, Payment)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Client Browser Container
    subgraph "Client Browser" 
        direction TB
        BrowserUI["Browser UI"]:::browser

        subgraph "Login Module" 
            direction TB
            LoginHTML["1login.html"]:::frontend
            LoginCSS["css/1style-login.css"]:::frontend
            LoginJS["js/1main-login.js"]:::frontend
        end

        subgraph "Catalog Module"
            direction TB
            WelcomeHTML["2welcome.html"]:::frontend
            DogsHTML["3dogs.html"]:::frontend
            CatsHTML["4cats.html"]:::frontend
            CatalogCSS["css/styles.css"]:::frontend
            CatalogJS["js/main.js"]:::frontend
        end

        subgraph "Cart Module"
            direction TB
            CartHTML["5shopping.html"]:::frontend
            CartCSS["css/styles.css"]:::frontend
            CartJS["js/main.js"]:::frontend
        end

        subgraph "Shared Assets" 
            direction TB
            Images["img/"]:::frontend
            SharedCSS["css/styles.css"]:::frontend
            SharedJS["js/main.js"]:::frontend
        end

        LocalStorage[(localStorage)]:::datastore
    end

    %% Static Server
    Server[(Static Web Server / CDN)]:::server

    %% External Services
    subgraph "External Services"
        direction TB
        AuthService(("Auth Service")):::cloud
        PaymentGateway(("Payment Gateway API")):::cloud
    end

    %% Data Flows
    BrowserUI -->|HTTP GET HTML/CSS/JS| Server
    Server -->|Serves static files| BrowserUI

    BrowserUI -->|User submits login| LoginHTML
    LoginHTML -->|loads JS| LoginJS
    LoginJS -->|"validate credentials"| LocalStorage

    BrowserUI -->|Navigate pages| WelcomeHTML
    WelcomeHTML -->|loads CSS/JS| CatalogCSS
    WelcomeHTML -->|loads CSS/JS| CatalogJS
    DogsHTML -->|loads CSS/JS| CatalogCSS
    DogsHTML -->|loads CSS/JS| CatalogJS
    CatsHTML -->|loads CSS/JS| CatalogCSS
    CatsHTML -->|loads CSS/JS| CatalogJS

    BrowserUI -->|Open cart| CartHTML
    CartHTML -->|loads CSS/JS| CartCSS
    CartHTML -->|loads CSS/JS| CartJS
    CartJS -->|"update cart"| LocalStorage

    CartJS -->|HTTPS POST checkout| PaymentGateway

    %% Click Events for Component Mapping
    click LoginHTML "https://github.com/vuanh1810/e-commerce-website/blob/main/1login.html"
    click LoginCSS "https://github.com/vuanh1810/e-commerce-website/blob/main/css/1style-login.css"
    click LoginJS "https://github.com/vuanh1810/e-commerce-website/blob/main/js/1main-login.js"
    click WelcomeHTML "https://github.com/vuanh1810/e-commerce-website/blob/main/2welcome.html"
    click DogsHTML "https://github.com/vuanh1810/e-commerce-website/blob/main/3dogs.html"
    click CatsHTML "https://github.com/vuanh1810/e-commerce-website/blob/main/4cats.html"
    click CartHTML "https://github.com/vuanh1810/e-commerce-website/blob/main/5shopping.html"
    click CatalogCSS "https://github.com/vuanh1810/e-commerce-website/blob/main/css/styles.css"
    click CartCSS "https://github.com/vuanh1810/e-commerce-website/blob/main/css/styles.css"
    click CatalogJS "https://github.com/vuanh1810/e-commerce-website/blob/main/js/main.js"
    click CartJS "https://github.com/vuanh1810/e-commerce-website/blob/main/js/main.js"
    click Images "https://github.com/vuanh1810/e-commerce-website/tree/main/img/"
    click SharedCSS "https://github.com/vuanh1810/e-commerce-website/blob/main/css/styles.css"
    click SharedJS "https://github.com/vuanh1810/e-commerce-website/blob/main/js/main.js"

    %% Styles
    classDef frontend fill:#B3CDE3,stroke:#333;
    classDef server fill:#C7E9B4,stroke:#333;
    classDef cloud fill:#FBB4AE,stroke:#333;
    classDef browser fill:#DECBE4,stroke:#333;
    classDef datastore fill:#FED9A6,stroke:#333;
```
