# hoangsonle/zenstore_fe architecture

> Architecture diagram of the GitHub repository hoangsonle/zenstore_fe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hoangsonle/zenstore_fe
- Repository: https://github.com/hoangsonle/zenstore_fe

## Overview

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: [`src/pages/layout/MainLayout.tsx`](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/layout/MainLayout.tsx) (Main Layout), [`src/apis/axios.ts`](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/axios.ts) (Axios Client), [`src/components/products/ProductDetails.tsx`](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/products/ProductDetails.tsx) (Product UI), [`src/pages/products/ProductPage.tsx`](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/products/ProductPage.tsx) (Products)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry & Shell"]
  node_src_index_js(("index.js<br/>app entry<br/>[index.js]"))
  node_src_app_js["App<br/>spa root<br/>[App.js]"]
  node_main_layout["Main Layout<br/>route shell<br/>[MainLayout.tsx]"]
  node_route_scroll_top(("Scroll Top<br/>ux helper"))
  node_preloader(("Preloader<br/>startup helper<br/>[Preloader.tsx]"))
  node_color_init(("Color Init<br/>theme init<br/>[ColorInit.tsx]"))
  node_icon_init(("Icon Init<br/>ui init"))
end

subgraph group_pages["Pages"]
  node_home_page["Home<br/>route page<br/>[HomePage.tsx]"]
  node_product_page["Products<br/>route page<br/>[ProductPage.tsx]"]
  node_product_details_page["Product Details<br/>route page"]
  node_blog_page["Blog<br/>route page<br/>[BlogPage.tsx]"]
  node_blog_details_page["Blog Details<br/>route page"]
  node_contact_page["Contact<br/>route page<br/>[ContactPage.jsx]"]
  node_installment_page["Installment<br/>route page"]
end

subgraph group_components["Components"]
  node_header["Header<br/>navigation ui<br/>[Header.tsx]"]
  node_footer["Footer<br/>[EnhancedFooter.tsx]"]
  node_product_components["Product UI<br/>catalog ui<br/>[ProductDetails.tsx]"]
  node_home_components["Home Sections<br/>homepage ui<br/>[FeaturedOne.jsx]"]
  node_blog_components["Blog UI<br/>content ui<br/>[Blog.tsx]"]
  node_shared_components["Shared UI<br/>[Breadcrumb.tsx]"]
end

subgraph group_data["Data & State"]
  node_search_context(("Search Context<br/>shared state<br/>[SearchContext.tsx]"))
  node_hooks(("Fetch Hooks<br/>async hooks<br/>[useApi.ts]"))
  node_axios_api(("Axios Client<br/>http client<br/>[axios.ts]"))
  node_banner_api(("Banner API<br/>content api<br/>[banner.api.ts]"))
  node_blog_api(("Blog API<br/>content api<br/>[blog.api.ts]"))
  node_category_api(("Category API<br/>catalog api<br/>[category.api.ts]"))
  node_product_api(("Product API<br/>catalog api<br/>[product.api.ts]"))
end

subgraph group_assets["Assets & Styling"]
  node_theme_assets["Theme Assets<br/>static theme<br/>[main.scss]"]
  node_public_hosting["Public Host<br/>static hosting<br/>[index.html]"]
end

node_src_index_js -->|"bootstraps"| node_src_app_js
node_src_app_js -->|"renders"| node_main_layout
node_main_layout -->|"uses"| node_route_scroll_top
node_main_layout -->|"uses"| node_preloader
node_main_layout -->|"uses"| node_color_init
node_main_layout -->|"uses"| node_icon_init
node_main_layout -->|"contains"| node_header
node_main_layout -->|"contains"| node_footer
node_main_layout -->|"routes"| node_home_page
node_main_layout -->|"routes"| node_product_page
node_main_layout -->|"routes"| node_product_details_page
node_main_layout -->|"routes"| node_blog_page
node_main_layout -->|"routes"| node_blog_details_page
node_main_layout -->|"routes"| node_contact_page
node_main_layout -->|"routes"| node_installment_page
node_header -->|"reads/writes"| node_search_context
node_home_page -->|"composes"| node_home_components
node_product_page -->|"composes"| node_product_components
node_product_details_page -->|"composes"| node_product_components
node_blog_page -->|"composes"| node_blog_components
node_blog_details_page -->|"composes"| node_blog_components
node_product_page -->|"uses"| node_shared_components
node_blog_page -->|"uses"| node_shared_components
node_hooks -->|"calls"| node_axios_api
node_banner_api -->|"uses"| node_axios_api
node_blog_api -->|"uses"| node_axios_api
node_category_api -->|"uses"| node_axios_api
node_product_api -->|"uses"| node_axios_api
node_home_components -->|"fetches"| node_banner_api
node_blog_components -->|"fetches"| node_blog_api
node_product_components -->|"fetches"| node_product_api
node_product_components -->|"fetches"| node_category_api
node_header -->|"shares"| node_search_context
node_theme_assets -->|"served by"| node_public_hosting

click node_src_index_js "https://github.com/hoangsonle/zenstore_fe/blob/main/src/index.js"
click node_src_app_js "https://github.com/hoangsonle/zenstore_fe/blob/main/src/App.js"
click node_main_layout "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/layout/MainLayout.tsx"
click node_route_scroll_top "https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/RouteScrollToTop.tsx"
click node_preloader "https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/Preloader.tsx"
click node_color_init "https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/ColorInit.tsx"
click node_icon_init "https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/PhosphorIconInit.ts"
click node_home_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/homePage/HomePage.tsx"
click node_product_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/products/ProductPage.tsx"
click node_product_details_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/products/ProductDetailsPage.tsx"
click node_blog_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/blog/BlogPage.tsx"
click node_blog_details_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/blog/BlogDetailsPage.tsx"
click node_contact_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/contact/ContactPage.jsx"
click node_installment_page "https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/installment/InstallmentPage.tsx"
click node_header "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/header/Header.tsx"
click node_footer "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/footer/EnhancedFooter.tsx"
click node_product_components "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/products/ProductDetails.tsx"
click node_home_components "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/FeaturedOne.jsx"
click node_blog_components "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/blog/Blog.tsx"
click node_shared_components "https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/breadcrumb/Breadcrumb.tsx"
click node_search_context "https://github.com/hoangsonle/zenstore_fe/blob/main/src/context/SearchContext.tsx"
click node_hooks "https://github.com/hoangsonle/zenstore_fe/blob/main/src/hooks/useApi.ts"
click node_axios_api "https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/axios.ts"
click node_banner_api "https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/banner/banner.api.ts"
click node_blog_api "https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/blog/blog.api.ts"
click node_category_api "https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/category/category.api.ts"
click node_product_api "https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/product/product.api.ts"
click node_theme_assets "https://github.com/hoangsonle/zenstore_fe/blob/main/public/assets/sass/main.scss"
click node_public_hosting "https://github.com/hoangsonle/zenstore_fe/blob/main/public/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_src_index_js,node_src_app_js,node_main_layout,node_route_scroll_top,node_preloader,node_color_init,node_icon_init toneBlue
class node_home_page,node_product_page,node_product_details_page,node_blog_page,node_blog_details_page,node_contact_page,node_installment_page toneAmber
class node_header,node_footer,node_product_components,node_home_components,node_blog_components,node_shared_components toneMint
class node_search_context,node_hooks,node_axios_api,node_banner_api,node_blog_api,node_category_api,node_product_api toneRose
class node_theme_assets,node_public_hosting toneIndigo
```

## Components

### Entry & Shell

Application bootstrap and the main SPA chrome.

- [index.js](https://github.com/hoangsonle/zenstore_fe/blob/main/src/index.js): app entry · Bootstraps the React app. · `src/index.js`
- [App](https://github.com/hoangsonle/zenstore_fe/blob/main/src/App.js): spa root · Top-level application component. · `src/App.js`
- [Main Layout](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/layout/MainLayout.tsx): route shell · Main page shell and route composition boundary. · `src/pages/layout/MainLayout.tsx`
- [Scroll Top](https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/RouteScrollToTop.tsx): ux helper · Resets scroll position on navigation. · `src/helper/RouteScrollToTop.tsx`
- [Preloader](https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/Preloader.tsx): startup helper · Initial loading state for the app shell. · `src/helper/Preloader.tsx`
- [Color Init](https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/ColorInit.tsx): theme init · Initializes color/theme behavior. · `src/helper/ColorInit.tsx`
- [Icon Init](https://github.com/hoangsonle/zenstore_fe/blob/main/src/helper/PhosphorIconInit.ts): ui init · Initializes icon rendering. · `src/helper/PhosphorIconInit.ts`

### Pages

Route-level composition roots for each business area.

- [Home](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/homePage/HomePage.tsx): route page · Homepage composition root. · `src/pages/homePage/HomePage.tsx`
- [Products](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/products/ProductPage.tsx): route page · Catalog and shop page root. · `src/pages/products/ProductPage.tsx`
- [Product Details](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/products/ProductDetailsPage.tsx): route page · Product detail route root. · `src/pages/products/ProductDetailsPage.tsx`
- [Blog](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/blog/BlogPage.tsx): route page · Blog listing route root. · `src/pages/blog/BlogPage.tsx`
- [Blog Details](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/blog/BlogDetailsPage.tsx): route page · Blog article route root. · `src/pages/blog/BlogDetailsPage.tsx`
- [Contact](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/contact/ContactPage.jsx): route page · Contact page root. · `src/pages/contact/ContactPage.jsx`
- [Installment](https://github.com/hoangsonle/zenstore_fe/blob/main/src/pages/installment/InstallmentPage.tsx): route page · Installment/payment info page root. · `src/pages/installment/InstallmentPage.tsx`

### Components

Reusable UI families shared across pages.

- [Header](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/header/Header.tsx): navigation ui · Global navigation, search, and announcement area. · `src/components/header/Header.tsx`
- [Footer](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/footer/EnhancedFooter.tsx): site footer · Global footer and newsletter area. · `src/components/footer/EnhancedFooter.tsx`
- [Product UI](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/products/ProductDetails.tsx): catalog ui · Product listing, details, filters, and cart/checkout widgets. · `src/components/products/ProductDetails.tsx`
- [Home Sections](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/FeaturedOne.jsx): homepage ui · Homepage marketing and merchandising sections. · `src/components/FeaturedOne.jsx`
- [Blog UI](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/blog/Blog.tsx): content ui · Blog list and article presentation. · `src/components/blog/Blog.tsx`
- [Shared UI](https://github.com/hoangsonle/zenstore_fe/blob/main/src/components/breadcrumb/Breadcrumb.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](https://github.com/hoangsonle/zenstore_fe/blob/main/src/context/SearchContext.tsx): shared state · Cross-page search state shared by header and catalog views. · `src/context/SearchContext.tsx`
- [Fetch Hooks](https://github.com/hoangsonle/zenstore_fe/blob/main/src/hooks/useApi.ts): async hooks · Shared async and lifecycle fetching abstractions. · `src/hooks/useApi.ts`
- [Axios Client](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/axios.ts): http client · Shared Axios wrapper for remote requests. · `src/apis/axios.ts`
- [Banner API](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/banner/banner.api.ts): content api · Banner and promotional content access. · `src/apis/banner/banner.api.ts`
- [Blog API](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/blog/blog.api.ts): content api · Blog data access layer. · `src/apis/blog/blog.api.ts`
- [Category API](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/category/category.api.ts): catalog api · Category and navigation data access. · `src/apis/category/category.api.ts`
- [Product API](https://github.com/hoangsonle/zenstore_fe/blob/main/src/apis/product/product.api.ts): catalog api · Product and commerce data access. · `src/apis/product/product.api.ts`

### Assets & Styling

Static host assets and theme/style sources.

- [Theme Assets](https://github.com/hoangsonle/zenstore_fe/blob/main/public/assets/sass/main.scss): static theme · Sass/CSS theme sources and compiled storefront assets. · `public/assets/sass/main.scss`
- [Public Host](https://github.com/hoangsonle/zenstore_fe/blob/main/public/index.html): static hosting · SPA entry HTML, static assets, and redirect rules. · `public/index.html`

## Connections

- 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.
