A full-stack e-commerce application built with React, Node.js, and MongoDB. This project implements a modern e-commerce platform with user authentication, product management, shopping cart functionality, and order processing.
The project is organized into two main directories:
Located in the client directory, this is a React-based single-page application.
src/components/- Reusable UI componentssrc/pages/- Main application pagessrc/store/- State management (Redux/Context)src/hooks/- Custom React hookssrc/config/- Configuration filessrc/lib/- Utility functions and librariessrc/assets/- Static assets (images, fonts, etc.)
- React.js
- Vite (Build tool)
- Tailwind CSS (Styling)
- Redux/Context API (State Management)
- Axios (HTTP Client)
Located in the server directory, this is a Node.js Express server.
-
User Model (
User.js)- Implements user authentication and profile management
- Fields: userName, email, password, role
- Role-based access control (user/admin)
- Email uniqueness validation
-
Product Model (
Product.js)- Manages product catalog
- Fields: image, title, description, category, brand, price, salePrice, totalStock
- Timestamps for creation and updates
- Flexible schema for various product types
-
Order Model (
Order.js)- Handles order processing and tracking
- Fields: userId, cartId, cartItems, addressInfo, orderStatus, paymentMethod, paymentStatus
- Detailed order tracking with status updates
- Payment integration fields (paymentId, payerId)
-
Cart Model (
Cart.js)- Manages shopping cart functionality
- Tracks user's cart items and quantities
- Handles cart operations (add, remove, update)
-
Address Model (
Address.js)- Stores user shipping addresses
- Multiple addresses per user support
- Detailed address information
-
Auth Controllers (
/auth/)- User registration and login
- Password hashing and JWT token generation
- Session management
-
Admin Controllers (
/admin/)- Product CRUD operations
- User management
- Order processing
- Analytics and reporting
-
Shop Controllers (
/shop/)- Product listing and search
- Cart management
- Order processing
- Address management
-
Auth Routes (
/auth/)- POST /register - User registration
- POST /login - User authentication
- GET /profile - User profile
- PUT /profile - Profile updates
-
Admin Routes (
/admin/)- CRUD operations for products
- User management endpoints
- Order management
- Analytics endpoints
-
Shop Routes (
/shop/)- GET /products - Product listing
- GET /products/:id - Product details
- POST /cart - Add to cart
- GET /cart - View cart
- POST /orders - Place order
- GET /orders - View orders
- User registration and authentication using JWT
- Profile management with role-based access
- Secure password hashing
- Session management
- Product catalog with images
- Category and brand organization
- Price management with sale prices
- Stock tracking
- Shopping cart with persistent storage
- Multiple shipping addresses
- Order tracking and status updates
- Payment integration
- Complete product management
- User administration
- Order processing and tracking
- Sales analytics
- Node.js (v14 or higher)
- MongoDB
- npm or yarn
- Clone the repository
git clone [repository-url]- Install dependencies for both client and server
# Install server dependencies
cd server
npm install
# Install client dependencies
cd ../client
npm install- Set up environment variables
- Create
.envfiles in both client and server directories - Configure necessary environment variables (database URL, JWT secret, etc.)
- Start the development servers
# Start the server
cd server
npm run dev
# Start the client
cd ../client
npm run devThe server exposes RESTful APIs for:
- Authentication (
/api/auth) - Products (
/api/products) - Orders (
/api/orders) - Users (
/api/users)
Detailed API documentation can be found in the server's documentation.
- JWT-based authentication
- Password hashing
- Input validation
- CORS configuration
- Rate limiting
- Secure session management
- Image optimization
- Code splitting
- Lazy loading
- Caching strategies
- Database indexing
The project includes:
- Unit tests for components
- Integration tests for API endpoints
- End-to-end tests for critical user flows
The application can be deployed using:
- Frontend: Vercel, Netlify, or any static hosting
- Backend: Heroku, AWS, or any Node.js hosting platform
- Database: MongoDB Atlas or self-hosted MongoDB
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.