Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Quote REST System

A Java/Spring Boot distributed systems project demonstrating REST-based communication between multiple quotation services, a broker service, and a standalone Java client.

The system models a simple insurance quote workflow. A client submits customer information to a broker service. The broker forwards the request to multiple quotation provider services, collects their responses, and returns an application containing the generated quotations.

Architecture

The project is structured as a Maven multi-module application:

  • core — shared domain classes used by all modules
  • alphaquote — quotation provider REST service
  • betaquote — quotation provider REST service
  • gammaquote — quotation provider REST service
  • broker — REST service that aggregates quotations from all providers
  • client — standalone Java client that submits applications to the broker

Technologies

  • Java 17
  • Maven
  • Spring Boot
  • REST APIs
  • Jackson JSON serialisation
  • Docker
  • Docker Compose

REST Endpoints

Quotation Services

Each quotation service exposes:

POST /quotations
GET /quotations
GET /quotations/{id}

Default ports:

alphaquote  → http://localhost:8080
betaquote   → http://localhost:8081
gammaquote  → http://localhost:8082

Broker Service

The broker exposes:

POST /applications
GET /applications
GET /applications/{id}

Default broker URL:

http://localhost:8083

Example Request

Example request body for creating an application:

{
  "name": "Jane Doe",
  "gender": "F",
  "age": 41,
  "height": 1.61,
  "weight": 57,
  "smoker": false,
  "medicalIssues": false
}

Send this to:

POST http://localhost:8083/applications

The broker returns a created application containing the client information and quotations from the quotation services.

Running locally with Maven

First build the full project:

mvn clean package

Start each Spring Boot service in a separate terminal from the project root:

mvn spring-boot:run -pl alphaquote
mvn spring-boot:run -pl betaquote
mvn spring-boot:run -pl gammaquote
mvn spring-boot:run -pl broker

Once all four services are running, run the standalone Java client from another terminal:

mvn compile exec:java -pl client

The client creates a ClientInfo object, serialises it to JSON, sends it to the broker using POST /applications, and prints the response.

Running with Docker Compose

Build the project first so that each service has a packaged JAR file:

mvn clean package

Then start the containerised services:

docker compose up --build

This starts the following containers:

alphaquote  → port 8080
betaquote   → port 8081
gammaquote  → port 8082
broker      → port 8083

The broker can then be tested at:

http://localhost:8083/applications

You can test the Dockerised broker using Postman or by running the standalone client from your host machine:

mvn compile exec:java -pl client

The client is not containerised. It runs locally and communicates with the broker through the exposed port 8083.

Notes

When running the services with Docker Compose, the broker contacts the quotation services using their Docker Compose service names, such as:

http://alphaquote:8080/quotations
http://betaquote:8081/quotations
http://gammaquote:8082/quotations

This is different from local Maven execution, where services are usually contacted through localhost.

One small warning: if your broker currently uses Docker service names like `http://alphaquote:8080/quotations`, then running all services directly with Maven may fail unless you switch those URLs back to `localhost` or make them configurable.

Possible Improvements

If this were developed further, useful improvements would include:

  • Moving service URLs fully into external configuration
  • Adding persistent storage instead of in-memory maps
  • Adding validation for incoming client data
  • Improving error handling when quotation services are unavailable
  • Adding automated tests for controllers and service interactions
  • Adding structured logging
  • Replacing hardcoded service URLs with service discovery or a registration endpoint

About

Java Spring Boot REST API demonstrating communication between multiple quotation services using Docker Compose

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages