A full-stack e-commerce application built with MongoDB, Express.js, React (Next.js), and Node.js.
- User Management: User registration, login, and profile management
- Admin Panel: Admin authentication and user management
- Product Management: CRUD operations for products
- Shopping Cart: Add/remove products to/from cart
- Checkout System: Complete purchase workflow
- Authentication: JWT-based authentication for users and admins
- Responsive Design: Built with Tailwind CSS for mobile-first design
- Next.js 16 - React framework with server-side rendering
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client for API requests
- React 19 - Latest React version
- Node.js - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Tokens for authentication
- CORS - Cross-origin resource sharing
NodeShop/
├── client/ # Next.js frontend application
│ ├── app/ # App router pages and components
│ │ ├── admin/ # Admin dashboard pages
│ │ ├── cart/ # Shopping cart functionality
│ │ ├── checkout/ # Checkout process
│ │ ├── components/ # Reusable UI components
│ │ ├── login/ # User authentication
│ │ ├── products/ # Product listing and details
│ │ └── register/ # User registration
│ ├── public/ # Static assets
│ └── package.json # Frontend dependencies
└── server/ # Express.js backend application
├── controllers/ # Request handlers
│ ├── adminlogin/ # Admin authentication logic
│ ├── user/ # User management logic
│ └── Products.js # Product management logic
├── models/ # MongoDB schemas
│ ├── Admin.js # Admin model
│ ├── User.js # User model
│ └── Products.js # Product model
├── routes/ # API route definitions
├── middleware/ # Authentication middleware
├── service/ # Business logic services
└── package.json # Backend dependencies
- Node.js (v18 or higher)
- MongoDB (local installation or MongoDB Atlas)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd NodeShop
-
Install server dependencies
cd server npm install -
Install client dependencies
cd ../client npm install -
Environment Setup
Create a
.envfile in the server directory:MONGODB_URI=mongodb://127.0.0.1:27017/NodeShopMern JWT_SECRET=your_jwt_secret_key PORT=5000
-
Start MongoDB
Make sure MongoDB is running on your system or configure MongoDB Atlas connection.
-
Start the backend server
cd server npm startServer will run on
http://localhost:5000 -
Start the frontend application
cd client npm run devClient will run on
http://localhost:3000
POST /admin/login- Admin loginPOST /user/register- User registrationPOST /user/login- User login
GET /user/all- Get all users (Admin only)PUT /user/status/:id- Update user status (Admin only)
GET /Products- Get all productsPOST /Products- Create new product (Admin only)PUT /Products/:id- Update product (Admin only)DELETE /Products/:id- Delete product (Admin only)
The application uses JWT (JSON Web Tokens) for authentication:
- Users receive a token upon successful login
- Protected routes require valid JWT token
- Admin routes have additional role-based access control
- Responsive Design: Mobile-first approach with Tailwind CSS
- TypeScript: Type safety throughout the application
- Next.js App Router: Modern routing with server components
- Toast Notifications: User feedback with nextjs-toast-notify
- Form Validation: Client-side validation for better UX
- Email, password, name
- Status (active/inactive)
- Role-based permissions
- Admin credentials and permissions
- User management capabilities
- Product details (name, price, description)
- Inventory management
- Category classification
- Set environment variables for production
- Configure MongoDB connection string
- Deploy to platforms like Heroku, Railway, or DigitalOcean
- Build the Next.js application:
npm run build - Deploy to Vercel, Netlify, or similar platforms
- Configure API endpoints for production
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -m 'Add feature' - Push to branch:
git push origin feature-name - Submit a pull request
This project is licensed under the ISC License.
If you encounter any issues, please create an issue on the repository with:
- Description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details
For support and questions, please open an issue on the repository.