A distributed patient management platform built with Java 21, Spring Boot, Docker, and AWS CDK.
The project demonstrates secure API gateway routing, service-to-service communication via gRPC, and event-driven processing with Kafka.
Spring Boot Java 21 Spring Cloud Gateway PostgreSQL Kafka gRPC Docker AWS CDK
This repository contains a microservice system focused on patient domain workflows:
- API Gateway as the single entry point
- Auth Service for login + JWT validation
- Patient Service for patient CRUD
- Billing Service for gRPC-based account creation
- Analytics Service for Kafka event consumption
- Integration Tests for gateway/auth/patient flows
- Infrastructure module with AWS CDK (VPC, ECS/Fargate, RDS, MSK, ALB blueprint)
The architecture combines:
- Synchronous communication (REST + gRPC)
- Asynchronous communication (Kafka + Protobuf)
- Containerized runtime (Docker Compose)
Client
|
v
API Gateway (:4004)
|------------------------------> Auth Service (:4005) [login/validate]
|
+------------------------------> Patient Service (:4000) [CRUD]
|
+--> Billing Service (:9001 gRPC)
|
+--> Kafka Topic: "patient"
|
v
Analytics Service (:4002)
- Centralized entrypoint: Gateway handles routing and token checks for protected routes.
- Service boundaries: Auth, Patient, Billing, and Analytics stay decoupled by domain.
- Communication fit-for-purpose:
- REST for external API calls
- gRPC for efficient internal sync calls
- Kafka for async event fan-out
- Scalable foundation: Each service can be deployed and scaled independently.
- Built with Spring Cloud Gateway (WebFlux).
- Routes:
/auth/**-> Auth Service/api/patients/**-> Patient Service
- Includes custom
JwtValidationGatewayFilterFactory:- checks
Authorization: Bearer <token> - calls Auth Service
/validate - blocks unauthorized requests with
401
- checks
- Handles login and token validation.
- Uses Spring Security, JPA, PostgreSQL, JWT (jjwt).
- Endpoints:
POST /login-> issues JWT on valid credentialsGET /validate-> validates JWT integrity/expiration
- Seeds demo user via
data.sql.
- Main domain service for patient records.
- Tech: Spring Web, Spring Data JPA, Validation, PostgreSQL/H2.
- Endpoints:
GET /patientsPOST /patientsPUT /patients/{id}DELETE /patients/{id}
- Business behavior on patient creation:
- Persist patient
- Trigger billing account creation via gRPC
- Publish
PATIENT_CREATEDevent to Kafka topicpatient
- gRPC server providing
CreateBillingAccount. - Receives
BillingRequestwith patient data and returnsBillingResponse. - Contract defined with Protocol Buffers.
- Kafka consumer (
@KafkaListener) for topicpatient. - Deserializes protobuf payload (
PatientEvent) and processes/logs events. - Designed as extension point for reporting, BI, monitoring pipelines.
- Uses RestAssured + JUnit 5.
- Verifies:
- successful and failing auth login flow
- protected patient endpoint access via bearer token through gateway
- Tests run against a live stack on
http://localhost:4004.
- Java-based AWS CDK stack definition.
- Provisions blueprint resources like:
- VPC
- ECS/Fargate services
- RDS databases
- MSK cluster
- Application Load Balanced gateway service
- Synth output available under
infrastructure/cdk.out.
message PatientEvent {
string patientId = 1;
string name = 2;
string email = 3;
string event_type = 4;
}service BillingService {
rpc CreateBillingAccount (BillingRequest) returns (BillingResponse);
}- Authentication is token-based (JWT).
- Gateway protects patient routes using a custom filter.
- Auth Service provides token issuance + validation endpoints.
- Services are configured for container network communication in Docker Compose.
- Java 21
- Spring Boot 3.5.9
- Spring Cloud Gateway
- Spring Data JPA / Hibernate
- Spring Security
- gRPC + Protocol Buffers
- Apache Kafka
- PostgreSQL 17
- Maven
- Docker / Docker Compose
- AWS CDK (Java)
- JUnit 5
- RestAssured
- Docker + Docker Compose
- Java 21 (for local service runs/tests)
- Maven (or
./mvnwper module)
docker compose up --build4004API Gateway4005Auth Service4000Patient Service (internal in compose, reachable through gateway)4001Billing HTTP9001Billing gRPC4002Analytics Service5001Patient PostgreSQL5002Auth PostgreSQL9092/9094Kafka8080Kafka UI
# Login
curl -s -X POST http://localhost:4004/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"testuser@test.com","password":"password123"}'# Example protected request
curl -X GET http://localhost:4004/api/patients \
-H "Authorization: Bearer <JWT_TOKEN>"Gateway provides doc routes:
GET /api-docs/auth-> proxied OpenAPI spec from Auth ServiceGET /api-docs/patients-> proxied OpenAPI spec from Patient Service
Core gateway endpoints:
POST /auth/loginGET /auth/validateGET /api/patientsPOST /api/patientsPUT /api/patients/{id}DELETE /api/patients/{id}
Start services first (docker compose up), then:
cd integration-tests
mvn testEach service contains its own Maven test setup, e.g.:
cd patient-service
./mvnw test- Microservice architecture with clear service boundaries
- Secure API gateway pattern with centralized auth checks
- Mixed communication patterns (REST + gRPC + Kafka)
- Contract-first messaging with Protocol Buffers
- Container-first local environment with Docker Compose
- Infrastructure as Code fundamentals with AWS CDK
- Separation of concerns across controller/service/repository layers
- Input validation and global exception handling
- Integration testing of real HTTP flows
- Reproducible local setup with seeded data
- Expand automated test coverage (service logic + gateway filter edge cases)
- Add centralized observability (OpenTelemetry + tracing + metrics dashboards)
- Add role-based authorization rules beyond token validity checks
- Implement retry/dead-letter handling for Kafka consumer failures
- Introduce CI pipeline (build, test, container scan, deployment checks)
This is a portfolio project and actively evolving.
Feedback, ideas, and architectural discussions are welcome.