Skip to content

Repository files navigation

Insurance Management System

A domain-driven microservice platform for insurance estimation and policy management, built with Spring Boot and Next.js.


Architecture

Eight microservices plus service discovery, each owning its domain data and collaborating via asynchronous events:

ServiceResponsibilityDatabaseStatus
API GatewayRouting, auth validation, rate limitingStub
Auth ServiceUser management, JWT issuance / validationauth_dbStub
Customer ServiceCustomer CRUD, SAGA validationcustomer_dbActive
Vehicle ServiceVehicle info, brand/model/engine reference datavehicle_dbActive
RealEstate ServiceReal estate info, construction/luxury/usage referencerealestate_dbActive
Insurance ServiceInsurance products, types, companiesinsurance_dbActive
Estimation ServiceInsurance estimation, SAGA coordination, timeoutestimation_dbActive
Reference Data ServiceCities, professions, lookup tablesreference_data_dbActive

Service Discovery: Eureka Server on port 8761.

Communication

  • External: All requests route through the API Gateway (Spring Cloud Gateway). No direct service exposure.
  • Inter-service: Kafka for all inter-service communication (SAGA events, domain events).
  • Pattern: Choreography-based SAGA — no central orchestrator. Services react to events and publish outcomes.
  • Idempotency: All consumers deduplicate by sagaId + event type via atomic INSERT with UNIQUE constraint.

Estimation SAGA Flow

EstimationRequested → CustomerValidated + VehicleValidated + RealEstateValidated
→ PremiumCalculated → WAITING_APPROVAL
→ (accept-offer) → PAYMENT_WAITING
→ (process-payment) → ACTIVE

Status lifecycle: STARTEDWAITING_APPROVALPAYMENT_WAITINGACTIVE — with FAILED and timeout (5 min) compensation paths.

Infrastructure

ComponentTechnologyPort
Databases (8)PostgreSQL 165432–5439
Message BrokerKafka (KRaft mode)9092
Distributed TracingZipkin9411
Rate LimitingRedis 7 Alpine6379
Service DiscoveryEureka8761

Frontend

Next.js 16 (App Router, SSR) with React 19, TypeScript, Tailwind CSS 4, and shadcn/ui (Base UI React, style: "base-nova").

Server Components by default with explicit "use client" boundaries. Client state via Zustand, server state via TanStack React Query, forms via React Hook Form + Zod, tables via TanStack React Table.

Pages

  • Dashboard — overview with stats cards
  • Customers — list, create, edit, detail view
  • Vehicles — list, create, edit (brand/model cascading)
  • Real Estate — list, create, edit
  • Insurances — products, types, companies
  • Offers (Estimations) — list with status filters, create, detail with status-driven action button, payment page

Prerequisites

  • Java 25
  • Docker Compose
  • Node.js 20+
  • Gradle (included via wrapper — gradlew.bat)

Getting Started

One-Command Startup

start-all.cmd

Builds all JARs via ./gradlew.bat bootJar -x test, then starts infrastructure + all 8 services as Docker containers. Use -skip-build to skip the Gradle build step.

start-all.cmd -skip-build

Stop everything:

stop-all.cmd

Step-by-Step Startup

# 1. Start infrastructure (PostgreSQL × 8, Kafka, Redis, Zipkin, Eureka)cd infra/docker
docker compose -f docker-compose.yml -f docker-compose.override.yml up -d
# 2. Build all service JARscd ../..
./gradlew.bat bootJar -x test# 3. Start all microservicescd infra/docker
docker compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.services.yml up -d --build
# 4. Start frontendcd ../../frontend
npm install
npm run dev

Browse tohttp://localhost:3000.


Service Ports

ServicePort
API Gateway8080
Customer Service8081
Vehicle Service8082
RealEstate Service8083
Insurance Service8084
Estimation Service8085
Reference Data Service8086
Auth Service8087
Next.js Frontend3000
Eureka Dashboard8761

Build & Test

# Build a specific microservice
./gradlew.bat :services:<service-name>:build
# Run tests for a specific microservice
./gradlew.bat :services:<service-name>:test
# Build all JARs (skip tests)
./gradlew.bat bootJar -x test# Frontendcd frontend
npm run build
npm run lint
npm run dev

Project Layout

├── common/ # Shared libraries
│ ├── common-message/ # Kafka event POJOs, EventType constants
│ ├── common-web/ # Shared web config (security, filters)
│ └── common-test/ # Shared test utilities
├── services/ # Microservices (Gradle submodules)
│ ├── api-gateway/
│ ├── auth-service/
│ ├── customer-service/
│ ├── vehicle-service/
│ ├── realestate-service/
│ ├── insurance-service/
│ ├── estimation-service/
│ ├── reference-data-service/
│ └── eureka-server/
├── frontend/ # Next.js 16 SSR application
│ └── src/
│ ├── app/ # App Router (pages, layouts, API routes)
│ ├── components/ # shadcn/ui + feature components
│ ├── hooks/ # Custom React hooks
│ └── lib/ # API client, Zustand stores, utilities
├── infra/
│ ├── docker/ # Docker Compose files, Dockerfiles
│ ├── kafka/ # Kafka topic initialization script
│ ├── k8s/ # Kubernetes manifests (planned)
│ └── sql/ # Database init scripts (per service)
└── docs/
├── outlines/ # Architecture blueprint (12 files)
├── stories/ # User stories (7 files)
├── plans/ # Execution checklists (active + archived)
└── tasks/ # Task templates

Documentation

The docs/ directory implements a structured engineering framework:

DirectoryPurpose
outlines/Permanent architectural decisions and conventions — treated as immutable law
stories/User-facing feature requirements with acceptance criteria
plans/Step-by-step execution checklists — the active source of truth for development
tasks/Directed instruction templates linking outlines and stories

Key outlines:


Features (TBA)

FeatureStatusNotes
Auth ServicePlannedUser registration, login, JWT issuance/validation, BCrypt, account lockout
API GatewayPlannedRoute-level rate limiting via Redis, JWT auth filter chain, response wrapper
Kubernetes DeploymentPlannedinfra/k8s/ directory created; manifests and Helm charts pending
CI/CD PipelinesPlannedNo GitHub Actions workflows configured yet
Test Coverage (JaCoCo)Planned80% coverage target for insurance-service and estimation-service
Frontend Auth IntegrationPlannedLogin/register pages exist; JWT cookie integration with gateway pending
OpenAPI / Swagger UIPlannedSpringdoc integration for API documentation

Environment Variables

All configurable variables are documented in .env.template (single source of truth). Copy it to configure your deployment:

cp .env.template .env

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages