How isamitprajapati/full-stack-e-commerce-mern-app works
Project type and purpose
• This is a full‑stack e‑commerce web application built with the MERN stack (MongoDB, Express, React, Node.js).
• Purpose: allow users to browse, search, and purchase products; and provide an admin interface for product and user management.
File structure
• Top‑level directories “frontend” and “backend” clearly separate client and server code.
• “backend” follows an MVC‑style layout:
• config: database connection
• controllers: product and user controllers (filter, search, cart operations, auth)
• models: Mongoose schemas for users, products, cart items
• middleware: JWT authentication
• routes: maps HTTP endpoints to controller actions
• “frontend” is a React app with:
• public: static HTML
• src/components, src/pages: reusable UI & page views
• src/context, src/store: application state (Context API + Redux Toolkit)
• src/helpers: utility functions (API calls, image upload, formatting)
• tailwind.config.js: styling
Extract additional insights from README
• Uses JWT for auth (TOKEN_SECRET_KEY), MongoDB Atlas (MONGODB_URI)
• Cloudinary for image storage (REACT_APP_CLOUD_NAME_CLOUDINARY)
• RESTful API endpoints on the server, async calls from client
Main components and interactions
a. Client Browser / React Frontend
• Pages (Home, ProductDetails, Cart, AdminPanel, etc.)
• State management (Redux store + Context)
• Helpers invoking REST API over HTTP
b. Backend API (Node.js + Express)
• Route layer receives incoming requests
• Auth middleware verifies JWT
• Controllers implement business logic (user signup/login, CRUD for products, cart operations)
• Models (Mongoose) communicate with MongoDB
c. Database: MongoDB Atlas
d. File‐storage / CDN: Cloudinary (for product images)
e. External services: optional payment gateway or email service (if added later)
Relationships and data flows
• User in browser → triggers UI action → Redux/Context dispatch → helper invokes HTTP request
• HTTP request → Express route → auth middleware (if protected) → controller → model → MongoDB
• Controller response → JSON → sent back to client → store updates UI
• Image upload workflow: client → Cloudinary SDK/API → returns image URL → stored in product document in MongoDB
• Admin flows: similar but with additional role‑based permission checks (permission.js)
Architectural patterns & design principles
• Client‑Server separation (React vs Node/Express)
• MVC style on the backend (routes → controllers → models)
• RESTful API endpoints
• Stateless authentication with JWT
• Centralized state management (Redux + Context)
• Environment‑driven configuration (dotenv)
Technologies & frameworks
• Frontend: React, Redux Toolkit, Context API, Tailwind CSS
• Backend: Node.js, Express, Mongoose
• Database: MongoDB Atlas
• Auth: JSON Web Tokens
• Image Storage: Cloudinary