Skip to content

mahabubr/leadcommerce-server

Repository files navigation


Leadcommerce Backend

◦ Developed with the software and tools below.

JavaScript Nodemon tsnode TypeScript GitHub%20Actions JSON Express Markdown

GitHub top language GitHub code size in bytes GitHub commit activity

Table of Contents

Introduction

e-commerce management system web app. The primary goal is to manage and maintain the product. Deals with e-commerce websites for online product sales. It provides for users to purchase and maintain their products through a dashboard.

Features

  • Modular architecture for easy scalability and maintenance.
  • admin, store, employee, deliveryman authentication and authorization.
  • Secure password hashing using bcrypt.
  • JSON Web Token (JWT) based authentication.
  • CORS support for cross-origin requests.
  • MongoDB database integration via Mongoose.
  • Express.js for building RESTful APIs.
  • Environment variables management with dotenv.
  • API documentation using postman.
  • TypeScript support for improved code quality and maintainability.

Folder Structure

Here is an overview of your project's folder structure:

.
├── .husky/                     
│   └── pre-commit/     
├── .vscode/             
│   ├── setting.json/     
│   └── settings.json/ 
├── dist/              
├── src/                        # Source code directory
│   ├── App/                    # Main application code
│   │   ├── helpers/  
│   │   │   └── jwtHelpers/ 
│   │   ├── middlewares/  
│   │   │   ├── auth/ 
│   │   │   ├── globalErrorHandler/ 
│   │   │   ├── multer/ 
│   │   │   └── validationRequests/ 
│   │   ├── modules/             # Modules for various features
│   │   │   ├── Admin/ 
│   │   │   ├── Auth/            # Authentication related code
│   │   │   ├── category/ 
│   │   │   ├── dashboard/ 
│   │   │   ├── delivery/ 
│   │   │   ├── employe/ 
│   │   │   ├── events/ 
│   │   │   ├── faq/ 
│   │   │   ├── order/          # order management code
│   │   │   ├── payment/ 
│   │   │   ├── products/       # product management code
│   │   │   ├── shipment/  
│   │   │   └── store/            
│   │   ├── routes/   
│   │   │   └── index.js/
│   ├── Config/                 # Configuration files
│   │   ├── cloudinary/ 
│   │   └── index/ 
│   ├── constants/         
│   │   └── paginationConstants/ 
│   ├── enums/         
│   │   └── role/
│   ├── error/         
│   │   ├── ApiError/
│   │   ├── handleCastError/
│   │   ├── handleValidationError/
│   │   └── handleZodError/
│   ├── helper/         /
│   │   └── paginationHelper/
│   ├── interface/         
│   │   ├── common/
│   │   ├── error/
│   │   ├── pagination/
│   │   └── index.d.ts/
│   ├── shared/         
│   │   ├── catchAsync/
│   │   ├── logger/
│   │   ├── pick/
│   │   └── sendResponse/
│   ├── app.ts                   # Main application entry point
│   └── index.ts                 # Application startup script
├── .env                         # Environment variables configuration
├── .env.example
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .prettierrc
├── package.json        
├── tsconfig           
├── vercel          
└── README.md                    # Project documentation (you are here)

Prerequisites

List the prerequisites and dependencies that users need to have installed to run your application. For example:

🔧 Installation

Provide step-by-step instructions on how to install and set up your application locally. For example:

  1. Clone the ecommerce-backend repository:
git clone https://github.com/mahabubr/leadcommerce-server
  1. Install the dependencies:
npm install

Configuration

  1. Create a .env file in the root directory of the project.

  2. Add your environment variables to the .env file. Here's an example with placeholders:

     PORT = 5000
     DATABASE_URL=mongodb://localhost:27017/your-database
     CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
     CLOUDINARY_API_KEY=your-cloudinary-cloud-api-key
     CLOUDINARY_API_SECRET=your-cloudinary-cloud-api-secret-key
     SECRET=******put any secret key *******
    

    Replace the placeholders with your actual values.

Scripts

  • start: Build and start the application in production mode.
  • dev: Start the development server with automatic restart using nodemon.
  • build: Run tests, build TypeScript code, and generate TypeScript aliases.
  • test: Run tests using Jest.

Dependencies

  • bcrypt: Password hashing library.
  • cors: Cross-origin resource sharing middleware.
  • dotenv: Environment variableList management.
  • express: Web framework for Node.js.
  • jsonwebtoken: JSON Web Token (JWT) library.
  • mongoose: MongoDB object modeling for Node.js.
  • nodemailer: Email sending library.
  • swagger-ui-express: Swagger UI for API documentation.
  • yamljs: YAML to JSON parser.
  • zod: TypeScript-first schema validation library.

Environment Variables

  • PORT: The port on which the application will listen.
  • MONGO_URI: MongoDB connection URL.
  • NODE_ENV: Node.js environment (e.g., development, production).
  • BCRYPT_SALTROUND: Number of bcrypt salt rounds.
  • JWT_ACCESSTOKEN_SECRET: Secret key for JWT access tokens.
  • JWT_ACCESSTOKEN_EXP: Expiration time for JWT access tokens.

Deployment Instructions

To deploy your Node.js application using GitHub Actions, follow these simplified steps:

  1. Push Changes to GitHub: Make changes to your Node.js application code as needed.

  2. Commit Changes: Commit your changes to the main branch.

    git add .
    git commit -m "Update application code"
  3. Push to GitHub: Push the committed changes to your GitHub repository.

    git push origin main
  4. GitHub Actions: GitHub Actions will automatically trigger a workflow when changes are pushed to the main branch. This workflow performs the following tasks:

    • Builds your Node.js application.
    • Pushes a Docker image to Docker Hub.
    • Deploys the updated application to your server.
  5. Monitor Deployment: Monitor the GitHub Actions workflow progress on your GitHub repository's Actions tab. The workflow will display the status of each step, including building, pushing, and deploying.

  6. Access Deployed Application: Once the workflow is completed successfully, your Node.js application should be deployed and accessible. You can access it via the specified URL or domain name.

That's it! Your application is automatically deployed whenever you push changes to the main branch of your GitHub repository. This streamlined process minimizes manual deployment steps for users.

Releases

No releases published

Packages

No packages published

Contributors 5