How abhishekak411/vmern-ecommerce works
Project type and purpose
• This is a MERN‐stack (MongoDB, Express, React, Node) e‑commerce prototype.
• Supports two roles:
• Users: browse/search products, add to cart, checkout, view order history.
• Sellers: perform CRUD on products, view/manage their inventory.
• Uses JSON Web Tokens for authentication/authorization, custom email/password validation, and BcryptJS for password hashing.
File structure
• Top‐level separation:
• client/ → React front end
• server/ → Node/Express back end
• client/:
• public/ → static HTML, manifest, robots.txt
• src/ → App.js, style files, reportWebVitals, setupTests
• src/Components/ → feature‑grouped React components (Cart, Category, Global, HOC, Helpers, Home, Multiple‑Products, Newest, Product, Single, User)
• src/Context/ → authContext for global auth state
• src/Helpers/apiConfig.js → base URL and HTTP helper
• tailwind.config.js → styling config
• server/:
• index.js → Express app entry point
• controllers/ → prod.cont.js, seller.cont.js, user.cont.js (business logic)
• routes/ → allRoutes.js, prodRoutes.js, sellerRoutes.js, userRoutes.js (routing)
• middlewares/ → sellerAuth.js, userAuth.js (JWT validation)
• models/ → Mongoose schemas: defproduct.js, users.js, orders.js
• utils/ → emailValidator.js, passwordValidator.js
• JSON/products.json → seed data endpoint
• Config & build scripts: .env variables, package.json in both client and server.
Key insights from README
• Lists all React routes with their purposes (/, /login, /register, /addProducts, /sellerProducts, /single/:id, /cart, /mens, /womens, /electronics, /newest).
• Defines backend API under base path http://localhost:{port}/app/auth with user, product, seller endpoints.
• Mentions JWT secret, MongoDB URL, and startup scripts for server & client.
Step‑by‑step sketch plan
• Middleware layer (userAuth, sellerAuth)
• Routers (userRoutes, prodRoutes, sellerRoutes)
• Controllers
6. Off to the side, show utilities: emailValidator.js, passwordValidator.js, JSON seed loader, indicating controllers call them.