How suhassalian27/e-commerce-website-using-reactjs-nodejs works
Project Type and Purpose
• This is a full-stack e-commerce web application built on the MERN stack.
• Frontend: React + Redux; Backend: Node.js + Express; Database: MongoDB (via Mongoose); Authentication: JWT.
File Structure
• Top-level “frontend” and “backend” folders – clear separation of concerns.
• Frontend:
• public/ – static HTML/CSS (index.html, manifest, images)
• src/ – React components (Screens/ & reusable components), Redux (actions, reducers, store), serviceWorker
• Backend:
• models/ – Mongoose schemas (userModel, productModel)
• routes/ – Express routers (userRoute, productRoute)
• server.js – Express app entry point, middleware setup
• config/data.js & util.js – initial data injection, utility functions
• Root: .babelrc, package.json for build tooling; template/ – legacy/static demonstration files.
README for Additional Insights
• Uses React-Bootstrap for UI, Axios for HTTP
• RESTful API endpoints for products, users, orders
• Features: signup/signin (with JWT), admin product CRUD, cart workflow, order placement
• Dev & Deploy notes: local npm scripts, MongoDB prerequisite
Main Components
a. Client Layer (Browser)
• React App:
• Screens (Home, ProductDetail, Cart, Checkout, Admin)
• Components (Carousel, CheckoutSteps, Form controls)
• Redux Store (reducers for cart, user, products; actions invoking Axios)
b. API Layer (Express Server)
• Route Handlers (userRoute, productRoute)
• Middleware (bodyParser, JWT auth guard, error handlers)
• Controllers/Models (Mongoose interacts with MongoDB)
c. Data Layer
• MongoDB Database (collections: users, products, orders)
d. External Services (optional / future)
• Payment Gateway (Stripe placeholder)
• Image storage (local/public/images or cloud)
e. Deployment (optional)
• Node server hosted on Heroku/AWS; React hosted on Netlify or served statically.
Relationships & Data Flow
• Browser → React UI: user interacts with components
• React → Redux store: updates UI state (cart, user, products)
• Redux actions → Axios HTTP calls → Express routes
• Express route → Controller → Mongoose model → MongoDB
• MongoDB → Mongoose → Express → JSON response → React → Redux → UI
• JWT token passed in HTTP headers for protected routes
Architectural Patterns & Design Principles
• Frontend: Component-based design with unidirectional data flow (Redux)
• Backend: RESTful API, MVC-inspired separation (routes/controllers/models)
• Stateless authentication using JWT; middleware enforces RBAC (user vs. admin)
• Single source of truth for application state in Redux
Detailed Callouts
• Frontend static assets served from public/ or via build pipeline
• serviceWorker registration for PWA capabilities
• util.js for helper functions in backend
• data.js seed script – illustrate optional initialization process