Skip to content

Backend-node/NodeShop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NodeShop - E-commerce MERN Application

A full-stack e-commerce application built with MongoDB, Express.js, React (Next.js), and Node.js.

πŸš€ Features

  • 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

πŸ› οΈ Tech Stack

Frontend (Client)

  • 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

Backend (Server)

  • 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

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local installation or MongoDB Atlas)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd NodeShop
  2. Install server dependencies

    cd server
    npm install
  3. Install client dependencies

    cd ../client
    npm install
  4. Environment Setup

    Create a .env file in the server directory:

    MONGODB_URI=mongodb://127.0.0.1:27017/NodeShopMern
    JWT_SECRET=your_jwt_secret_key
    PORT=5000
  5. Start MongoDB

    Make sure MongoDB is running on your system or configure MongoDB Atlas connection.

Running the Application

  1. Start the backend server

    cd server
    npm start

    Server will run on http://localhost:5000

  2. Start the frontend application

    cd client
    npm run dev

    Client will run on http://localhost:3000

πŸ“š API Endpoints

Authentication

  • POST /admin/login - Admin login
  • POST /user/register - User registration
  • POST /user/login - User login

User Management

  • GET /user/all - Get all users (Admin only)
  • PUT /user/status/:id - Update user status (Admin only)

Products

  • GET /Products - Get all products
  • POST /Products - Create new product (Admin only)
  • PUT /Products/:id - Update product (Admin only)
  • DELETE /Products/:id - Delete product (Admin only)

πŸ” Authentication

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

🎨 Frontend Features

  • 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

πŸ—„οΈ Database Models

User Model

  • Email, password, name
  • Status (active/inactive)
  • Role-based permissions

Admin Model

  • Admin credentials and permissions
  • User management capabilities

Product Model

  • Product details (name, price, description)
  • Inventory management
  • Category classification

πŸš€ Deployment

Backend Deployment

  1. Set environment variables for production
  2. Configure MongoDB connection string
  3. Deploy to platforms like Heroku, Railway, or DigitalOcean

Frontend Deployment

  1. Build the Next.js application: npm run build
  2. Deploy to Vercel, Netlify, or similar platforms
  3. Configure API endpoints for production

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit changes: git commit -m 'Add feature'
  4. Push to branch: git push origin feature-name
  5. Submit a pull request

πŸ“ License

This project is licensed under the ISC License.

πŸ› Issues

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

πŸ“ž Support

For support and questions, please open an issue on the repository.

About

NodeShop - E-commerce MERN Application A full-stack e-commerce application built with MongoDB, Express.js, React (Next.js), and Node.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors