How abidev2003/ecommerce-react-ssd works
1. This repository contains a full e-commerce application split into three main areas: a Node backend API, a current React/Vite frontend, and an older JavaScript frontend kept under old-projects/ as a legacy/reference copy.
2. The backend lives in ecommerce-backend-ai-main/backend and is organized around four core domain entities: products, cart items, delivery options, and orders. Those shapes are formalized in models/, with matching seed/default data in defaultData/.
3. The backend persistence model is file-based rather than database-backed. Runtime state is stored in JSON files such as products.json, cart.json, orders.json, and deliveryOptions.json, with reset support to restore the state from the default fixtures.
4. The backend API surface is split by resource under routes/: products, cartItems, deliveryOptions, orders, paymentSummary, and reset. This suggests a request flow where the client reads product/catalog data, mutates cart state, submits or reads orders, and asks the server to compute payment totals.
5. server.js is the backend entry point and likely wires the route modules together into a single HTTP service. The paymentSummary route is an important service boundary because it centralizes cart/order pricing logic instead of leaving it entirely in the UI.
6. The frontend in ecommerce-project is a TypeScript React app built with Vite. Its architecture is page-oriented: HomePage, CheckoutPage, OrdersPage, TrackingPage, and NotFoundPage represent the main user journeys, with App.tsx acting as the shell/router host.
7. UI composition on the frontend is layered. Shared structure is handled by Header, while feature-specific subcomponents live under the relevant page folders, especially the checkout area (CartItemDetails, DeliveryOptions, DeliveryDate, OrderSummery, PaymentSummery) and orders area (OrdersGrid, OrderHeader, OrderDetailGrid).
8. Data flow in the frontend is centered on commerce workflows: browse products on the home page, assemble a cart, choose a delivery option during checkout, view payment/order summaries, then navigate to order history and tracking views. The page and component names show that the UI mirrors the backend domain model closely.
9. Static assets are part of the delivery boundary for both apps. Product and rating images are stored under image folders in the backend and in the frontend’s public/images, indicating the app depends on image assets being served as static files rather than fetched from an external media service.
10. Shared business logic is minimal but explicit. The frontend has src/utils/money.ts for formatting/calculation helpers, while the backend owns the canonical data and summary computation. That separation keeps presentation concerns in the client and state/aggregation concerns on the server.
11. Testing is built into both layers. The frontend uses Vitest and component tests alongside the pages/components, while the backend includes supporting files and patches for its runtime dependencies. The presence of tests near each feature folder suggests the project is organized by feature slice rather than by technical layer alone.
12. The old-projects/ecommerce-project-js tree is a full earlier version of the frontend in plain JavaScript. It mirrors the current TypeScript app’s structure very closely, so it is best treated as legacy code or a migration checkpoint, not a separate runtime system.
13. Overall, the architecture is a two-tier commerce system: a file-backed REST API for catalog/cart/order state, and a client-side React application that renders the shopping flows and consumes that API. The most important diagram boundaries are client UI, backend service/routes, JSON persistence, and static asset storage.
Main entry points: server.js Server · App.tsx App Shell · orders.js Orders API · index.js Domain Models
Components 22
Backend API
Node service, route handlers, schema models, and file-backed persistence.
- Server · Bootstraps the backend and wires routes.
ecommerce-backend-ai-main/server.js - Products API · Catalog read endpoint.
ecommerce-backend-ai-main/routes/products.js - Cart API · Cart item state mutations and reads.
ecommerce-backend-ai-main/routes/cartItems.js - Delivery API · Delivery option catalog and selection flow.
ecommerce-backend-ai-main/routes/deliveryOptions.js - Orders API · Order creation and history endpoints.
ecommerce-backend-ai-main/routes/orders.js - Pricing API · Central payment and totals calculation boundary.
ecommerce-backend-ai-main/routes/paymentSummary.js - Reset API · Restores runtime state from fixtures.
ecommerce-backend-ai-main/routes/reset.js - Domain Models · Canonical shapes for products, cart items, delivery options, and orders.
ecommerce-backend-ai-main/models/index.js - Default Data · Seed data used to repopulate file state.
ecommerce-backend-ai-main/defaultData - JSON Store · Runtime persistence for catalog, cart, orders, and delivery data.
ecommerce-backend-ai-main/backend - Media Assets · Backend-served product and rating images.
ecommerce-backend-ai-main/images
React Frontend
Current TypeScript/Vite commerce UI and shared client utilities.
- App Shell · Client router and top-level composition.
ecommerce-project/src/App.tsx - Header · Global navigation and site chrome.
ecommerce-project/src/components/Header.tsx - Home Page · Browse products and add to cart.
ecommerce-project/src/pages/home/HomePage.jsx - Checkout Page · Cart review, delivery choice, and purchase summary.
ecommerce-project/src/pages/checkout/CheckoutPage.jsx - Orders Page · Order history and detail views.
ecommerce-project/src/pages/orders/OrdersPage.jsx - Aux Pages · Tracking and not-found routes.
ecommerce-project/src/pages/TrackingPage.jsx - Money Utils · Client-side formatting and money helpers.
ecommerce-project/src/utils/money.ts - Public Images · Frontend-served product and rating images.
ecommerce-project/public/images
Legacy Frontend
Older JavaScript version kept as a reference/migration checkpoint.
- Legacy App · Older JavaScript frontend entrypoint.
old-projects/ecommerce-project-js/src/App.jsx - Legacy Pages · Previous checkout, home, orders, and auxiliary views.
old-projects/ecommerce-project-js/src/pages - Legacy Money · Old formatting helper kept alongside the legacy app.
old-projects/ecommerce-project-js/src/utils/money.js
Connections 36
- Server → Products API: mounts · Server exposes the catalog endpoint.
- Server → Cart API: mounts · Server exposes cart state endpoints.
- Server → Delivery API: mounts · Server exposes delivery option endpoints.
- Server → Orders API: mounts · Server exposes order endpoints.
- Server → Pricing API: mounts · Server exposes pricing summary endpoints.
- Server → Reset API: mounts · Server exposes reset support.
- Server → Domain Models: uses · Request handlers rely on the canonical domain shapes.
- Server → JSON Store: persists · Server reads and writes the JSON-backed runtime state.
- Server → Default Data: seeds from · Reset flow restores state from fixtures.
- Products API → Domain Models: reads · Catalog responses are shaped by product models.
- Cart API → Domain Models: reads/writes · Cart items are validated against the domain model.
- Cart API → JSON Store: stores · Cart mutations are serialized to JSON files.
- Delivery API → Domain Models: reads · Delivery options follow the shared schema.
- Delivery API → JSON Store: stores · Delivery selection is kept in file state.
- Orders API → Domain Models: reads/writes · Orders are created from the shared order model.
- Orders API → JSON Store: stores · Orders are persisted in JSON.
- Pricing API → JSON Store: reads · Pricing uses the current cart/order state.
- Pricing API → Domain Models: uses · Totals are computed from domain entities.
- Reset API → Default Data: loads · Reset endpoint reloads fixture data.
- Reset API → JSON Store: overwrites · Reset endpoint restores runtime JSON files.
- App Shell → Header: composes · Global shell includes shared header chrome.
- App Shell → Home Page: routes to · One main journey is product browsing.
- App Shell → Checkout Page: routes to · One main journey is checkout.
- App Shell → Orders Page: routes to · One main journey is order history.
- App Shell → Aux Pages: routes to · Auxiliary navigation pages are hosted here.
- App Shell → Money Utils: uses · Shared money helpers support UI calculations.
- Home Page → Products API: fetches · Home page loads the catalog from the API.
- Home Page → Public Images: renders · Product imagery is served from local static assets.
- Checkout Page → Cart API: fetches · Checkout reads and updates cart state.
- Checkout Page → Delivery API: fetches · Checkout loads delivery choices.
- Checkout Page → Pricing API: fetches · Checkout displays pricing totals from the server.
- Checkout Page → Orders API: submits · Checkout completes the order workflow.
- Orders Page → Orders API: fetches · Orders page loads order history.
- Aux Pages → Orders API: fetches · Tracking views depend on order data.
- Legacy App → Legacy Pages: composes · Legacy shell hosts the older page set.
- Legacy App → Legacy Money: uses · Legacy UI uses the older money helper.