Giter Club home page Giter Club logo

ecommerce-order-service's Introduction

Order Service

The Order Service is a backend service responsible for handling order management in an e-commerce application. This service allows for creating orders, retrieving order details, and processing orders through integration with other services like Product and User services.

Features

  • Create new orders with product and user details.
  • Retrieve all orders.
  • Retrieve orders by user ID.
  • Integration with RabbitMQ for message queuing.
  • RESTful API architecture.

Technologies Used

  • Node.js
  • Express.js
  • Sequelize (ORM)
  • PostgreSQL (Database)
  • Axios (HTTP Client)
  • RabbitMQ (Message Broker)

Table of Contents

Installation

To set up the Order Service locally, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/order-service.git
    cd order-service
  2. Install dependencies:

    npm install
  3. Set up your environment variables: Create a .env file in the root directory and add your database and RabbitMQ configurations.

    DB_HOST=localhost
    DB_USER=your_db_user
    DB_PASSWORD=your_db_password
    DB_NAME=your_db_name
    RABBITMQ_URL=amqp://localhost
  4. Run database migrations:

    npx sequelize-cli db:migrate
  5. Start the service:

    npm start

Usage

Once the service is running, you can interact with the API at http://localhost:3000. Use tools like Postman or cURL to test the endpoints.

API Endpoints

Create Order

  • URL: /orders
  • Method: POST
  • Request Body:
    {
      "productId": ["123", "456"],
      "userId": "789",
      "quantity": [2, 1],
      "price": [29.99, 59.99]
    }
  • Request Body:
    {
      "id": 1,
      "userId": "789",
      "email": "[email protected]",
      "productName": ["Product1", "Product2"],
      "totalAmount": 119.97,
      "createdAt": "2024-05-21T14:09:55.418Z",
      "updatedAt": "2024-05-21T14:09:55.418Z"
    }

Create Order

  • URL: /orders
  • Method: GET
  • Response:
    [
      {
        "id": 1,
        "userId": "789",
        "email": "[email protected]",
        "productName": ["Product1", "Product2"],
        "totalAmount": 119.97,
        "createdAt": "2024-05-21T14:09:55.418Z",
        "updatedAt": "2024-05-21T14:09:55.418Z"
      }
    ]

Related Projects

Future Improvements

Feature Enhancements

  • Implement user profile creation and update functionality.

Security Enhancements

  • Configure JWT token expiration time to be customizable.

Testing

  • Add unit tests to increase the reliability of the API.
  • Create integration tests to validate API behavior in different scenarios.

General Improvements

  • Utilize linter and formatter tools for code cleanliness.
  • Regularly update dependencies and stay informed about security vulnerabilities.

ecommerce-order-service's People

Contributors

batuncer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.