Skip to content

Commit

Permalink
Merge pull request #80 from NashTech-Labs/feature/readme
Browse files Browse the repository at this point in the history
updated readme
  • Loading branch information
shivamm31 authored Jan 24, 2024
2 parents 646a247 + a62b37f commit 4204546
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 43 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
[![car-demo-common-service](https://github.com/NashTech-Labs/car-demo/actions/workflows/service-pipeline.yml/badge.svg)](https://github.com/NashTech-Labs/car-demo/actions/workflows/service-pipeline.yml)
# Car Demo

* [About Car Demo](#about-car-demo)
* [Key technical benefits](#key-technical-benefits)
* [System functionality](#system-functionality)
* [Architecture](#architecture)
* [Get the source code](#get-the-source-code)
* [Getting Started for Local](#getting-started-for-local)
* [GCP Infrastructure and Deployment](#gcp-infrastructure-and-deployment)
* [GCP Infrastructure by using Terraform](#gcp-infrastructure-by-using-terraform)
* [Deploy Services via Github Action](#deploy-services-via-github-action)
* [Data Analytics and Visualization](#data-analytics-and-visualization)
* [Documentation](#documentation)
* [How to merge a feature](#how-to-merge-a-feature)
* [Next Features to be implemented](#next-features-to-be-implemented)


# About Car Demo
We are developing an eCommerce platform dedicated to the sale of cars. Users will have the capability to search for products, place orders through a shopping cart, and complete payments. The platform will also incorporate inventory management for efficient tracking. Additionally, a secure centralized data platform will be established to support data analytics and facilitate the implementation of AI/ML use cases.

Key technical benefits
Expand Down Expand Up @@ -61,18 +78,18 @@ You can include this environment property in IntelliJ by navigating to the upper
The listed services are operate sequentially.

***Phase-1***
- admin-service
- inventory-service
- admin-service [README.md](admin-service/README.md)
- inventory-service [README.md](inventory-service/README.md)
- order-service [README.md](order-service%2FREADME.md)
- payment-service [README.md](payment-service/README.md)
- shipment-service
- elasticsearch
- shipment-service [README.md](shipment-service/README.md)
- elasticsearch [README.md](elastic-search/README.md)

***Phase-2***
- cart-service
- cart-service [README.md](cart-service/README.md)

***Phase-3***
- car-ui
- car-ui [README.md](car-ui/README.md)

Now open a browser on this urls

Expand Down
54 changes: 54 additions & 0 deletions cart-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Cart Service

## Application Overview

The Cart Service is a meticulously designed component that facilitates customers in selecting items from the store's website and managing their shopping carts. It leverages a robust architecture to handle the complexities of cart management, providing a seamless experience for users.

### Prerequisites
We must configure MySQL as the persistent store destination.

![cart-service-config.png](https://i.postimg.cc/1z7yX0RY/cart-service-config.png)

### Local setup
- Setup axon-server and MySQL docker images
```
local-dev > docker compose up -d
```
- Run the application
```
cart-service > mvn clean springboot:run
```
- Endpoint for resting
- Generate a request for add to cart.
```arm
curl --location 'http://localhost:9094/cart/add' \
--header 'Content-Type: application/json' \
--data '{
"productId": "199",
"quantity": 1,
"userId": "1652"
}'
```
- Generate a request for remove to cart.
```arm
curl --location 'http://localhost:9094/cart/remove' \
--header 'Content-Type: application/json' \
--data '{
"productId": "205",
"quantity": 1,
"userId": "1652"
}'
```
- Generate a request to get cart contents.
```
curl --location 'http://localhost:9094/cart/get' \
--header 'Content-Type: application/json' \
--data '{
"userId": "1652"
}'
```

### Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.
57 changes: 20 additions & 37 deletions inventory-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,29 @@

This application is conscientiously crafted to oversee the management of available cars for sale within a system. Leveraging the Axon Framework for CQRS (Command Query Responsibility Segregation) and Event Sourcing, it seamlessly orchestrates the creation of inventory, ensures the storage of product details in a database, and adeptly publishes events to a Google Cloud Pub/Sub topic.

#### Workflow
## Prerequisites
We must set up Axon Server to handle command and query operations, and configure MySQL as the persistent store destination.

### Inventory Creation
![Screenshot from 2024-01-24 17-01-29.png](https://i.postimg.cc/W1M89wfF/inventory-service-config.png)

- It all starts with a CreateProductCommand, managed by the Inventory Aggregate class.
- The aggregate takes care of the command, leading to the triggering of the ProductCreatedEvent.
## Local setup

### Event Handling
- Setup axon-server and MySQL docker images
```
local-dev > docker compose up -d
```
- Run the application
```
inventory-service > mvn clean springboot:run
```
- Endpoint for resting
- Get product.
```
curl --location 'http://localhost:9091/products/product/199'
```

The ProductEventHandler takes care of the ProductCreatedEvent.
## Contributing

- It grabs the product information from the event.
- The details are then stored in a database through the ProductRepository.
- On top of that, the PubSubPublisherService is employed to broadcast the product details to a Google Cloud Pub/Sub topic.

### Google Cloud Pub/Sub Integration:

- The PubSubPublisherService sets up the Pub/Sub publisher when the application starts using @PostConstruct.
- It handles turning product data into a Pub/Sub message and sends it to the specified topic.
- When the application shuts down with @PreDestroy, the publisher is smoothly stopped.

### Data Storage

- Product details are persisted to a database for future reference.
- The ProductRepository handles the database interactions.

##### Key Components

### InventoryAggregate



Manages all aspects of product creation, monitors ongoing activities, and stays informed through events to ensure up-to-date awareness of the process.

### ProductEventHandler


Listens for the ProductCreatedEvent, grabs product info from the event, stores it in a database through the ProductRepository, and spreads the word about the product by sharing details on Google Cloud Pub/Sub using the PubSubPublisherService.

### PubSubPublisherService

Sets up a Google Cloud Pub/Sub publisher when the application starts, sends product information to a Pub/Sub topic, and ensures a smooth shutdown for the publisher when the application closes.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

0 comments on commit 4204546

Please sign in to comment.