MediSync
Patient-management back end as Spring Boot microservices with gRPC and Kafka
An API gateway checks JWTs and routes to the auth and patient services. Creating a patient opens a billing account over gRPC and publishes a Protobuf event to Kafka for analytics. Each service owns its PostgreSQL database, and the AWS infrastructure is written in CDK and deployed to LocalStack.
- 5 services
- gRPC + Kafka
- Database per service
- ECS · RDS · MSK in CDK
§1
The problem
Patient records, authentication and billing change at different speeds and carry different risks. In one application, a billing change can take down the patient API, and every module reads and writes the same database.
§2
My role
Built the five services, the gateway's JWT filter, the Protobuf contracts, the CDK stack and the integration tests.
§3
Architecture
§4
Key decisions
D/01
Authenticate once, at the edge
A Spring Cloud Gateway filter rejects requests without a Bearer token and calls auth-service /validate before forwarding patient routes. Login and register stay public.
D/02
Sync when you need the answer
Opening a billing account is a blocking gRPC call because the patient flow needs the result. The patient-created event goes to Kafka because nobody waits on it.
D/03
Protobuf on both channels
The same .proto schemas type the gRPC calls and the Kafka payloads (sent as bytes), so producer and consumer share one contract.
D/04
Database per service
Auth and patient each have their own PostgreSQL instance. Nothing joins across them; tests run on H2.
D/05
Infrastructure as code
A Java CDK stack defines the VPC, two RDS PostgreSQL databases, an MSK cluster, ECS Fargate services and an ALB in front of the gateway, deployed to LocalStack so it runs without an AWS bill.
§5
Challenges
- Create and update need different rules: registeredDate is required on create only, handled with a Bean Validation group instead of two DTOs.
- Updating a patient with the same email used to fail the uniqueness check; the query now excludes the patient's own row (existsByEmailAndIdNot).
- End-to-end tests with REST Assured log in through the gateway and call the patient API with the returned token.
- Next step: billing returns a placeholder account today. Persisting accounts and adding gRPC deadlines and retries comes next.
§6
Stack
- Java 21
- Spring Boot
- Spring Cloud Gateway
- gRPC
- Protobuf
- Kafka
- PostgreSQL
- AWS CDK
- LocalStack
- Docker
Next case study
Repo Pilot
Payment-event ingestion and reconciliation that survives duplicates