# tayooshoboke6/final-mmartfe architecture

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

- Interactive diagram: https://gitdiagram.com/tayooshoboke6/final-mmartfe
- Repository: https://github.com/tayooshoboke6/final-mmartfe

## Overview

#### 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: [`src/App.js`](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/App.js) (App routing), [`src/pages/Checkout.js`](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/Checkout.js) (Checkout), [`src/context/AuthContext.js`](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/context/AuthContext.js) (Session contexts), [`src/services/firebase-auth.service.js`](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/firebase-auth.service.js) (Auth service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_entry(("Browser entry<br/>React entry<br/>[index.js]"))
  node_app["App routing<br/>React app<br/>[App.js]"]
  node_main_layout["Customer layout<br/>[MainLayout.js]"]
  node_customer_pages["Customer pages<br/>route screens"]
  node_seo["SEO metadata<br/>SEO component<br/>[SEO.js]"]
  node_contexts["Session contexts<br/>React contexts<br/>[AuthContext.js]"]
end

subgraph group_commerce["Commerce services"]
  node_catalog["Product access<br/>product services<br/>[ProductService.js]"]
  node_cache_sync["Cache &amp; delta sync<br/>client data layer<br/>[CacheManager.js]"]
  node_commerce_api[("Commerce data API<br/>remote data")]
  node_checkout["Checkout<br/>[Checkout.js]"]
  node_orders["Order service<br/>order API client<br/>[order.service.js]"]
  node_payments["Payment UI<br/>payment controls<br/>[PaymentCallback.js]"]
end

subgraph group_identity["Identity"]
  node_auth_service["Auth service<br/>identity client"]
  node_firebase[("Firebase Auth<br/>external identity")]
  node_auth_proxy{{"Auth proxy<br/>edge function<br/>[&#91;&#91;path&#93;&#93;.js]"}}
end

subgraph group_admin["Admin operations"]
  node_admin_layout["Admin console<br/>admin layout<br/>[AdminLayout.js]"]
  node_admin_products["Catalog management<br/>admin screen<br/>[Products.js]"]
  node_admin_guard["Admin password gate<br/>access control"]
end

subgraph group_delivery["Location &amp; delivery"]
  node_location_ui["Location UI<br/>maps and address UI<br/>[GeofenceMap.js]"]
  node_delivery_service["Delivery eligibility<br/>delivery service"]
  node_maps["Google Maps &amp; Places<br/>external maps"]
end

subgraph group_publishing["Publishing"]
  node_feed_scripts["SEO &amp; feed generators<br/>Node scripts<br/>[generateSitemap.js]"]
  node_static_hosting["Static hosting<br/>deployment target"]
end

node_entry -->|"mounts"| node_app
node_app -->|"routes customer views"| node_main_layout
node_main_layout -->|"frames"| node_customer_pages
node_customer_pages -->|"sets metadata"| node_seo
node_app -->|"provides global state"| node_contexts
node_contexts -->|"auth session"| node_auth_service
node_auth_service -.->|"proxies auth requests"| node_auth_proxy
node_auth_proxy -->|"forwards to"| node_firebase
node_auth_service -->|"authenticates with"| node_firebase
node_customer_pages -->|"browses products"| node_catalog
node_catalog -->|"uses"| node_cache_sync
node_cache_sync -->|"syncs and fetches"| node_commerce_api
node_contexts -->|"supplies cart"| node_checkout
node_checkout -->|"validates delivery"| node_delivery_service
node_checkout -->|"submits order"| node_orders
node_checkout -->|"initiates payment"| node_payments
node_location_ui -->|"supplies address"| node_delivery_service
node_location_ui -->|"uses"| node_maps
node_customer_pages -->|"discovers locations"| node_location_ui
node_app -->|"routes admin views"| node_admin_layout
node_admin_guard -->|"gates access"| node_admin_layout
node_admin_layout -->|"hosts management"| node_admin_products
node_admin_products -->|"manages catalog"| node_commerce_api
node_feed_scripts -.->|"publishes artifacts"| node_static_hosting
node_static_hosting -->|"serves SPA"| node_entry

click node_entry "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/index.js"
click node_app "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/App.js"
click node_main_layout "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/layout/MainLayout.js"
click node_seo "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/seo/SEO.js"
click node_contexts "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/context/AuthContext.js"
click node_catalog "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/ProductService.js"
click node_cache_sync "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/CacheManager.js"
click node_checkout "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/Checkout.js"
click node_orders "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/order.service.js"
click node_payments "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/PaymentCallback.js"
click node_auth_service "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/firebase-auth.service.js"
click node_auth_proxy "https://github.com/tayooshoboke6/final-mmartfe/blob/master/functions/__/auth/%5B%5Bpath%5D%5D.js"
click node_location_ui "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/GeofenceMap.js"
click node_delivery_service "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/delivery.service.js"
click node_admin_layout "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/layouts/AdminLayout.js"
click node_admin_products "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/admin/Products.js"
click node_admin_guard "https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/admin/withAdminPassword.js"
click node_feed_scripts "https://github.com/tayooshoboke6/final-mmartfe/blob/master/scripts/generateSitemap.js"
click node_static_hosting "https://github.com/tayooshoboke6/final-mmartfe/blob/master/public/_redirects"

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_entry,node_app,node_main_layout,node_customer_pages,node_seo,node_contexts toneBlue
class node_catalog,node_cache_sync,node_commerce_api,node_checkout,node_orders,node_payments toneAmber
class node_auth_service,node_firebase,node_auth_proxy toneMint
class node_admin_layout,node_admin_products,node_admin_guard toneRose
class node_location_ui,node_delivery_service,node_maps toneIndigo
class node_feed_scripts,node_static_hosting toneTeal
```

## Components

### Customer storefront

- [Browser entry](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/index.js): React entry · `src/index.js`
- [App routing](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/App.js): React app · Composes providers and customer/admin routes. · `src/App.js`
- [Customer layout](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/layout/MainLayout.js): layout · Header, footer, and customer page frame. · `src/components/layout/MainLayout.js`
- **Customer pages**: route screens · Catalog, product, cart, checkout, account, and orders.
- [SEO metadata](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/seo/SEO.js): SEO component · `src/components/seo/SEO.js`
- [Session contexts](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/context/AuthContext.js): React contexts · Authentication, cart, notifications, and toasts. · `src/context/AuthContext.js`

### Commerce services

- [Product access](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/ProductService.js): product services · General and optimized catalog retrieval. · `src/services/ProductService.js`
- [Cache & delta sync](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/CacheManager.js): client data layer · Caching, deduplication, prefetching, and incremental updates. · `src/services/CacheManager.js`
- **Commerce data API**: remote data
- [Checkout](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/Checkout.js): checkout screen · Turns cart and delivery selection into an order. · `src/pages/Checkout.js`
- [Order service](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/order.service.js): order API client · `src/services/order.service.js`
- [Payment UI](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/PaymentCallback.js): payment controls · Apple Pay, Google Pay, bank transfer, and callbacks. · `src/pages/PaymentCallback.js`

### Identity

- [Auth service](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/firebase-auth.service.js): identity client · Firebase-oriented customer authentication. · `src/services/firebase-auth.service.js`
- **Firebase Auth**: external identity
- [Auth proxy](https://github.com/tayooshoboke6/final-mmartfe/blob/master/functions/__/auth/%5B%5Bpath%5D%5D.js): edge function · `functions/__/auth/[[path]].js`

### Admin operations

- [Admin console](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/layouts/AdminLayout.js): admin layout · Separate operational route boundary. · `src/components/layouts/AdminLayout.js`
- [Catalog management](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/pages/admin/Products.js): admin screen · Product administration and import workflows. · `src/pages/admin/Products.js`
- [Admin password gate](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/admin/withAdminPassword.js): access control · `src/components/admin/withAdminPassword.js`

### Location & delivery

- [Location UI](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/components/GeofenceMap.js): maps and address UI · Geofence map and address autocomplete. · `src/components/GeofenceMap.js`
- [Delivery eligibility](https://github.com/tayooshoboke6/final-mmartfe/blob/master/src/services/delivery.service.js): delivery service · Address validation and delivery selection. · `src/services/delivery.service.js`
- **Google Maps & Places**: external maps

### Publishing

- [SEO & feed generators](https://github.com/tayooshoboke6/final-mmartfe/blob/master/scripts/generateSitemap.js): Node scripts · Offline sitemap, Google feed, and Facebook catalog generation. · `scripts/generateSitemap.js`
- [Static hosting](https://github.com/tayooshoboke6/final-mmartfe/blob/master/public/_redirects): deployment target · Vercel and Cloudflare-compatible static delivery. · `public/_redirects`

## Connections

- 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
