Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sivaprasadreddy/spring-modular-monolith
An application following Spring Modulith
https://github.com/sivaprasadreddy/spring-modular-monolith
java spring-boot spring-modulith
Last synced: 7 days ago
JSON representation
An application following Spring Modulith
- Host: GitHub
- URL: https://github.com/sivaprasadreddy/spring-modular-monolith
- Owner: sivaprasadreddy
- License: apache-2.0
- Created: 2024-08-26T02:27:43.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-18T16:22:15.000Z (8 days ago)
- Last Synced: 2024-12-18T17:29:11.602Z (7 days ago)
- Topics: java, spring-boot, spring-modulith
- Language: Java
- Homepage:
- Size: 482 KB
- Stars: 49
- Watchers: 2
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-modular-monolith
An e-commerce application following Modular Monolith architecture using [Spring Modulith](https://spring.io/projects/spring-modulith).
The goal of this application is to demonstrate various features of Spring Modulith with a practical application.![bookstore-modulith.png](bookstore-modulith.png)
This application follows modular monolith architecture with the following modules:
* **Common:** This module contains the code that is shared by all modules.
* **Catalog:** This module manages the catalog of products and store data in `catalog` schema.
* **Orders:** This module implements the order management and store the data in `orders` schema.
* **Inventory:** This module implements the inventory management and store the data in `inventory` schema.
* **Notifications:** This module handles the events published by other modules and sends notifications to the interested parties.**Goals:**
* Implement each module as independently as possible.
* Prefer event-driven communication instead of direct module dependency wherever applicable.
* Store data managed by each module in an isolated manner by using different schema or database.
* Each module should be testable by loading only module-specific components.**Module communication:**
* **Common** module is an OPEN module that can be used by other modules.
* **Orders** module invokes the **Catalog** module public API to validate the order details
* When an Order is successfully created, **Orders** module publishes **"OrderCreatedEvent"**
* The **"OrderCreatedEvent"** will also be published to external broker like RabbitMQ. Other applications may consume and process those events.
* **Inventory** module consumes "OrderCreatedEvent" and updates the stock level for the products.
* **Notifications** module consumes "OrderCreatedEvent" and sends an order confirmation email to the customer.## Prerequisites
* JDK 21
* Docker and Docker Compose
* Your favourite IDE (Recommended: [IntelliJ IDEA](https://www.jetbrains.com/idea/))Install JDK, Maven, Gradle using [SDKMAN](https://sdkman.io/)
```shell
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
$ sdk install java 21.0.1-tem
$ sdk install gradle
$ sdk install maven
```Task is a task runner that we can use to run any arbitrary commands in easier way.
```shell
$ brew install go-task
(or)
$ go install github.com/go-task/task/v3/cmd/task@latest
```Verify the prerequisites
```shell
$ java -version
$ docker info
$ docker compose version
$ task --version
```## Using `task` to perform various tasks:
The default `Taskfile.yml` is configured to use Maven.
Another `Taskfile.gradle.yml` is also created with Gradle configuration.If you want to use Gradle instead of Maven, then add `-t Taskfile.gradle.yml` for the `task` commands.
For example:
```shell
$ task test` // uses Maven
$ task -t Taskfile.gradle.yml test` //uses Gradle
``````shell
# Run tests
$ task test# Automatically format code using spotless-maven-plugin
$ task format# Build docker image
$ task build_image# Run OpenRewrite Recipes
$ task open_rewrite# Run application in docker container
$ task start
$ task stop
$ task restart
```* Application URL: http://localhost:8080
* Actuator URL: http://localhost:8080/actuator
* Actuator URL for modulith: http://localhost:8080/actuator/modulith
* RabbitMQ Admin URL: http://localhost:15672 (Credentials: guest/guest)
* Zipkin URL: http://localhost:9411## Deploying on k8s cluster
* [Install kubectl](https://kubernetes.io/docs/tasks/tools/)
* [Install kind](https://kind.sigs.k8s.io/docs/user/quick-start/)```shell
$ brew install kubectl
$ brew install kind
```Create a KinD cluster and deploy an app.
```shell
# Create KinD cluster
$ task kind_create# deploy app to kind cluster
$ task k8s_deploy# undeploy app
$ task k8s_undeploy# Destroy KinD cluster
$ task kind_destroy
```* Application URL: http://localhost:30090
* RabbitMQ Admin URL: http://localhost:30091 (Credentials: guest/guest)
* Zipkin URL: http://localhost:30092