A full-stack e-commerce application built with the MERN stack (MongoDB, Express, React, Node.js). ByteBazaar is a modern shopping platform that allows users to browse products, add items to their cart, and complete purchases with PayPal integration.
- Features
- Tech Stack
- Project Structure
- Installation
- Configuration
- Running the Application
- API Routes
- Database Models
- Key Components
- Author
- User Authentication: Register, login, and logout functionality with JWT tokens
- Product Browsing: View all products with detailed information
- Product Ratings & Reviews: Users can rate and review products
- Shopping Cart: Add/remove items from cart with persistent storage
- Checkout Process: Multi-step checkout with shipping and payment information
- Order Management: View order history and order details
- User Profile: Update personal information and view order history
- PayPal Integration: Secure payment processing via PayPal
- Product Management: Create, update, and delete products
- Order Management: View all orders and update order status
- User Management: View all users and manage user roles
- Admin Dashboard: Access to admin-specific screens and controls
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- bcryptjs - Password hashing
- jsonwebtoken - JWT authentication
- cookie-parser - Cookie parsing middleware
- dotenv - Environment variable management
- React 18 - UI library
- Redux Toolkit - State management
- React Router v6 - Client-side routing
- React Bootstrap - UI component library
- Axios - HTTP client
- PayPal SDK - Payment integration
- React Toastify - Toast notifications
- React Icons - Icon library
ByteBazaar/
βββ backend/
β βββ config/ # Database configuration
β βββ controller/ # Route controllers (business logic)
β βββ data/ # Sample data for seeding
β βββ middleware/ # Express middleware (auth, error handling)
β βββ models/ # Mongoose schemas (User, Product, Order)
β βββ routes/ # API routes
β βββ utils/ # Utility functions
β βββ server.js # Express server entry point
β βββ seeder.js # Database seeding script
β βββ package.json
β
βββ frontend/
βββ public/ # Static assets
βββ src/
β βββ components/ # Reusable React components
β βββ screens/ # Page components
β βββ slices/ # Redux slices (state management)
β βββ utils/ # Utility functions
β βββ assets/ # Images and styles
β βββ App.js # Main App component
β βββ store.js # Redux store configuration
β βββ index.js # React entry point
βββ package.json
- Node.js (v14+) and npm
- MongoDB (local or Atlas connection)
git clone https://github.com/aashishpanthee/ByteBazaar.git
cd ByteBazaarcd backend
npm installcd frontend
npm installCreate a .env file in the /backend directory with the following variables:
PORT=5001
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/bytebazaar
JWT_SECRET=your_jwt_secret_key
PAYPAL_CLIENT_ID=your_paypal_client_id
NODE_ENV=developmentThe frontend is configured to proxy API requests to http://localhost:5001 (defined in package.json).
From the root directory:
npm run devThis will start both the Node.js server and React development server concurrently.
cd backend
npm run serverThe server will run on http://localhost:5001
cd frontend
npm startThe frontend will run on http://localhost:3000
cd backend
npm run data:importcd backend
npm run data:destroyGET /api/products- Get all productsGET /api/products/:id- Get product by IDPOST /api/products- Create product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)
POST /api/users/register- Register new userPOST /api/users/login- User loginPOST /api/users/logout- User logoutGET /api/users/profile- Get user profilePUT /api/users/profile- Update user profile
POST /api/orders- Create new orderGET /api/orders/:id- Get order by IDPUT /api/orders/:id/pay- Update order payment statusGET /api/orders/:id/deliver- Mark order as delivered (Admin)
name- User's full nameemail- Unique email addresspassword- Hashed passwordisAdmin- Administrator flag- Timestamps (createdAt, updatedAt)
name- Product nameimage- Product image URLbrand- Brand namecategory- Product categorydescription- Product descriptionprice- Product pricecountInStock- Inventory countrating- Average ratingreviews- Array of review objects with user, rating, and comment- Timestamps (createdAt, updatedAt)
user- Reference to UserorderItems- Array of items with product detailsshippingAddress- Address, city, postal code, countrypaymentMethod- Payment method usedpaymentResult- PayPal transaction detailsitemsPrice,taxPrice,shippingPrice,totalPrice- Pricing detailsisPaid,isDelivered- Status flags- Timestamps (createdAt, updatedAt, paidAt, deliveredAt)
- Header - Navigation bar with search and user menu
- Footer - Footer section
- Product - Product card display
- Rating - Star rating component
- Message - Alert/message display
- Loader - Loading spinner
- CheckoutSteps - Multi-step checkout progress indicator
- FormContainer - Centered form wrapper
- PrivateRoute - Protected route for authenticated users
- AdminRoute - Protected route for admin users
- HomeScreen - Product listing
- ProductScreen - Product details with reviews
- CartScreen - Shopping cart
- LoginScreen - User login
- RegisterScreen - User registration
- ShippingScreen - Shipping address form
- PaymentScreen - Payment method selection
- PlaceOrderScreen - Order review and confirmation
- OrderScreen - Order details and tracking
- ProfileScreen - User profile management
- AdminScreens - Product and order management for admins
- asyncHandler - Async error handling wrapper
- authMiddleware - JWT authentication and authorization
- errorMiddleware - Global error handling
Aashish Panthee
- GitHub: @aashishpanthee
ISC
Built with β€οΈ using MERN Stack