From 02937b99aedfdf3e25ddf4f77abb4c89bd861ad6 Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 13:09:23 +0530 Subject: [PATCH 1/7] updated readme --- README.md | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b9539c17..1da97ef0 100644 --- a/README.md +++ b/README.md @@ -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 @@ -61,12 +78,12 @@ 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 From 4d30fb774d99af4c721c0ae1f59d601585ce41c3 Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 16:01:32 +0530 Subject: [PATCH 2/7] added cart service readme --- README.md | 4 ++-- cart-service/README.md | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 cart-service/README.md diff --git a/README.md b/README.md index 1da97ef0..b09ecbd2 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,10 @@ The listed services are operate sequentially. - 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 diff --git a/cart-service/README.md b/cart-service/README.md new file mode 100644 index 00000000..b786e310 --- /dev/null +++ b/cart-service/README.md @@ -0,0 +1,43 @@ +# 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. + +### Workflow + +#### Cart Interaction +The core functionality revolves around customer interaction with the shopping cart. Users can add items, remove them, and view the contents of their cart. This process is managed through various commands and events. + +#### Cart Commands + +- AddToCartCommand: Initiates the addition of an item to the shopping cart. +- RemoveFromCartCommand: Triggers the removal of an item from the cart. + +#### Cart Events + +- ItemAddedToCartEvent: Raised when an item is successfully added to the cart. +- ItemRemovedFromCartEvent: Signaled upon the successful removal of an item from the cart. + +#### Event Handling + +The CartEventHandler is responsible for managing cart-related events. + +- ItemAddedToCartEventHandler: Listens for the ItemAddedToCartEvent, updates the cart status, and may perform additional actions based on business logic. +- ItemRemovedFromCartEventHandler: Listens for the ItemRemovedFromCartEvent, adjusts the cart accordingly, and performs necessary updates. + +#### Data Storage +The Cart Service ensures that cart information is efficiently stored for each customer. The CartRepository is responsible for handling data interactions related to the shopping cart. + +### Key Components + +#### CartAggregate +Manages the entire cart lifecycle, processing cart commands, and emitting events to reflect changes in the cart state. It serves as the authoritative source for cart-related operations. + +#### CartEventHandler +Handles cart-related events, updating the state of the cart based on the received events. It collaborates with the CartRepository to ensure data consistency. + +#### CartRepository +Manages the persistence of cart-related data, handling interactions with the underlying storage system to retrieve and store cart information. + + From ce642bc2dd42d6caf5bed1cb4f041610af8a3d9c Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 16:04:13 +0530 Subject: [PATCH 3/7] updated readme --- cart-service/README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cart-service/README.md b/cart-service/README.md index b786e310..f6f294c9 100644 --- a/cart-service/README.md +++ b/cart-service/README.md @@ -29,15 +29,3 @@ The CartEventHandler is responsible for managing cart-related events. #### Data Storage The Cart Service ensures that cart information is efficiently stored for each customer. The CartRepository is responsible for handling data interactions related to the shopping cart. -### Key Components - -#### CartAggregate -Manages the entire cart lifecycle, processing cart commands, and emitting events to reflect changes in the cart state. It serves as the authoritative source for cart-related operations. - -#### CartEventHandler -Handles cart-related events, updating the state of the cart based on the received events. It collaborates with the CartRepository to ensure data consistency. - -#### CartRepository -Manages the persistence of cart-related data, handling interactions with the underlying storage system to retrieve and store cart information. - - From a12ff191ad9d4efd1ca376b47bf9800b425a8308 Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 17:35:11 +0530 Subject: [PATCH 4/7] updated the readme --- cart-service/README.md | 73 ++++++++++++++++++++++++------------- inventory-service/README.md | 57 ++++++++++------------------- 2 files changed, 68 insertions(+), 62 deletions(-) diff --git a/cart-service/README.md b/cart-service/README.md index f6f294c9..c91222c9 100644 --- a/cart-service/README.md +++ b/cart-service/README.md @@ -4,28 +4,51 @@ 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. -### Workflow - -#### Cart Interaction -The core functionality revolves around customer interaction with the shopping cart. Users can add items, remove them, and view the contents of their cart. This process is managed through various commands and events. - -#### Cart Commands - -- AddToCartCommand: Initiates the addition of an item to the shopping cart. -- RemoveFromCartCommand: Triggers the removal of an item from the cart. - -#### Cart Events - -- ItemAddedToCartEvent: Raised when an item is successfully added to the cart. -- ItemRemovedFromCartEvent: Signaled upon the successful removal of an item from the cart. - -#### Event Handling - -The CartEventHandler is responsible for managing cart-related events. - -- ItemAddedToCartEventHandler: Listens for the ItemAddedToCartEvent, updates the cart status, and may perform additional actions based on business logic. -- ItemRemovedFromCartEventHandler: Listens for the ItemRemovedFromCartEvent, adjusts the cart accordingly, and performs necessary updates. - -#### Data Storage -The Cart Service ensures that cart information is efficiently stored for each customer. The CartRepository is responsible for handling data interactions related to the shopping cart. - +### Prerequisites +We must set up Axon Server to handle command and query operations, and configure MySQL as the persistent store destination. + +![cart-service-config.png](..%2F..%2F..%2FPictures%2FScreenshots%2Fcart-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:9090/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:9090/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:9090/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. \ No newline at end of file diff --git a/inventory-service/README.md b/inventory-service/README.md index d64ee86e..457154f8 100644 --- a/inventory-service/README.md +++ b/inventory-service/README.md @@ -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](..%2F..%2F..%2FPictures%2FScreenshots%2FScreenshot%20from%202024-01-24%2017-01-29.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:9090/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. From 199e81def91579f7cc6a320aa9a64f4804a0cd1e Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 17:41:14 +0530 Subject: [PATCH 5/7] updated image in readme. --- cart-service/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cart-service/README.md b/cart-service/README.md index c91222c9..7c37aa28 100644 --- a/cart-service/README.md +++ b/cart-service/README.md @@ -7,7 +7,7 @@ The Cart Service is a meticulously designed component that facilitates customers ### Prerequisites We must set up Axon Server to handle command and query operations, and configure MySQL as the persistent store destination. -![cart-service-config.png](..%2F..%2F..%2FPictures%2FScreenshots%2Fcart-service-config.png) +![cart-service-config.png](https://i.postimg.cc/1z7yX0RY/cart-service-config.png) ### Local setup - Setup axon-server and MySQL docker images From ea0f9f26c89d21a498b765ae305a4f240078e957 Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 17:43:34 +0530 Subject: [PATCH 6/7] updated readme. --- cart-service/README.md | 6 +++--- inventory-service/README.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cart-service/README.md b/cart-service/README.md index 7c37aa28..1520de0c 100644 --- a/cart-service/README.md +++ b/cart-service/README.md @@ -21,7 +21,7 @@ cart-service > mvn clean springboot:run - Endpoint for resting - Generate a request for add to cart. ```arm -curl --location 'http://localhost:9090/cart/add' \ +curl --location 'http://localhost:9094/cart/add' \ --header 'Content-Type: application/json' \ --data '{ "productId": "199", @@ -31,7 +31,7 @@ curl --location 'http://localhost:9090/cart/add' \ ``` - Generate a request for remove to cart. ```arm -curl --location 'http://localhost:9090/cart/remove' \ +curl --location 'http://localhost:9094/cart/remove' \ --header 'Content-Type: application/json' \ --data '{ "productId": "205", @@ -41,7 +41,7 @@ curl --location 'http://localhost:9090/cart/remove' \ ``` - Generate a request to get cart contents. ``` -curl --location 'http://localhost:9090/cart/get' \ +curl --location 'http://localhost:9094/cart/get' \ --header 'Content-Type: application/json' \ --data '{ "userId": "1652" diff --git a/inventory-service/README.md b/inventory-service/README.md index 457154f8..991ddd19 100644 --- a/inventory-service/README.md +++ b/inventory-service/README.md @@ -7,7 +7,7 @@ This application is conscientiously crafted to oversee the management of availab ## Prerequisites We must set up Axon Server to handle command and query operations, and configure MySQL as the persistent store destination. -![Screenshot from 2024-01-24 17-01-29.png](..%2F..%2F..%2FPictures%2FScreenshots%2FScreenshot%20from%202024-01-24%2017-01-29.png) +![Screenshot from 2024-01-24 17-01-29.png](https://i.postimg.cc/W1M89wfF/inventory-service-config.png) ## Local setup @@ -22,7 +22,7 @@ inventory-service > mvn clean springboot:run - Endpoint for resting - Get product. ``` -curl --location 'http://localhost:9090/products/product/199' +curl --location 'http://localhost:9091/products/product/199' ``` ## Contributing From a62b37f7be61441aa4ac48b9aa7148982367787a Mon Sep 17 00:00:00 2001 From: shivamm31 Date: Wed, 24 Jan 2024 18:29:57 +0530 Subject: [PATCH 7/7] updated the changes --- cart-service/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cart-service/README.md b/cart-service/README.md index 1520de0c..e8754a96 100644 --- a/cart-service/README.md +++ b/cart-service/README.md @@ -5,7 +5,7 @@ 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 set up Axon Server to handle command and query operations, and configure MySQL as the persistent store destination. +We must configure MySQL as the persistent store destination. ![cart-service-config.png](https://i.postimg.cc/1z7yX0RY/cart-service-config.png)