How hoangsonle/zenstore_fe works
1. This is a Create React App frontend for a commerce/catalog experience, not a backend service. The repo is organized as a single-page application with page-level routes, reusable UI sections, and an API layer that talks to external content/product endpoints.
2. The application entry path is src/index.js into src/App.js, with src/pages/layout/MainLayout.tsx acting as the main shell. That layout likely owns route composition, shared header/footer, and page chrome, while small helpers like RouteScrollToTop, Preloader, ColorInit, and PhosphorIconInit handle cross-cutting bootstrapping behavior.
3. The page layer is split by business area: homePage, products, blog, contact, and installment. Each page is assembled from many smaller sections rather than one monolith, which is important for the architecture diagram: pages are composition roots, not the source of business logic.
4. The component layer is heavily modular and domain-based. There are shared UI blocks for header, footer, breadcrumb, pagination, brand, promotional banners, sales, top-selling products, product details, cart/checkout, and blog. Many components have variants such as “One” and “Two”, indicating alternative layouts/themes rather than separate features.
5. Data access is isolated under src/apis. There is a shared Axios wrapper in src/apis/axios.ts and feature-specific modules for banner, blog, category, and product, each with interface files. This suggests the frontend consumes a REST-style backend or content API and maps responses through typed contracts.
6. The main data flow appears to be: route/page component mounts -> hook/API call -> typed API module -> UI component tree. src/hooks/useApi.ts and useAsyncEffect.ts are the main abstraction points for fetching and lifecycle-driven async work, while src/context/SearchContext.tsx provides shared search state across the header/product area.
7. The repo includes a set of utility and helper modules for UI behavior and data formatting. Examples include productUtils, numberUtils, and faviconUtils, plus helpers for animation, countdowns, quantity control, and scroll-to-top behavior. These are supporting pieces that keep presentational components thin.
8. Styling is split across two systems: extensive Sass sources under public/assets/sass plus compiled CSS in public/assets/css, and many component-scoped .css files under src/components. The Sass tree is organized into abstracts, components, layout, utilities, and page partials, which indicates a theme-driven storefront design system with home-page and “other page” variants.
9. Static assets and deployment are handled from public/. The public/assets tree contains images, icons, fonts, and prebuilt styles, while .htaccess, _redirects, and web.config indicate deployment to static hosts that need SPA route rewriting.
10. The architecture is frontend-only from this repository’s perspective: there is no server code here, only client rendering plus remote data fetching. External dependencies that materially affect structure are React, TypeScript mixed with JavaScript/JSX, Axios, and CSS/Sass-based theming.
11. Testing and validation are lightweight but present: CRA’s default App.test.js plus a focused unit test under src/__tests__/getActiveIndexFromPath.test.js. That suggests some route/navigation logic is important enough to test independently.
Main entry points: MainLayout.tsx Main Layout · axios.ts Axios Client · ProductDetails.tsx Product UI · ProductPage.tsx Products
Components 29
Entry & Shell
Application bootstrap and the main SPA chrome.
- index.js · Bootstraps the React app.
src/index.js - App · Top-level application component.
src/App.js - Main Layout · Main page shell and route composition boundary.
src/pages/layout/MainLayout.tsx - Scroll Top · Resets scroll position on navigation.
src/helper/RouteScrollToTop.tsx - Preloader · Initial loading state for the app shell.
src/helper/Preloader.tsx - Color Init · Initializes color/theme behavior.
src/helper/ColorInit.tsx - Icon Init · Initializes icon rendering.
src/helper/PhosphorIconInit.ts
Pages
Route-level composition roots for each business area.
- Home · Homepage composition root.
src/pages/homePage/HomePage.tsx - Products · Catalog and shop page root.
src/pages/products/ProductPage.tsx - Product Details · Product detail route root.
src/pages/products/ProductDetailsPage.tsx - Blog · Blog listing route root.
src/pages/blog/BlogPage.tsx - Blog Details · Blog article route root.
src/pages/blog/BlogDetailsPage.tsx - Contact · Contact page root.
src/pages/contact/ContactPage.jsx - Installment · Installment/payment info page root.
src/pages/installment/InstallmentPage.tsx
Components
Reusable UI families shared across pages.
- Header · Global navigation, search, and announcement area.
src/components/header/Header.tsx - Footer · Global footer and newsletter area.
src/components/footer/EnhancedFooter.tsx - Product UI · Product listing, details, filters, and cart/checkout widgets.
src/components/products/ProductDetails.tsx - Home Sections · Homepage marketing and merchandising sections.
src/components/FeaturedOne.jsx - Blog UI · Blog list and article presentation.
src/components/blog/Blog.tsx - Shared UI · Breadcrumbs, pagination, brand, and other reusable blocks.
src/components/breadcrumb/Breadcrumb.tsx
Data & State
Remote data access, hooks, and shared client state.
- Search Context · Cross-page search state shared by header and catalog views.
src/context/SearchContext.tsx - Fetch Hooks · Shared async and lifecycle fetching abstractions.
src/hooks/useApi.ts - Axios Client · Shared Axios wrapper for remote requests.
src/apis/axios.ts - Banner API · Banner and promotional content access.
src/apis/banner/banner.api.ts - Blog API · Blog data access layer.
src/apis/blog/blog.api.ts - Category API · Category and navigation data access.
src/apis/category/category.api.ts - Product API · Product and commerce data access.
src/apis/product/product.api.ts
Assets & Styling
Static host assets and theme/style sources.
- Theme Assets · Sass/CSS theme sources and compiled storefront assets.
public/assets/sass/main.scss - Public Host · SPA entry HTML, static assets, and redirect rules.
public/index.html
Connections 34
- index.js → App: bootstraps · React entry mounts the app root.
- App → Main Layout: renders · App delegates composition to the main shell.
- Main Layout → Scroll Top: uses · Layout applies navigation scroll reset.
- Main Layout → Preloader: uses · Layout includes startup loading behavior.
- Main Layout → Color Init: uses · Layout initializes theme/color behavior.
- Main Layout → Icon Init: uses · Layout initializes icon support.
- Main Layout → Header: contains · Global header is part of the shell.
- Main Layout → Footer: contains · Global footer is part of the shell.
- Main Layout → Home: routes · Shell hosts the route-level pages.
- Main Layout → Products: routes · Shell hosts the route-level pages.
- Main Layout → Product Details: routes · Shell hosts the route-level pages.
- Main Layout → Blog: routes · Shell hosts the route-level pages.
- Main Layout → Blog Details: routes · Shell hosts the route-level pages.
- Main Layout → Contact: routes · Shell hosts the route-level pages.
- Main Layout → Installment: routes · Shell hosts the route-level pages.
- Header → Search Context: reads/writes · Header search UI shares state through context.
- Home → Home Sections: composes · Homepage is assembled from marketing sections.
- Products → Product UI: composes · Catalog page is assembled from product widgets.
- Product Details → Product UI: composes · Details page reuses product detail modules.
- Blog → Blog UI: composes · Blog listing uses the blog UI family.
- Blog Details → Blog UI: composes · Article page uses the blog UI family.
- Products → Shared UI: uses · Catalog page relies on shared building blocks.
- Blog → Shared UI: uses · Blog page relies on shared building blocks.
- Fetch Hooks → Axios Client: calls · Async hooks wrap the shared HTTP client.
- Banner API → Axios Client: uses · Feature API modules call through Axios wrapper.
- Blog API → Axios Client: uses · Feature API modules call through Axios wrapper.
- Category API → Axios Client: uses · Feature API modules call through Axios wrapper.
- Product API → Axios Client: uses · Feature API modules call through Axios wrapper.
- Home Sections → Banner API: fetches · Homepage sections consume banner/content data.
- Blog UI → Blog API: fetches · Blog UI consumes blog content data.
- Product UI → Product API: fetches · Catalog UI consumes product data.
- Product UI → Category API: fetches · Catalog UI uses category data for filters/navigation.
- Header → Search Context: shares · Search state is shared with catalog entry points.
- Theme Assets → Public Host: served by · Compiled styles and assets are delivered from public hosting.