How rapter1990/insurance-campaign-microservices works
Purpose and Runtime Topology
This Maven multi-module system is an insurance campaign-management platform built on Java 25 and Spring Boot 4. It exposes REST APIs for identity, campaign lifecycle, dashboards, and logs; uses independent service data stores; and runs either fully containerized or with infrastructure-only local Compose.
• Root orchestration: pom.xml, docker-compose.yml, docker-compose-local.yml
• Service entry points: api-gateway/src/main/java/com/casestudy/insurancecampaign/gateway/ApiGatewayApplication.java, campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/CampaignServiceApplication.java
Platform Control Plane and Edge
Discovery Server provides Eureka registration; Config Server centrally serves Spring configuration. API Gateway is the primary client entry point: routes requests to services, validates JWTs, applies Redis-backed rate limits, and aggregates/falls back OpenAPI documents.
• discovery-server/src/main/java/com/casestudy/insurancecampaign/discovery/DiscoveryServerApplication.java
• config-server/src/main/java/com/casestudy/insurancecampaign/config/ConfigServerApplication.java
• api-gateway/src/main/java/com/casestudy/insurancecampaign/gateway/filter/GatewayJwtAuthenticationFilter.java
• api-gateway/src/main/java/com/casestudy/insurancecampaign/gateway/config/GatewayRateLimiterConfiguration.java
Identity and Authorization Boundary
Auth Service owns users, roles, refresh tokens, password-reset tokens, and RSA access-token signing. It persists identity state in its PostgreSQL database through JPA/Liquibase. Other services and the gateway validate signatures with the shared public-key security module; campaign authorization is additionally enforced within Campaign Service, not trusted solely to the gateway.
• auth-service/src/main/java/com/casestudy/insurancecampaign/auth/controller/AuthController.java
• auth-service/src/main/java/com/casestudy/insurancecampaign/auth/service/AuthService.java
• security/src/main/java/com/casestudy/insurancecampaign/security/ServiceSecurityConfiguration.java
• auth-service/src/main/resources/db/changelog/db.changelog-master.yml
Campaign Lifecycle Core
Campaign Service is the system of record for campaigns and status history. Its service layer validates title/category/content rules, rejects duplicate category-title-description combinations, assigns initial status, enforces valid approval/deactivation transitions, persists state/history, and serves REST plus gRPC. It caches campaign status statistics in Redis and evicts cache entries on changes.
• campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/service/CampaignService.java
• campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/entity/CampaignEntity.java
• campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/entity/CampaignStatusHistoryEntity.java
• campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/grpc/CampaignGrpcEndpoint.java
Dashboard and Interservice Contracts
Dashboard Service is a read-oriented HTTP façade for campaign statistics and campaign history. It does not directly access the campaign database; it calls Campaign Service’s gRPC endpoint using generated protobuf contracts. Auth audit logging instead uses HTTP Exchange from Auth Service to Log Service and is deliberately non-blocking to authentication outcomes through Resilience4j circuit breaker, retry, and bulkhead controls.
• dashboard-service/src/main/java/com/casestudy/insurancecampaign/dashboard/client/CampaignGrpcClient.java
• grpc-contract/src/main/proto/campaign.proto
• auth-service/src/main/java/com/casestudy/insurancecampaign/auth/client/LogServiceHttpClient.java
• auth-service/src/main/java/com/casestudy/insurancecampaign/auth/service/AuthAuditService.java
Eventing and Log Persistence
Campaign changes and slow-request observations are emitted through Kafka; Log Service consumes slow-request events and sends failed processing to a DLQ. Log Service also receives auth audit HTTP calls. Both audit and slow-request records are stored in Elasticsearch, separating searchable operational/business logs from normal application file logs.
• common/src/main/java/com/casestudy/insurancecampaign/common/event/CampaignStatusChangedEvent.java
• common/src/main/java/com/casestudy/insurancecampaign/common/web/SlowRequestLoggingFilter.java
• log-service/src/main/java/com/casestudy/insurancecampaign/log/service/SlowRequestLogConsumer.java
• log-service/src/main/java/com/casestudy/insurancecampaign/log/config/KafkaDlqConfiguration.java
Shared Cross-Cutting and Observability
common standardizes API envelopes, exception mapping, Kafka JSON, virtual-thread setup, HTTP observations, and slow-request publication. Services export actuator metrics to Prometheus and traces through the OpenTelemetry Collector to Tempo; file logs flow via Promtail to Loki. Grafana provisions all three data sources and a campaign dashboard.
• common/src/main/java/com/casestudy/insurancecampaign/common/exception/GlobalExceptionHandler.java
• observability/otel-collector/otel-collector.yml
• observability/prometheus/prometheus.yml
• observability/grafana/dashboards/campaign-logs-traces.json
Main entry points: CampaignService.java Campaign Service · GatewayJwtAuthenticationFilter.java API Gateway · AuthService.java Auth Service · SlowRequestLogConsumer.java Log Service
Components 19
Platform
- Discovery Server · Eureka service registration.
discovery-server/src/main/java/com/casestudy/insurancecampaign/discovery/DiscoveryServerApplication.java - Config Server · Central Spring configuration.
config-server/src/main/java/com/casestudy/insurancecampaign/config/ConfigServerApplication.java - API Gateway · JWT-protected routing and Redis rate limiting.
api-gateway/src/main/java/com/casestudy/insurancecampaign/gateway/filter/GatewayJwtAuthenticationFilter.java - Security Module · Shared public-key JWT validation.
security/src/main/java/com/casestudy/insurancecampaign/security/ServiceSecurityConfiguration.java - Common Module · Shared web, events, Kafka, and observability conventions.
common/src/main/java/com/casestudy/insurancecampaign/common/web/SlowRequestLoggingFilter.java
Business Services
- Auth Service · Identity, roles, tokens, and RSA token signing.
auth-service/src/main/java/com/casestudy/insurancecampaign/auth/service/AuthService.java - Campaign Service · Campaign lifecycle system of record; serves REST and gRPC.
campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/service/CampaignService.java - Dashboard Service · Read-only campaign statistics and history façade.
dashboard-service/src/main/java/com/casestudy/insurancecampaign/dashboard/client/CampaignGrpcClient.java - Log Service · Persists auth-audit and slow-request logs.
log-service/src/main/java/com/casestudy/insurancecampaign/log/service/SlowRequestLogConsumer.java
Data & Eventing
- Auth PostgreSQL
auth-service/src/main/resources/db/changelog/db.changelog-master.yml - Campaign PostgreSQL · Campaign and status-history persistence.
campaign-service/src/main/java/com/casestudy/insurancecampaign/campaign/entity/CampaignEntity.java - Redis
api-gateway/src/main/java/com/casestudy/insurancecampaign/gateway/config/GatewayRateLimiterConfiguration.java - Kafka · Carries campaign-change and slow-request events.
- Kafka DLQ · Failed slow-request processing.
log-service/src/main/java/com/casestudy/insurancecampaign/log/config/KafkaDlqConfiguration.java - Elasticsearch · Searchable audit and operational logs.
Observability
- OpenTelemetry Collector · Forwards service traces to Tempo.
observability/otel-collector/otel-collector.yml - Prometheus · Scrapes actuator metrics.
observability/prometheus/prometheus.yml - Loki · Receives file logs through Promtail.
- Grafana · Campaign logs, metrics, and traces dashboard.
observability/grafana/dashboards/campaign-logs-traces.json
Connections 27
- API Gateway → Auth Service: routes identity API
- API Gateway → Campaign Service: routes campaign API
- API Gateway → Dashboard Service: routes dashboard API
- API Gateway → Redis: rate-limit counters
- Security Module → API Gateway: JWT validation
- Security Module → Campaign Service: JWT validation
- Auth Service → Auth PostgreSQL: users and tokens
- Campaign Service → Campaign PostgreSQL: campaigns and history
- Campaign Service → Redis: status-statistics cache
- Dashboard Service → Campaign Service: gRPC statistics and history · Uses generated protobuf contracts.
- Auth Service → Log Service: non-blocking audit HTTP · Circuit breaker, retry, and bulkhead isolate authentication.
- Campaign Service → Kafka: campaign status changes
- Common Module → Kafka: publishes slow requests
- Kafka → Log Service: slow-request events
- Log Service → Kafka DLQ: failed consumption
- Log Service → Elasticsearch: audit and slow-request records
- Auth Service → Discovery Server: registers
- Campaign Service → Discovery Server: registers
- Dashboard Service → Discovery Server: registers
- API Gateway → Discovery Server: discovers services
- Config Server → Auth Service: serves configuration
- Config Server → Campaign Service: serves configuration
- Config Server → API Gateway: serves configuration
- Campaign Service → OpenTelemetry Collector: exports traces
- OpenTelemetry Collector → Grafana: Tempo traces
- Prometheus → Grafana: metrics
- Loki → Grafana: logs