A backend-focused Java Spring Boot microservices project for patient management, authentication, billing account creation, and analytics event processing. The project demonstrates REST APIs, API Gateway routing, JWT-based security, role-based authorization, gRPC communication, Kafka event streaming, PostgreSQL persistence, OpenAPI documentation, and Dockerized service builds.
The system is split into independent services:
- API Gateway routes external requests and validates protected patient API calls.
- Auth Service manages users, roles, JWT access tokens, refresh tokens, and Google OAuth login.
- Patient Service manages patient records and triggers billing and analytics workflows.
- Billing Service exposes a gRPC API for billing account creation.
- Analytics Service consumes patient events from Kafka.
| Service | Port | Responsibility |
|---|---|---|
| API Gateway | 4004 |
Routes /auth/** and /api/**, applies JWT validation, exposes aggregated Swagger docs |
| Auth Service | 4005 |
Registration, login, refresh tokens, logout, user management, roles, OAuth2 login |
| Patient Service | 4000 |
Patient CRUD APIs, validation, PostgreSQL persistence, gRPC billing call, Kafka event publishing |
| Billing Service | 4001 |
HTTP service plus gRPC server on 9001 for billing account creation |
| Analytics Service | - | Kafka consumer for patient events |
- Microservice-based backend architecture.
- Centralized routing with Spring Cloud Gateway.
- Stateless authentication using JWT access tokens.
- Refresh token rotation and revocation backed by database storage.
- Role-based authorization with
ROLE_GUESTandROLE_ADMIN. - Google OAuth2 login support.
- Patient CRUD APIs with request validation and exception handling.
- Service-to-service communication using gRPC and Protocol Buffers.
- Event-driven processing using Kafka.
- Separate persistence ownership for Auth and Patient services.
- Swagger/OpenAPI documentation for API discovery.
- Dockerfile for each service.
- Client sends requests through the API Gateway.
- Authentication requests are forwarded to the Auth Service.
- Protected patient requests require a Bearer token.
- Gateway validates tokens with the Auth Service before forwarding requests.
- Patient Service persists patient data in PostgreSQL.
- On patient creation, Patient Service calls Billing Service over gRPC.
- Patient Service publishes a
PATIENT_CREATEDevent to Kafka. - Analytics Service consumes the event asynchronously.
POST /v1/registerPOST /v1/loginPOST /v1/refreshPOST /v1/logoutGET /users/validateGET /users/validate-admin- User management APIs under
/users
Gateway path: /api/patients
GET /patientsPOST /patientsGET /patients/{id}PUT /patients/{id}DELETE /patients/{id}
gRPC:
CreateBillingAccount(BillingRequest) returns (BillingResponse)
Kafka:
- Topic:
patient - Event payload: Protocol Buffer
PatientEvent
- Java 21
- Spring Boot
- Spring Cloud Gateway
- Spring Security
- Spring Data JPA / Hibernate
- PostgreSQL
- JWT (
jjwt) - OAuth2 Client
- gRPC
- Protocol Buffers
- Apache Kafka
- Maven
- Docker
- OpenAPI / Swagger
- Jakarta Bean Validation
- Lombok
- ModelMapper
.
|-- api-gateway
|-- auth-service
|-- patient-service
|-- billing-service
|-- analytics-service
`-- prompt-to-generate.md
- Java 21
- Maven or included Maven wrappers
- PostgreSQL
- Kafka
- Docker, optional
There is currently no root docker-compose.yml. Each service includes its own Dockerfile, while infrastructure and networking must be configured separately.
Run any service from its directory:
./mvnw spring-boot:runBuild any service:
./mvnw clean packageBuild a Docker image:
docker build -t patient-management/<service-name> .AUTH_SERVICE_URL
SPRING_DATASOURCE_URLSPRING_DATASOURCE_USERNAMESPRING_DATASOURCE_PASSWORDSPRING_JPA_HIBERNATE_DDL_AUTOSPRING_JPA_SHOW_SQLSPRING_JPA_PROPERTIES_HIBERNATE_DIALECTSPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQLSPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_IDSPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_GOOGLE_CLIENT_SECRETSECURITY_JWT_SECRETSECURITY_JWT_ISSUERSECURITY_JWT_ACCESS_TTL_SECONDSSECURITY_JWT_REFRESH_TTL_SECONDSSECURITY_JWT_REFRESH_TOKEN_COOKIE_NAMESECURITY_JWT_COOKIE_DOMAINSECURITY_JWT_COOKIE_HTTP_ONLYSECURITY_JWT_COOKIE_SECURESECURITY_JWT_COOKIE_SAME_SITE
SPRING_DATASOURCE_URLSPRING_DATASOURCE_USERNAMESPRING_DATASOURCE_PASSWORDSPRING_JPA_HIBERNATE_DDL_AUTOSPRING_SQL_INIT_MODESPRING_KAFKA_BOOTSTRAP_SERVERSBILLING_SERVICE_ADDRESSBILLING_SERVICE_GRPC_PORT
SPRING_KAFKA_BOOTSTRAP_SERVERS
- API Gateway:
http://localhost:4004/swagger-ui.html - Auth Service:
http://localhost:4005/swagger-ui.html - Patient Service:
http://localhost:4000/swagger-ui.html
- Designed as separate services with clear responsibilities.
- Uses API Gateway for centralized routing and authorization checks.
- Implements stateless JWT authentication with refresh token lifecycle management.
- Uses gRPC for internal synchronous communication.
- Uses Kafka for asynchronous event-driven processing.
- Applies validation, exception handling, dependency injection, and layered service design.
- Uses OpenAPI documentation and Dockerized service builds for developer usability.
- Add root Docker Compose setup for services and infrastructure.
- Persist billing account data in Billing Service.
- Add integration tests for gateway security, gRPC, and Kafka flows.
- Add Spring Boot Actuator health checks.
- Move shared protobuf files into a dedicated contract module.
Name: Sujal Bendre
GitHub: https://github.com/Suj018300
LinkedIn: https://www.linkedin.com/in/bendresujal/
Email: sujalbendre2526@gmail.com
