https://github.com/rbkgh/eventdrivenstockprocessor
Event Driven Stock Processor
https://github.com/rbkgh/eventdrivenstockprocessor
Last synced: 11 months ago
JSON representation
Event Driven Stock Processor
- Host: GitHub
- URL: https://github.com/rbkgh/eventdrivenstockprocessor
- Owner: RbkGh
- License: mit
- Created: 2024-06-20T06:01:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-26T13:35:48.000Z (about 2 years ago)
- Last Synced: 2024-11-15T06:17:30.456Z (over 1 year ago)
- Language: Java
- Size: 1.58 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# Stock Processor Service
[](https://opensource.org/licenses/MIT)
## Requirements
```textmate
1. Java 17+
"java --version" on the command line must return a version 17 java like:
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment Homebrew (build 17.0.9+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)
```
## Overview
```textmate
There are two main modules
i. product-service
- when a product is created, the server responds with 201 and adds the location of the resource in the "Location" header of the response
- if product exists, it returns conflicted httpstatus
ii. event-update-listener
- product-service starts a web service with exposed api's for product manipulation,saves to postgres.
- product-service also serves as the kafka producer that publishes any change in product to a kafka topic
- when an http request comes to create a product, immediately the product is successfully created,
a product payload is published to "product.created" topic, when an update http request comes in, a payload is published to "product.updated" topic,
when a delete http request comes in, product deleted is published to "product.deleted"
- event-update-listener is a subscriber to the topics that are published by product service and it also stores the information in mongodb.
```
## Run all services:
1.
> rename ".example.env" file to ".env" [this loads the values into docker]
2.
```shell
docker-compose build
````
3.
```shell
docker-compose up
````
>>> this above starts kafka and zookeper, starts two services(product-service and event-update-listener) and starts two databases, mongo_db and postgres_db

> [[/product-service-http-requests.postman_collection.json]](./product-service-http-requests.postman_collection.json) contains all CRUD http requests to use in PostMan

> Swagger URL : [](http://localhost:8080/swagger-ui/index.html)
> Kafka-UI to view kafka updates as changes happen in real-time http://localhost:8090/
> CI/CD : Jenkinsfile is placed in product-service to deploy to heroku
## Run Tests- Navigate into /product-service and run:
```shell
./mvnw clean
```
```shell
./mvnw test
```
>>> this runs integration and unit tests with 100% class coverage using testcontainer for integration and mocks for unit service tests
