This project is structured as a modulith architecture with one main module and four submodules. Each submodule encapsulates a specific domain of functionality and can be run independently. Docker is used for containerization, with each module having its own Dockerfile and the main module having a docker-compose.yml
for orchestration.
This project consists of the following modules:
- Modulith Module: Orchestrates the application using Docker Compose.
- Database Module: Manages database interactions using H2.
- Summary Module: Aggregates and summarizes data from the Star Wars and Harry Potter API modules.
- StarWars API Module: Interacts with the Star Wars API.
- HarryPotter API Module: Interacts with the Harry Potter API.
The main module is responsible for orchestrating the application using Docker Compose. It does not contain a Spring Boot application itself but manages the deployment of other modules.
The database module manages all database interactions using an H2 database. It defines the entities and repositories used across the application.
The summary module aggregates and summarizes data from the Star Wars and Harry Potter API modules, providing a consolidated view of the information. It connects to the StarWars and HarryPotter APIs to fetch the data.
The StarWars API module handles all interactions with the Star Wars API. It fetches data related to Star Wars characters and movies and connects to the database to store this data.
The HarryPotter API module handles all interactions with the Harry Potter API. It fetches data related to Harry Potter characters and events and connects to the database to store this data.
- Java 21
- Maven
- Docker
- Docker Compose
You can run each module independently or use Docker Compose to orchestrate them.
-
Clone the repository:
git clone https://github.com/svbuh/lal-2-architecture-modulith.git cd modulith-architecture
-
Build the modules
mvn clean package
-
Build the Docker images:
docker-compose build
-
Run the application:
docker-compose up
Each module can be run independently. Navigate to the module directory and use Maven to run the Spring Boot application:
cd harrypotter-api
mvn spring-boot:run
Repeat the above steps for the starwars-api
and summary-module
directories.
You can also run the applications with the run configurations in your preferred IDE.
Each module contains a Dockerfile. The docker-compose.yml
file in the main module is used to orchestrate the deployment of all modules.
To run the tests, use the following command:
mvn test