How bradtraversy/proshop-v2 works
Project type and purpose
• This is a full-stack eCommerce platform (“ProShop v2”) built with the MERN stack (MongoDB, Express, React, Node) plus Redux Toolkit/RTK Query.
• Provides product browsing, shopping cart, checkout (shipping/payment), order management, user profiles, and admin CRUD (products, users, orders).
File structure
• Top-level separation into backend/ and frontend/ directories (standard client–server split).
• backend/ follows an MVC/layered structure:
• config (DB connection)
• models (Mongoose schemas)
• controllers (business logic)
• routes (Express endpoints)
• middleware (auth, error handling, ID checking, async wrapper)
• utils (JWT token gen, PayPal helper, price calc)
• seeder script (populate/destroy sample data)
• server.js (app setup, static file serving in production)
• frontend/ is a React SPA (CRA) with:
• src/components (reusable UI bits, protected/admin route wrappers)
• src/screens (page-level containers: Home, Product, Cart, Checkout steps, Admin screens)
• src/slices (Redux Toolkit slices and RTK Query API slices)
• src/store.js (store configuration)
• src/utils (cart helpers)
• react-router for routing, Bootstrap for styling.
• Root also contains deployment artifacts: .env.example, uploads/ for image storage, package.json scripts (dev, server, build).
Key insights from the README
• Project description, feature list (cart, reviews, pagination, search, admin CRUD, PayPal & card payments).
• Env vars: MongoDB URI, JWT_SECRET, PayPal client ID, pagination limit, PORT.
• Run commands: npm run dev to launch concurrently front (3000) & back (5000).
• Production build: front npm run build → served from backend's static folder.
• Seeder commands to import/destroy sample data.
• Client (React SPA)
• API Server (Node/Express)
• Database (MongoDB Atlas or self-hosted)
• File Storage (uploads folder, served via Express static)
• External Payment Service (PayPal REST API)
1. User → React SPA: HTTP(S) to port 3000 (dev) or served static (prod)
2. React SPA → Express API: RESTful calls under /api (products, users, orders, upload)
3. API Server → MongoDB: Mongoose queries for models (Product, User, Order)
4. API Server → File System (or S3): file uploads via multer, stored in uploads/
5. API Server → PayPal: payment creation/verification via PayPal SDK util
6. React SPA uses Redux Toolkit & RTK Query to manage state and caching of API calls
c. Architectural patterns & design principles:
• Client–Server separation
• Layered backend (Router → Controller → Service/Model → DB)
• MVC-style Organization on backend
• Unidirectional data flow on frontend (React → Redux actions → RTK Query → API → Redux store → React)
• Middleware for cross-cutting concerns (auth, error handling, async)
• Token-based authentication (JWT in HTTP-only cookie)
d. Key technologies & frameworks (annotate components):
• React, React Router, Redux Toolkit, RTK Query, Bootstrap (frontend)
• Node.js, Express, Mongoose, MongoDB, multer, dotenv, jsonwebtoken, bcrypt, PayPal SDK (backend)
Detail without over-splitting
• uploadRoutes → multer → uploads folder if image handling is critical.
• Don’t forget static asset serving in production: Express static middleware pointing to /frontend/build or /frontend/dist.