Skip to content

Arpit529Srivastava/contract_testing_keploy

Repository files navigation

Microservices Project with Contract Testing using Keploy

Architecture of the project

Screenshot 2025-02-17 at 3 27 56 AM

This project consists of four microservices: user-service, order-service, payment-service, and notification-service. Each service has its own functionality and interacts with either a PostgreSQL or MongoDB database. Contract testing is implemented using Keploy to ensure the services work as expected.


Table of Contents

  1. Project Structure
  2. Services Overview
  3. Prerequisites
  4. Setup and Running the Project
  5. Endpoints

Services Overview

1. User-Service

  • Database: PostgreSQL
  • Endpoints:
    • POST /user: Create a new user in the PostgreSQL database.
    • GET /user: Retrieve user data from the PostgreSQL database.

2. Order-Service

  • Database: MongoDB
  • Endpoints:
    • POST /order: Create a new order in the MongoDB database after checking if the order ID exists in the PostgreSQL database.
    • GET /order: Retrieve order data from the MongoDB database.

3. Payment-Service

  • Functionality: Updates the payment status of an order in the MongoDB database.
  • Endpoint:
    • POST /pay: Updates the payment status by hitting the localhost:8081/order/update-payment endpoint.

4. Notification-Service

  • Functionality: Updates the email status of an order in the MongoDB database.
  • Endpoint:
    • POST /pay: Updates the email status by hitting the localhost:8081/update-email endpoint.

Prerequisites

Before running the project, ensure you have the following installed:

  • Docker
  • Docker Compose
  • Keploy (running via Docker, as it doesn't support macOS natively)

Setup and Running the Project

  1. Clone the Repository:
    git clone https://github.com/arpit529srivastava/contract_testing_keploy.git
  2. Start the Databases and Services:
    Use Docker Compose to start the PostgreSQL and MongoDB databases along with the microservices.
    docker-compose up -d
  3. Verify Services :
    Ensure all services are running by checking their respective endpoints:
- User-Service: localhost:8080/user

- Order-Service: localhost:8081/order

- Payment-Service: localhost:8082/pay

- Notification-Service: localhost:8083/pay  

Endpoints

  • User-Service:
POST /users: Create a new user.<br>
GET /users: Retrieve user data.
  • Order-Service:
POST /orders: Create a new order.
GET /orders: Retrieve user data.
  • Payment-Service:
POST /pay: Update payment status.
  • Notification-Service:
POST /notify: Update email status and send the email.

Releases

No releases published

Packages

No packages published