# irfan-rg/the-xo-store architecture

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

- Interactive diagram: https://gitdiagram.com/irfan-rg/the-xo-store
- Repository: https://github.com/irfan-rg/the-xo-store

## Overview

#### Purpose and topology
The XO Store is a full-stack merchandise e-commerce application. A Vite/React single-page frontend presents catalog, cart, checkout, and navigation views; an Express API supplies product and commerce-support endpoints backed by MongoDB. The frontend is intended for Vercel and the backend for Render.

#### Frontend bootstrap and composition
`frontend/merch-front/src/main.jsx` mounts the React application, with `frontend/merch-front/src/App.jsx` serving as the top-level application/routing composition point. User-facing screens are page-oriented: catalog and merchandising live in `frontend/merch-front/src/pages/Home.jsx` and `frontend/merch-front/src/pages/Products.jsx`; checkout flow is represented by `frontend/merch-front/src/pages/Cart.jsx` and `frontend/merch-front/src/pages/Checkout.jsx`.

#### Client-side cart state
`frontend/merch-front/src/context/CartContext.jsx` is the cross-page cart state boundary. Product browsing adds/removes items through this shared context, while Cart renders and modifies the resulting state and Checkout consumes it for payment. This keeps cart coordination in-browser rather than persisting it through the listed backend model/routes.

#### Backend API boundary
`backend/server.js` is the Node/Express process entry point. It owns environment loading, database/service setup, CORS, health/utility endpoints, and API mounting. Product HTTP handling is separated into `backend/routes/products.js`, creating a clear browser-to-API boundary: React uses its configured API URL, while Express translates requests into database operations and external-service calls.

#### Product persistence
`backend/models/Product.js` defines the Mongoose-backed product domain model, and `backend/routes/products.js` exposes catalog retrieval, including category filtering. The primary catalog flow is MongoDB → Mongoose Product model → Express product route → frontend product pages. `backend/server.js` also provides the documented development seed capability, making the database the source of catalog content.

#### Commerce and media integrations
The API exposes payment-intent creation and image upload endpoints from `backend/server.js`. Stripe handles payment authorization through a server-side secret key and a frontend publishable-key integration; Cloudinary provides externally hosted/optimized product imagery. Auth0 authentication is a frontend integration configured through the Vite environment, rather than a represented backend auth route.

#### Runtime and deployment boundaries
The frontend runs under Vite/React and is configured for static Vercel deployment, including SPA redirect behavior in `frontend/merch-front/vercel.json` and `frontend/merch-front/public/_redirects`. The backend runs separately as an Express service (`backend/server.js`) on Render, with MongoDB, Stripe, and Cloudinary credentials held in backend environment configuration. Frontend runtime configuration in `frontend/merch-front/.env` supplies API, Stripe public, and Auth0 identifiers; backend secrets remain in `backend/.env`.

Main entry points: [`frontend/merch-front/src/App.jsx`](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/App.jsx) (App composition), [`backend/server.js`](https://github.com/irfan-rg/the-xo-store/blob/main/backend/server.js) (Express API server), [`frontend/merch-front/src/pages/Checkout.jsx`](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Checkout.jsx) (Checkout), [`backend/routes/products.js`](https://github.com/irfan-rg/the-xo-store/blob/main/backend/routes/products.js) (Product API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_main["React bootstrap<br/>Vite entry<br/>[main.jsx]"]
  node_app["App composition<br/>React router<br/>[App.jsx]"]
  node_home["Home catalog<br/>React page<br/>[Home.jsx]"]
  node_products["Products catalog<br/>React page<br/>[Products.jsx]"]
  node_cart["Cart<br/>React page<br/>[Cart.jsx]"]
  node_checkout["Checkout<br/>React page<br/>[Checkout.jsx]"]
  node_cart_context["Cart state<br/>React context<br/>[CartContext.jsx]"]
  node_vercel_config["SPA deployment rules<br/>Vercel config<br/>[vercel.json]"]
end

subgraph group_backend["Express backend"]
  node_server["Express API server<br/>Node entry point<br/>[server.js]"]
  node_product_routes["Product API<br/>Express routes<br/>[products.js]"]
  node_product_model["Product model<br/>Mongoose model<br/>[Product.js]"]
end

subgraph group_external["External services"]
  node_mongodb[("MongoDB<br/>Database")]
  node_stripe["Stripe<br/>Payment service"]
  node_cloudinary["Cloudinary<br/>Media service"]
  node_auth0["Auth0<br/>Authentication service"]
  node_vercel["Vercel<br/>Static hosting"]
  node_render["Render<br/>Service hosting"]
end

node_main -->|"mounts"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_products
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_checkout
node_home -->|"adds items"| node_cart_context
node_products -->|"adds/removes items"| node_cart_context
node_cart -->|"renders and updates"| node_cart_context
node_checkout -->|"consumes cart"| node_cart_context
node_home -->|"fetches catalog"| node_product_routes
node_products -->|"fetches/filter catalog"| node_product_routes
node_product_routes -->|"queries"| node_product_model
node_product_model -->|"persists products"| node_mongodb
node_server -->|"mounts"| node_product_routes
node_server -->|"connects and seeds"| node_mongodb
node_checkout -->|"creates payment intent"| node_server
node_server -->|"uses secret-key API"| node_stripe
node_checkout -->|"uses publishable-key integration"| node_stripe
node_server -->|"uploads images"| node_cloudinary
node_app -->|"authenticates with"| node_auth0
node_vercel_config -->|"configures deployment"| node_vercel
node_main -->|"deployed to"| node_vercel
node_server -->|"deployed to"| node_render

click node_main "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/main.jsx"
click node_app "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/App.jsx"
click node_home "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Home.jsx"
click node_products "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Products.jsx"
click node_cart "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Cart.jsx"
click node_checkout "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Checkout.jsx"
click node_cart_context "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/context/CartContext.jsx"
click node_vercel_config "https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/vercel.json"
click node_server "https://github.com/irfan-rg/the-xo-store/blob/main/backend/server.js"
click node_product_routes "https://github.com/irfan-rg/the-xo-store/blob/main/backend/routes/products.js"
click node_product_model "https://github.com/irfan-rg/the-xo-store/blob/main/backend/models/Product.js"

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_main,node_app,node_home,node_products,node_cart,node_checkout,node_cart_context,node_vercel_config toneBlue
class node_server,node_product_routes,node_product_model toneAmber
class node_mongodb,node_stripe,node_cloudinary,node_auth0,node_vercel,node_render toneMint
```

## Components

### React frontend

Vite SPA deployed as static content.

- [React bootstrap](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/main.jsx): Vite entry · `frontend/merch-front/src/main.jsx`
- [App composition](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/App.jsx): React router · `frontend/merch-front/src/App.jsx`
- [Home catalog](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Home.jsx): React page · `frontend/merch-front/src/pages/Home.jsx`
- [Products catalog](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Products.jsx): React page · Browses and filters product catalog. · `frontend/merch-front/src/pages/Products.jsx`
- [Cart](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Cart.jsx): React page · `frontend/merch-front/src/pages/Cart.jsx`
- [Checkout](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/pages/Checkout.jsx): React page · `frontend/merch-front/src/pages/Checkout.jsx`
- [Cart state](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/src/context/CartContext.jsx): React context · In-browser cross-page cart state. · `frontend/merch-front/src/context/CartContext.jsx`
- [SPA deployment rules](https://github.com/irfan-rg/the-xo-store/blob/main/frontend/merch-front/vercel.json): Vercel config · Provides static deployment and SPA redirects. · `frontend/merch-front/vercel.json`

### Express backend

Render-hosted API and commerce integration boundary.

- [Express API server](https://github.com/irfan-rg/the-xo-store/blob/main/backend/server.js): Node entry point · Mounts APIs and owns health, setup, payment, upload, and seed capabilities. · `backend/server.js`
- [Product API](https://github.com/irfan-rg/the-xo-store/blob/main/backend/routes/products.js): Express routes · Serves catalog retrieval and category filtering. · `backend/routes/products.js`
- [Product model](https://github.com/irfan-rg/the-xo-store/blob/main/backend/models/Product.js): Mongoose model · `backend/models/Product.js`

### External services

- **MongoDB**: Database · Source of catalog content.
- **Stripe**: Payment service · Authorizes checkout payment intents.
- **Cloudinary**: Media service · Hosts and optimizes product imagery.
- **Auth0**: Authentication service · Frontend-configured authentication integration.
- **Vercel**: Static hosting
- **Render**: Service hosting

## Connections

- React bootstrap → App composition: mounts
- App composition → Home catalog: routes to
- App composition → Products catalog: routes to
- App composition → Cart: routes to
- App composition → Checkout: routes to
- Home catalog → Cart state: adds items
- Products catalog → Cart state: adds/removes items
- Cart → Cart state: renders and updates
- Checkout → Cart state: consumes cart
- Home catalog → Product API: fetches catalog
- Products catalog → Product API: fetches/filter catalog
- Product API → Product model: queries
- Product model → MongoDB: persists products
- Express API server → Product API: mounts
- Express API server → MongoDB: connects and seeds
- Checkout → Express API server: creates payment intent
- Express API server → Stripe: uses secret-key API
- Checkout → Stripe: uses publishable-key integration
- Express API server → Cloudinary: uploads images
- App composition → Auth0: authenticates with
- SPA deployment rules → Vercel: configures deployment
- React bootstrap → Vercel: deployed to
- Express API server → Render: deployed to
