How irfan-rg/the-xo-store works
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: App.jsx App composition · server.js Express API server · Checkout.jsx Checkout · products.js Product API
Components 17
React frontend
Vite SPA deployed as static content.
- React bootstrap
frontend/merch-front/src/main.jsx - App composition
frontend/merch-front/src/App.jsx - Home catalog
frontend/merch-front/src/pages/Home.jsx - Products catalog · Browses and filters product catalog.
frontend/merch-front/src/pages/Products.jsx - Cart
frontend/merch-front/src/pages/Cart.jsx - Checkout
frontend/merch-front/src/pages/Checkout.jsx - Cart state · In-browser cross-page cart state.
frontend/merch-front/src/context/CartContext.jsx - SPA deployment rules · Provides static deployment and SPA redirects.
frontend/merch-front/vercel.json
Express backend
Render-hosted API and commerce integration boundary.
- Express API server · Mounts APIs and owns health, setup, payment, upload, and seed capabilities.
backend/server.js - Product API · Serves catalog retrieval and category filtering.
backend/routes/products.js - Product model
backend/models/Product.js
External services
- MongoDB · Source of catalog content.
- Stripe · Authorizes checkout payment intents.
- Cloudinary · Hosts and optimizes product imagery.
- Auth0 · Frontend-configured authentication integration.
- Vercel
- Render
Connections 23
- 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