How ayub-alikhan-j/shree_jewel works
Project type and purpose
• ShreeJewel is a full-stack e-commerce web application.
• Front-end: React + Vite SPA (client/)
• Back-end: Node.js + Express REST API (server/)
• Data stores and external services: MongoDB, Cloudinary (image uploads), Razorpay & PayPal (payments).
a. Client SPA
• Pages & components (shopping, auth, admin)
• Redux store slices (auth, shop, admin)
b. API Server
• HTTP endpoints (routes/controllers: auth, shop, admin, common, webhooks)
• Business logic (controllers/helpers/models)
• Env validation & middleware (server/config/validateEnv.js)
c. Database
• MongoDB (collections: Users, Products, Orders, Cart, Reviews, etc.)
d. External services
• Cloudinary (image upload)
• Razorpay & PayPal (payment flows)
Dataflow and interactions
1. User opens the SPA in the browser.
2. SPA reads configuration (VITE_API_BASE_URL) and renders UI.
3. For any action (login, fetch products, add to cart, place order):
• SPA dispatches Redux action → async API call to Express endpoints.
4. Express middleware verifies JWT or session.
5. Controller invokes model methods (Mongoose) → MongoDB queries/updates.
6. If uploading images, server helper uploads to Cloudinary and returns URL.
7. For checkout: server helper initiates Razorpay/PayPal transaction → returns payment link/tokens to client.
8. Payment provider sends webhook → server route/webhook controller verifies and updates Order record.
9. Final status (success/failure) returns to client, which updates store & UI.
Architectural patterns & design principles
• Front-end: Component-based design, unidirectional data flow (Redux).
• Back-end: MVC-style separation (routes → controllers → models), single Express app.
• Infrastructure as code: docker-compose, Nginx config, scripts for HTTPS.
• 12-factor app: environment variables, separate build steps, externalized configs.