How tayooshoboke6/final-mmartfe works
Purpose and Runtime
This is a Create React App single-page storefront for M-Mart Plus, covering product discovery, location-aware delivery, checkout/payment, customer accounts/orders, promotions, and an operational admin console. Browser entry is src/index.js; application composition and routing are centered in src/App.js. Production static assets, PWA metadata, redirects, and sitemap artifacts live under public/.
Application Shell and Navigation
The React app is organized around customer pages, reusable layout, and route-specific screens. The primary layout/header/footer boundary is implemented by:
• src/App.js
• src/components/layout/MainLayout.js
• src/components/layout/Header.js
Customer-facing routes include catalog, product detail, cart, checkout, locations, account, and orders under src/pages/. SEO metadata is handled at page/component level through src/components/seo/SEO.js.
State, Identity, and Customer Session
Global React contexts separate authentication, cart state, notifications, and toasts:
• src/context/AuthContext.js
• src/context/CartContext.js
• src/context/NotificationContext.js
Authentication is Firebase-oriented, with configuration and service boundaries in src/firebase/config.js, src/services/firebase-auth.service.js, and src/services/auth.service.js. An edge-style auth proxy is also present at functions/__/auth/[[path]].js, with an alternative Cloudflare worker proxy file in cloudflare-worker-firebase-auth-proxy.js.
Commerce and Order Flow
Product browsing flows from page components into product services, then the remote API/data layer. The code distinguishes general, optimized, and delta-synchronized product access:
• src/services/ProductService.js
• src/services/OptimizedProductService.js
• src/services/DeltaSyncManager.js
Cart state feeds checkout; delivery selection/address validation and payment controls are explicit UI boundaries. Orders are submitted and later retrieved through:
• src/pages/Checkout.js
• src/services/order.service.js
• src/services/delivery.service.js
Payment UI supports Apple Pay, Google Pay, bank transfer, and callback handling in src/components/payment/ and src/pages/PaymentCallback.js.
Location and Delivery Boundary
The storefront supports store/location discovery, address autocomplete, geofencing, and delivery eligibility. This isolates Google Maps/Places integration and location data from checkout:
• src/components/GeofenceMap.js
• src/components/address/AddressAutocomplete.js
• src/services/address.service.js
Static location content is represented in src/data/locations.js; location SEO pages are served through src/pages/LocationPage.js.
Admin Operations
A distinct admin layout hosts management functions for products, categories, orders, users, campaigns, coupons, banners, store addresses, notifications, and settings:
• src/components/layouts/AdminLayout.js
• src/pages/admin/Dashboard.js
• src/pages/admin/Products.js
Admin import/editor components indicate browser-administered catalog and campaign workflows, with password gating implemented in src/components/admin/withAdminPassword.js.
Performance, Publishing, and External Integrations
Caching, request deduplication, prefetching, optimized images, and delta sync are first-class client concerns, centered on src/services/CacheManager.js, src/hooks/useCachedData.js, and src/utils/requestDeduplication.js. Cloudinary upload support is exposed through src/components/common/CloudinaryUpload.js.
The app integrates Firebase authentication, Google Maps/Places, payment providers, Cloudinary, analytics, Facebook Pixel, and merchant/catalog feeds. Feed and SEO generation are offline Node scripts:
• scripts/generateSitemap.js
• scripts/generate-google-feed.js
• scripts/facebook-catalog-generator.js
Deployment targets include Vercel (vercel.json) and Cloudflare-compatible static hosting controls (public/_headers, public/_redirects), with GitHub Actions workflows in .github/workflows/.
Main entry points: App.js App routing · Checkout.js Checkout · AuthContext.js Session contexts · firebase-auth.service.js Auth service
Components 23
Customer storefront
- Browser entry
src/index.js - App routing · Composes providers and customer/admin routes.
src/App.js - Customer layout · Header, footer, and customer page frame.
src/components/layout/MainLayout.js - Customer pages · Catalog, product, cart, checkout, account, and orders.
- SEO metadata
src/components/seo/SEO.js - Session contexts · Authentication, cart, notifications, and toasts.
src/context/AuthContext.js
Commerce services
- Product access · General and optimized catalog retrieval.
src/services/ProductService.js - Cache & delta sync · Caching, deduplication, prefetching, and incremental updates.
src/services/CacheManager.js - Commerce data API
- Checkout · Turns cart and delivery selection into an order.
src/pages/Checkout.js - Order service
src/services/order.service.js - Payment UI · Apple Pay, Google Pay, bank transfer, and callbacks.
src/pages/PaymentCallback.js
Identity
- Auth service · Firebase-oriented customer authentication.
src/services/firebase-auth.service.js - Firebase Auth
- Auth proxy
functions/__/auth/[[path]].js
Admin operations
- Admin console · Separate operational route boundary.
src/components/layouts/AdminLayout.js - Catalog management · Product administration and import workflows.
src/pages/admin/Products.js - Admin password gate
src/components/admin/withAdminPassword.js
Location & delivery
- Location UI · Geofence map and address autocomplete.
src/components/GeofenceMap.js - Delivery eligibility · Address validation and delivery selection.
src/services/delivery.service.js - Google Maps & Places
Publishing
- SEO & feed generators · Offline sitemap, Google feed, and Facebook catalog generation.
scripts/generateSitemap.js - Static hosting · Vercel and Cloudflare-compatible static delivery.
public/_redirects
Connections 25
- Browser entry → App routing: mounts
- App routing → Customer layout: routes customer views
- Customer layout → Customer pages: frames
- Customer pages → SEO metadata: sets metadata
- App routing → Session contexts: provides global state
- Session contexts → Auth service: auth session
- Auth service → Auth proxy: proxies auth requests
- Auth proxy → Firebase Auth: forwards to
- Auth service → Firebase Auth: authenticates with
- Customer pages → Product access: browses products
- Product access → Cache & delta sync: uses
- Cache & delta sync → Commerce data API: syncs and fetches
- Session contexts → Checkout: supplies cart
- Checkout → Delivery eligibility: validates delivery
- Checkout → Order service: submits order
- Checkout → Payment UI: initiates payment
- Location UI → Delivery eligibility: supplies address
- Location UI → Google Maps & Places: uses
- Customer pages → Location UI: discovers locations
- App routing → Admin console: routes admin views
- Admin password gate → Admin console: gates access
- Admin console → Catalog management: hosts management
- Catalog management → Commerce data API: manages catalog
- SEO & feed generators → Static hosting: publishes artifacts
- Static hosting → Browser entry: serves SPA