Skip to content

Anusree6154s/qkart-backend

Repository files navigation

QKart Backend

Backend for QKart - An E-commerce application

View QKart BackendView QKart FrontendView API Documentation

Table of Contents

  1. Project Overview
  2. Setup Instructions
  3. Project Breakdown

Project Overview

QKart is an E-commerce application providing a wide range of products for users. This project focuses on the backend development, implementing robust REST APIs and ensuring secure user interactions.

Tech Stack

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose ODM
  • Passport.js
  • JOI Validation
  • Jest Framework

Features

  • User registration and authentication via JWT.
  • Secure API endpoints with token-based authentication.
  • Management of user shopping carts (add, update, remove products).
  • Checkout process with integration tests to ensure functionality.
  • Comprehensive API documentation for developers.

Setup Instructions

  • Backend

    • Installation

      # clone repo
      git clone https://github.com/Anusree6154s/qkart-backend-2
      cd qkart-backend-2
      
      # install dependencies
      npm install
    • Set Up Environment Variables in server

      Create a .env file in the root directory and add the following configurations:

      JWT_ACCESS_EXPIRATION_MINUTES = your_jwt_exp_minutes
      JWT_REFRESH_EXPIRATION_DAYS = your_jwt_exp_days
      JWT_SECRET = your_jwt_secret
      MONGODB_URL = your_mongodb_uri
      NODE_ENV = development
      PORT = your_desired_port_other_than_8081 # PORT 8081 is client port
      
    • Running the Server

      npm start
  • Frontend

    • Running the Client

      For the frontend, navigate to the frontend directory and run:
      cd ../frontend
      npm install
      npm start

Project Breakdown

Project Structure for backend

qkart-backend/
│
└── src/
    ├── api-doc/
    │   ├── docs.html
    |   ├── logo.png
    |   └── swagger.js
    ├── config/
    │   ├── config.js
    |   ├── passport.js
    |   └── tokens.js
    ├── controllers/
    │   ├── auth.controller.js
    |   ├── cart.controller.js
    │   ├── index.js
    |   ├── product.controller.js
    |   └── user.controller.js
    ├── middlewares/
    │   ├── auth.js
    |   ├── error.js
    |   └── validate.js
    ├── models/
    |   ├── cart.model.js
    │   ├── index.js
    |   ├── product.model.js
    |   └── user.model.js
    ├── routes/
    |   └── v1/
    |      └── auth.route.js
    |      ├── cart.route.js
    |      ├── index.js
    |      ├── product.route.js
    |      ├── swagger.route.js
    |      └── user.route.js
    ├── services/
    │   ├── auth.service.js
    |   ├── cart.service.js
    |   ├── index.js
    │   ├── product.service.js
    |   ├── token.service.js
    |   └── user.service.js
    ├── utils/
    │   ├── ApiError.js
    |   ├── catchAsync.js
    |   └── pick.js
    ├── validations/
    │   ├── auth.validation.js
    |   ├── cart.validation.js
    |   ├── custom.validation.js
    │   ├── index.js
    |   ├── product.validation.js
    |   └── user.validation.js
    ├── app.js
    └── index.js

Technical Architecture

  • Components

    • Backend:
      • Node.js & Express.js: For building a robust REST API, chosen for their non-blocking architecture and scalability, making it ideal for handling multiple requests simultaneously.
    • Database:
      • MongoDB & Mongoose: Used for flexible data storage and easy data manipulation.
  • Design Pattern

    • Layered Architecture: This approach helps in separating concerns, making the code more maintainable and scalable.

      QKart Layered Architecture
  • Deployment Architecture

    • Hosting: The application is deployed on Render for ease of use and automatic deployments.
    • Server: Node.js server for handling requests.
  • Security

    • Authentication: JWT (JSON Web Tokens) for secure user authentication.

      JWT Token authentication flow for QKart APIs

Features Implemented

  • User Registration: Allows new users to create an account.
  • User Authentication: Secure login process using JWT tokens.
  • Shopping Cart Management: APIs for adding, updating, and removing items from the cart.
  • Checkout Process: Finalizes purchases and handles payment logic.

Potential Improvements

  • Wishlist functionality for users.
  • User reviews and ratings for products.
  • Admin dashboard for managing products and users.
  • Enhanced error handling and logging mechanisms.

qkart-backend-2-demo-gif