How premgchavan/fs-18-webfundamentals works
Project Type and Purpose
• At the root this repo is a catch-all for MERN-stack class materials (HTML/CSS/JS, React, Node/Express).
• Among dozens of mini-apps, the folder “ecommerceProject” exemplifies a full-stack MERN application with: user auth, product catalog, cart, coupons, file uploads, protected routes.
File Structure of ecommerceProject
• ecommerceProject/
• backend/
– controllers/ (userController.js, productController.js, cartController.js, couponController.js)
– models/ (userModel.js, productModel.js, cartModel.js, couponModel.js)
– routes/ (authRoutes.js, productRoutes.js, cartRoutes.js, couponRoutes.js, ecomRoutes.js)
– middlewares/ (authMiddleware.js, upload.js)
– services/ (cloudinaryUpload.js, tokenGenerate.js)
– utils/ (generateRandomCrypto.js)
– index.js (Express app entry point)
• frontend/
– public/ (index.html, static assets)
– src/
· App.jsx, ProtectedRoute.jsx, axiosConfig.js
· components/ (Header, Footer, DisplayProducts, etc.)
· pages/ (Home.jsx, Cart.jsx, Login.jsx, SingleProduct.jsx, Wishlist.jsx)
– tailwind.config.js, postcss.config.js, vite.config.js
README Insights
• This lab is part of a MERN-stack curriculum.
• React Client (Browser)
• Express API Server
• MongoDB Database
• Cloudinary (External File-Storage Service)
• JWT Auth Service (token generation/validation)
• React → Express (HTTPS calls via Axios)
• Express Controllers → Models (Mongoose) → MongoDB
• Express File-upload Endpoint → Cloudinary SDK
• AuthMiddleware intercepts API calls → verifies JWT → forwards to controller
• React ProtectedRoute reads token → blocks/unblocks UI routes
c. Architectural Patterns & Principles:
• Frontend: SPA, component-based, client-side routing, protected routes
• Backend: MVC-style (Routes → Middleware → Controllers → Models), service layer for cross-cutting concerns
• Separation of concerns: file-upload and token logic in “services”
d. Technologies & Frameworks:
• Frontend: React (Vite), Tailwind CSS, Axios
• Backend: Node.js, Express.js, Mongoose (MongoDB ORM)
• Auth: JSON Web Tokens
• File Storage: Cloudinary
Detail but Maintain Clarity
• JWT flow: Login → Token issuance → Authorization header on subsequent calls → AuthMiddleware.
• File-upload flow: React FileUpload component → /api/products/upload → cloudinaryUpload service → Cloudinary.
• Boundary with the technology in use (e.g. “Axios (HTTPS)”, “Mongoose”).