How vuanh1810/e-commerce-website works
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)