How zkluisinhodev/lugnia-frontend-challenge works
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: App.jsx App Shell · ProductList.jsx Product List · ShopPage.jsx Shop Page · api.js API Service
Components 24
App Shell
Entry, page assembly, and global styling.
- Host Page · Static entry HTML used by Vite.
index.html - Bootstrap · Mounts the React application.
src/main.jsx - App Shell · Top-level composition layer for pages and global providers.
src/App.jsx - Global CSS · Application-wide styling baseline.
src/index.css - Test Setup · Configures the Vitest and React Testing Library environment.
src/test/setup.js - Vite Config · Defines local build and dev behavior.
vite.config.js - Vercel Deploy · 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 · Centralized endpoint and API configuration.
src/constants/api.js - API Service · Fetches catalog data from the external API boundary.
src/services/api.js - Products Hook · Encapsulates product fetching and loading/error state.
src/hooks/useProducts.js - Categories Hook · Encapsulates category fetching and loading/error state.
src/hooks/useCategories.js - Product Mappers · 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 · Global cart state boundary with persistence for shopping actions.
src/context/CartContext.jsx - Theme Context · Theme selection boundary with synchronization to storage or system preference.
src/context/ThemeContext.jsx - Cart Tests · 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 · Assembles the marketing and entry experience.
src/pages/LandingPage.jsx - Shop Page · Assembles browsing, filtering, and purchase flows.
src/pages/ShopPage.jsx - Landing Sections · Header, hero, features, CTA, and footer for the public-facing experience.
src/components/landing - Filter Bar · Container for product search and filtering.
src/components/filters/FilterBar.jsx - Product List · Renders product collections and coordinates cards, detail modal, and pagination.
src/components/products/ProductList.jsx - Cart UI · Cart icon, drawer, item rows, and summary.
src/components/cart - Shared UI · Cross-cutting error handling and pagination components.
src/components/ui - Error Boundary · Protects the UI from rendering failures.
src/components/ui/ErrorBoundary.jsx - Pagination · Shared browsing control for catalog navigation.
src/components/ui/Pagination.jsx
Connections 26
- 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.