# zkluisinhodev/lugnia-frontend-challenge architecture

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

- Interactive diagram: https://gitdiagram.com/zkluisinhodev/lugnia-frontend-challenge
- Repository: https://github.com/zkluisinhodev/lugnia-frontend-challenge

## Overview

1. **Project shape**
   - This is a **React 19 single-page e-commerce frontend** built with **Vite** and deployed as a static app on **Vercel**.
   - The app is organized around two primary user experiences: a **Landing Page** and a **Shop Page**.

2. **Application entry and shell**
   - `index.html` is the Vite host page.
   - `src/main.jsx` bootstraps the React app.
   - `src/App.jsx` is the top-level composition layer that decides which page sections and global providers are mounted.
   - `src/index.css` provides the global styling baseline.

3. **Page-level composition**
   - `src/pages/LandingPage.jsx` assembles the marketing/entry experience.
   - `src/pages/ShopPage.jsx` assembles the product browsing and buying experience.
   - The README notes that **view persistence** remembers whether the user was last on Landing or Shop, so navigation state is not purely ephemeral.

4. **Feature domains**
   - `src/components/landing/*` contains the public-facing brand sections: header, hero, feature highlights, CTA, and footer.
   - `src/components/products/*` contains the shopping core: product cards, product list, and a product detail modal.
   - `src/components/filters/*` contains the product discovery controls: search, category, price range, and the filter bar container.
   - `src/components/cart/*` contains checkout-adjacent UI: cart icon, drawer, item rows, and summary.
   - `src/components/ui/*` contains cross-cutting utility components such as the error boundary and pagination.

5. **Data flow from API to UI**
   - The app fetches catalog data through `src/services/api.js`.
   - `src/constants/api.js` centralizes the API endpoints/configuration.
   - `src/hooks/useProducts.js` and `src/hooks/useCategories.js` encapsulate fetching and expose data/loading/error state to the UI.
   - `src/utils/productMappers.js` sits between the API and the UI to normalize product data, especially price formatting, so components do not depend on backend quirks.

6. **State management boundaries**
   - `src/context/CartContext.jsx` owns global cart state and is the main state boundary for shopping actions.
   - `src/context/ThemeContext.jsx` owns theme selection and synchronization.
   - The README indicates both **cart persistence** and **theme synchronization**, implying the contexts bridge React state with browser storage and/or system preferences.

7. **Interaction flow in the shop**
   - Product data is fetched, normalized, then passed into the list and filter components.
   - Filters narrow the visible catalog before rendering product cards.
   - Selecting a product opens the detail modal.
   - Adding an item updates `CartContext`, which in turn updates the cart icon badge and opens/feeds the cart drawer and summary.

8. **Cross-cutting UI and feedback**
   - `ErrorBoundary` protects the app from unhandled rendering failures.
   - Pagination is a shared UI concern for product browsing.
   - The README mentions **PrimeReact** and **SweetAlert2**, which materially affect the UI stack by providing richer controls and user feedback interactions beyond plain React components.

9. **Testing and quality**
   - `src/context/CartContext.test.jsx` shows that the cart state logic is explicitly unit tested.
   - `src/test/setup.js` configures the Vitest/React Testing Library environment.
   - The repo uses **Vitest** for tests and **ESLint** for code quality.

10. **Deployment and build boundaries**
   - `vite.config.js` defines the local build/dev behavior.
   - `vercel.json` supports SPA-style deployment on Vercel, which matters because client-side routing/state persistence must work without a traditional backend-rendered server.
   - `public/` contains static assets such as images used by the UI.

11. **Architectural takeaway**
   - The repo is a **frontend-only, feature-sliced React app** with a clear separation between:
     - **data acquisition** (`services`, `hooks`, `constants`),
     - **stateful application logic** (`context`),
     - **presentational feature UI** (`components`),
     - and **page assembly** (`pages`, `App`).
   - The most important diagram boundaries are the external API boundary, the cart/theme context boundary, and the shop UI pipeline from hooks → mappers → lists/cards → cart actions.

Main entry points: [`src/App.jsx`](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/App.jsx) (App Shell), [`src/components/products/ProductList.jsx`](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/products/ProductList.jsx) (Product List), [`src/pages/ShopPage.jsx`](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/pages/ShopPage.jsx) (Shop Page), [`src/services/api.js`](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/services/api.js) (API Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App Shell"]
  node_node_index_html["Host Page<br/>vite host<br/>[index.html]"]
  node_node_main(("Bootstrap<br/>react entry<br/>[main.jsx]"))
  node_node_app["App Shell<br/>composition<br/>[App.jsx]"]
  node_node_global_css["Global CSS<br/>styles<br/>[index.css]"]
  node_node_test_setup["Test Setup<br/>test config<br/>[setup.js]"]
  node_node_vite_config["Vite Config<br/>build config<br/>[vite.config.js]"]
  node_node_vercel["Vercel Deploy<br/>deployment config<br/>[vercel.json]"]
end

subgraph group_group_data["Data Flow"]
  node_node_api_constants["API Config<br/>constants<br/>[api.js]"]
  node_node_api_service["API Service<br/>[api.js]"]
  node_node_products_hook["Products Hook<br/>data hook<br/>[useProducts.js]"]
  node_node_categories_hook["Categories Hook<br/>data hook<br/>[useCategories.js]"]
  node_node_product_mappers["Product Mappers<br/>normalization<br/>[productMappers.js]"]
end

subgraph group_group_state["State Boundaries"]
  node_node_cart_context[("Cart Context<br/>state context<br/>[CartContext.jsx]")]
  node_node_theme_context[("Theme Context<br/>state context<br/>[ThemeContext.jsx]")]
  node_node_cart_test["Cart Tests<br/>unit test"]
end

subgraph group_group_ui["Feature UI"]
  node_node_landing_page["Landing Page<br/>[LandingPage.jsx]"]
  node_node_shop_page["Shop Page<br/>[ShopPage.jsx]"]
  node_node_landing_sections["Landing Sections<br/>brand ui"]
  node_node_filter_bar["Filter Bar<br/>discovery controls<br/>[FilterBar.jsx]"]
  node_node_product_list["Product List<br/>catalog view<br/>[ProductList.jsx]"]
  node_node_cart_ui["Cart UI<br/>checkout ui"]
  node_node_shared_ui["Shared UI<br/>common components"]
  node_node_error_boundary{{"Error Boundary<br/>resilience<br/>[ErrorBoundary.jsx]"}}
  node_node_pagination["Pagination<br/>shared control<br/>[Pagination.jsx]"]
end

node_node_index_html -->|"loads"| node_node_main
node_node_main -->|"mounts"| node_node_app
node_node_app -->|"wraps"| node_node_theme_context
node_node_app -->|"wraps"| node_node_cart_context
node_node_app -->|"guards"| node_node_error_boundary
node_node_app -->|"renders"| node_node_landing_page
node_node_app -->|"renders"| node_node_shop_page
node_node_landing_page -->|"composes"| node_node_landing_sections
node_node_shop_page -->|"composes"| node_node_filter_bar
node_node_shop_page -->|"composes"| node_node_product_list
node_node_shop_page -->|"composes"| node_node_cart_ui
node_node_filter_bar -->|"filters"| node_node_products_hook
node_node_product_list -->|"consumes"| node_node_products_hook
node_node_product_list -->|"normalizes"| node_node_product_mappers
node_node_product_list -->|"pages"| node_node_pagination
node_node_product_list -->|"adds to cart"| node_node_cart_context
node_node_cart_ui -->|"reads/writes"| node_node_cart_context
node_node_products_hook -->|"fetches"| node_node_api_service
node_node_categories_hook -->|"fetches"| node_node_api_service
node_node_api_service -->|"uses"| node_node_api_constants
node_node_api_service -->|"returns raw data"| node_node_product_mappers
node_node_theme_context -->|"tested via"| node_node_test_setup
node_node_cart_context -->|"verified by"| node_node_cart_test
node_node_vite_config -->|"builds"| node_node_main
node_node_vercel -->|"deploys"| node_node_app
node_node_global_css -->|"styles"| node_node_app

click node_node_index_html "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/index.html"
click node_node_main "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/main.jsx"
click node_node_app "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/App.jsx"
click node_node_global_css "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/index.css"
click node_node_landing_page "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/pages/LandingPage.jsx"
click node_node_shop_page "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/pages/ShopPage.jsx"
click node_node_landing_sections "https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/landing"
click node_node_filter_bar "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/filters/FilterBar.jsx"
click node_node_product_list "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/products/ProductList.jsx"
click node_node_cart_ui "https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/cart"
click node_node_shared_ui "https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/ui"
click node_node_api_constants "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/constants/api.js"
click node_node_api_service "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/services/api.js"
click node_node_products_hook "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/hooks/useProducts.js"
click node_node_categories_hook "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/hooks/useCategories.js"
click node_node_product_mappers "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/utils/productMappers.js"
click node_node_cart_context "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/CartContext.jsx"
click node_node_theme_context "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/ThemeContext.jsx"
click node_node_error_boundary "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/ui/ErrorBoundary.jsx"
click node_node_pagination "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/ui/Pagination.jsx"
click node_node_cart_test "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/CartContext.test.jsx"
click node_node_test_setup "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/test/setup.js"
click node_node_vite_config "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/vite.config.js"
click node_node_vercel "https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/vercel.json"

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_node_index_html,node_node_main,node_node_app,node_node_global_css,node_node_test_setup,node_node_vite_config,node_node_vercel toneBlue
class node_node_api_constants,node_node_api_service,node_node_products_hook,node_node_categories_hook,node_node_product_mappers toneAmber
class node_node_cart_context,node_node_theme_context,node_node_cart_test toneMint
class node_node_landing_page,node_node_shop_page,node_node_landing_sections,node_node_filter_bar,node_node_product_list,node_node_cart_ui,node_node_shared_ui,node_node_error_boundary,node_node_pagination toneRose
```

## Components

### App Shell

Entry, page assembly, and global styling.

- [Host Page](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/index.html): vite host · Static entry HTML used by Vite. · `index.html`
- [Bootstrap](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/main.jsx): react entry · Mounts the React application. · `src/main.jsx`
- [App Shell](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/App.jsx): composition · Top-level composition layer for pages and global providers. · `src/App.jsx`
- [Global CSS](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/index.css): styles · Application-wide styling baseline. · `src/index.css`
- [Test Setup](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/test/setup.js): test config · Configures the Vitest and React Testing Library environment. · `src/test/setup.js`
- [Vite Config](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/vite.config.js): build config · Defines local build and dev behavior. · `vite.config.js`
- [Vercel Deploy](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/vercel.json): deployment config · Supports SPA deployment and client-side routing on Vercel. · `vercel.json`

### Data Flow

API access, hooks, and mapping between backend data and UI models.

- [API Config](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/constants/api.js): constants · Centralized endpoint and API configuration. · `src/constants/api.js`
- [API Service](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/services/api.js): service · Fetches catalog data from the external API boundary. · `src/services/api.js`
- [Products Hook](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/hooks/useProducts.js): data hook · Encapsulates product fetching and loading/error state. · `src/hooks/useProducts.js`
- [Categories Hook](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/hooks/useCategories.js): data hook · Encapsulates category fetching and loading/error state. · `src/hooks/useCategories.js`
- [Product Mappers](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/utils/productMappers.js): normalization · Normalizes product data and price formatting for UI consumption. · `src/utils/productMappers.js`

### State Boundaries

Global client state for cart and theme, including persistence/synchronization concerns.

- [Cart Context](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/CartContext.jsx): state context · Global cart state boundary with persistence for shopping actions. · `src/context/CartContext.jsx`
- [Theme Context](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/ThemeContext.jsx): state context · Theme selection boundary with synchronization to storage or system preference. · `src/context/ThemeContext.jsx`
- [Cart Tests](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/context/CartContext.test.jsx): unit test · Explicit tests for cart state logic. · `src/context/CartContext.test.jsx`

### Feature UI

Page sections and reusable interface components for landing, shopping, and feedback.

- [Landing Page](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/pages/LandingPage.jsx): page · Assembles the marketing and entry experience. · `src/pages/LandingPage.jsx`
- [Shop Page](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/pages/ShopPage.jsx): page · Assembles browsing, filtering, and purchase flows. · `src/pages/ShopPage.jsx`
- [Landing Sections](https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/landing): brand ui · Header, hero, features, CTA, and footer for the public-facing experience. · `src/components/landing`
- [Filter Bar](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/filters/FilterBar.jsx): discovery controls · Container for product search and filtering. · `src/components/filters/FilterBar.jsx`
- [Product List](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/products/ProductList.jsx): catalog view · Renders product collections and coordinates cards, detail modal, and pagination. · `src/components/products/ProductList.jsx`
- [Cart UI](https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/cart): checkout ui · Cart icon, drawer, item rows, and summary. · `src/components/cart`
- [Shared UI](https://github.com/zkluisinhodev/lugnia-frontend-challenge/tree/main/src/components/ui): common components · Cross-cutting error handling and pagination components. · `src/components/ui`
- [Error Boundary](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/ui/ErrorBoundary.jsx): resilience · Protects the UI from rendering failures. · `src/components/ui/ErrorBoundary.jsx`
- [Pagination](https://github.com/zkluisinhodev/lugnia-frontend-challenge/blob/main/src/components/ui/Pagination.jsx): shared control · Shared browsing control for catalog navigation. · `src/components/ui/Pagination.jsx`

## Connections

- Host Page → Bootstrap: loads · Host page bootstraps the React entry point.
- Bootstrap → App Shell: mounts · Main entry mounts the top-level app composition.
- App Shell → Theme Context: wraps · App composes global theme state around the UI.
- App Shell → Cart Context: wraps · App composes global cart state around the UI.
- App Shell → Error Boundary: guards · Top-level rendering is protected by an error boundary.
- App Shell → Landing Page: renders · App can assemble the landing experience.
- App Shell → Shop Page: renders · App can assemble the shop experience.
- Landing Page → Landing Sections: composes · Landing page is built from marketing sections.
- Shop Page → Filter Bar: composes · Shop page includes product discovery controls.
- Shop Page → Product List: composes · Shop page renders the catalog browsing surface.
- Shop Page → Cart UI: composes · Shop page includes cart interaction surfaces.
- Filter Bar → Products Hook: filters · Filter state shapes the visible product set.
- Product List → Products Hook: consumes · Product list reads fetched product state.
- Product List → Product Mappers: normalizes · Catalog data is normalized before rendering.
- Product List → Pagination: pages · Pagination supports browsing across product sets.
- Product List → Cart Context: adds to cart · Product actions update global cart state.
- Cart UI → Cart Context: reads/writes · Cart drawer and badge reflect shared cart state.
- Products Hook → API Service: fetches · Products hook retrieves data through the service boundary.
- Categories Hook → API Service: fetches · Categories hook retrieves data through the service boundary.
- API Service → API Config: uses · Service relies on centralized API configuration.
- API Service → Product Mappers: returns raw data · Fetched data is normalized before reaching UI components.
- Theme Context → Test Setup: tested via · Test environment supports state and component tests.
- Cart Context → Cart Tests: verified by · Cart state logic has explicit unit coverage.
- Vite Config → Bootstrap: builds · Vite config governs app bundling and development.
- Vercel Deploy → App Shell: deploys · Vercel serves the SPA and its client-side navigation.
- Global CSS → App Shell: styles · Global styles apply across the app shell.
