How basir/amazona works
Purpose and deployment shape
Amazona is a MERN marketplace/e-commerce system: product discovery, cart and checkout, PayPal payment, fulfillment, reviews, seller/admin operations, mapping, email receipts, and live support. The root Node process is the production entry point (package.json, Procfile); its API server also serves the built React application. Local development runs the API and React dev server separately.
Backend composition
backend/server.js initializes Express, environment/database connectivity, API routing, static upload/build serving, and realtime support infrastructure. Domain endpoints are partitioned by resource:
• Products, search/filtering, reviews, seller catalog: backend/routers/productRouter.js, backend/models/productModel.js
• Identity, registration, profiles, role management, seeds: backend/routers/userRouter.js, backend/models/userModel.js
• Checkout lifecycle, payment, delivery, reporting: backend/routers/orderRouter.js, backend/models/orderModel.js
• Multipart image ingestion into the local upload boundary: backend/routers/uploadRouter.js, uploads
Persistence, authorization, and integrations
MongoDB/Mongoose is the durable system of record, with schemas for users, products, and orders in backend/models/. Seed data originates in backend/data.js. JWT creation and authentication/role middleware are centralized in backend/utils.js; routers enforce customer, seller, and admin boundaries. Runtime configuration supplies MongoDB and third-party credentials. Material external services are MongoDB/Atlas, PayPal (client ID and checkout/payment flow), Google Maps, Mailgun order-email delivery, and Socket.IO-based chat. Heroku is the documented deployment target.
React application shell and navigation
frontend/src/index.js mounts the Redux-backed React application; frontend/src/App.js defines the route-level application shell and screens. Route guards separate authenticated, administrator, and seller capabilities through frontend/src/components/PrivateRoute.js, frontend/src/components/AdminRoute.js, and frontend/src/components/SellerRoute.js. Major user journeys are represented by screen modules such as catalog/product views, checkout/order views, profile/history, support, and administrative dashboards under frontend/src/screens/.
Client state and API orchestration
Redux is the client-side control plane: frontend/src/store.js combines domain reducers; async API calls live in frontend/src/actions/; request lifecycle and persisted user/cart/checkout state are represented in frontend/src/reducers/ and frontend/src/constants/. Product browsing flows from screens through productActions.js to product APIs and back into product reducers. Equivalent action/reducer pipelines handle authentication, cart/shipping/payment, and orders (frontend/src/actions/cartActions.js, frontend/src/actions/orderActions.js, frontend/src/actions/userActions.js).
Primary business flow
Catalog/search screens load paginated, filtered products; product detail adds seller-constrained items to the cart. Checkout captures shipping and payment selections, then creates an order via the order API. The order screen loads PayPal configuration, completes payment, and refreshes payment/delivery state. Backend payment completion persists order changes and can send a Mailgun receipt. Customers then inspect history/profile; sellers manage their products/orders; admins manage users, products, orders, and dashboard data.
Realtime and client integration boundaries
The client communicates with the API via action-layer HTTP calls and carries JWT credentials for protected operations. frontend/src/components/ChatBox.js and frontend/src/screens/SupportScreen.js form the customer/support realtime surface backed by Socket.IO initialized from backend/server.js. Mapping is isolated to frontend/src/screens/MapScreen.js and checkout address capture, while product image upload crosses from product-edit UI to backend/routers/uploadRouter.js and the uploads filesystem.
Main entry points: server.js Express server · orderRouter.js Order API · utils.js JWT auth & roles · App.js App routes & screens
Components 20
React client
- React bootstrap · Mounts the Redux-backed application.
frontend/src/index.js - App routes & screens · Hosts catalog, checkout, account, seller, and admin journeys.
frontend/src/App.js - Capability route guards · Separates authenticated, admin, and seller routes.
frontend/src/components/PrivateRoute.js - Redux state · Combines persisted user, cart, checkout, and request state.
frontend/src/store.js - API action layer · Orchestrates product, cart, order, and user API calls.
frontend/src/actions/productActions.js - Support chat · Customer and support chat surface.
frontend/src/components/ChatBox.js - Address mapping · Map and checkout address capture boundary.
frontend/src/screens/MapScreen.js
Node API
- Express server · Initializes APIs, static React serving, uploads, and Socket.IO.
backend/server.js - JWT auth & roles · Centralizes token creation and customer, seller, admin authorization.
backend/utils.js - Product API · Catalog, search, reviews, and seller catalog operations.
backend/routers/productRouter.js - User API · Registration, profiles, roles, and seed operations.
backend/routers/userRouter.js - Order API · Checkout, payment, delivery, and reporting lifecycle.
backend/routers/orderRouter.js - Image upload API · Multipart image ingestion boundary.
backend/routers/uploadRouter.js
Data & integrations
- Mongoose domain models · Users, products, and orders are the durable domain record.
- Uploaded images
uploads - MongoDB / Atlas · Production durable datastore.
- PayPal · Checkout configuration and payment completion.
- Mailgun · Order receipt delivery.
- Socket.IO · Live support messaging transport.
- Google Maps
Connections 24
- React bootstrap → App routes & screens: mounts
- React bootstrap → Redux state: provides store
- App routes & screens → Capability route guards: protects routes
- App routes & screens → API action layer: dispatches
- API action layer → Redux state: updates state
- API action layer → Express server: HTTP + JWT
- Support chat → Socket.IO: realtime messages
- Address mapping → Google Maps: maps
- Express server → JWT auth & roles: applies
- Express server → Product API: routes
- Express server → User API: routes
- Express server → Order API: routes
- Express server → Image upload API: routes
- Express server → Socket.IO: hosts
- JWT auth & roles → Product API: authorizes
- JWT auth & roles → User API: authorizes
- JWT auth & roles → Order API: authorizes
- Product API → Mongoose domain models: uses products
- User API → Mongoose domain models: uses users
- Order API → Mongoose domain models: uses orders
- Mongoose domain models → MongoDB / Atlas: persists
- Image upload API → Uploaded images: stores images
- Order API → PayPal: processes payment
- Order API → Mailgun: sends receipts