How anupamgupt/e-commerce_frontend works
Project Type and Purpose
• This is a single-page application (SPA) front-end only, bootstrapped with Create React App.
• It implements an e-commerce UI: home, product listing, single product, cart, login, register pages.
• All business data currently comes from a local Data.js module (no custom back-end in this repo).
File Structure
• Top level:
• public/: static assets (index.html, manifest.json, robots.txt)
• src/: React source code
– components/: reusable UI components (Navbar, Slider, Products, etc.)
– pages/: page-level components (Home, ProductList, SingleProduct, Cart, Login, Register)
– Data.js: hard-coded product/category dataset
– index.js: ReactDOM entry point
• No “backend” directory—this repository is purely client-side.
README
• Confirms CRA setup, dev/build scripts, and the Netlify deployment URL.
• No mention of a server API, so assume static hosting (Netlify) serving the built bundle.
Main Components
a. Client (Web Browser)
b. Static Hosting (Netlify or equivalent CDN)
c. React App Entry Point (index.html → index.js)
d. React Router (routing layer switching between pages)
e. Pages Layer (Home, ProductList, SingleProduct, Cart, Login, Register)
f. Shared Components Layer (Navbar, Slider, Products, Categories, Footer, Newsletter, etc.)
g. Data Layer (Data.js — local JSON-like data source)
h. Browser Storage (e.g., localStorage for Cart)
i. External Services (optional: payment gateway, authentication provider—if integrated later)
Relationships and Interactions
• User interacts via Browser UI → triggers React Router to load a Page component.
• Page component imports and orchestrates one or more Shared Components.
• Shared Components retrieve data from:
• Data.js (static dataset)
• Browser Storage (e.g., cart contents)
• Data flows top-down via props from Pages to Components.
• User actions (add to cart, navigate) update state or localStorage and may trigger re-render.
Architectural Patterns & Design Principles
• Component-Based Architecture: small, reusable UI units.
• Feature/Route-Based Folder Structure: pages vs. generic components.
• Unidirectional Data Flow: props from parent to child; state managed by page or component.
• SPA Routing: client-side routing with React Router.