How alexnika/2026-02-otus-microservices-nikolaev works
Scope and Evolution
This is an OTUS Microservice Architecture course repository organized as incremental assignments (hw01–hw07). Early modules demonstrate a standalone Spring Boot HTTP service and Kubernetes deployment; hw04–hw06 evolve it into a PostgreSQL-backed, monitored, JWT-secured user service. hw07 is the architectural culmination: a multi-service order/billing/notification system.
Primary Entry Points
The deployable runtime units in hw07 are independent Java/Spring Boot applications:
• User/authentication service: hw07/USERService/src/main/java/ru/otus/hw/UserServiceApplication.java
• Order service: hw07/ORDERService/src/main/java/ru/otus/hw/OrderServiceApplication.java
• Billing service: hw07/BILLINGService/src/main/java/ru/otus/hw/BillingServiceApplication.java
• Notification service: hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/NotificationServiceApplication.java
The root Gradle build defines the multi-module project at hw07/build.gradle and hw07/settings.gradle. Local composition is represented by hw07/DEV/docker-compose.yaml; Kubernetes deployment is packaged as hw07/hw07chart.
User and Identity Boundary
USERService owns users, profiles, roles, credential handling, and JWT issuance/validation. Its REST resources split authentication, role administration, user CRUD, and profile operations:
• hw07/USERService/src/main/java/ru/otus/hw/controller/AuthResource.java
• hw07/USERService/src/main/java/ru/otus/hw/controller/UserResource.java
• hw07/USERService/src/main/java/ru/otus/hw/security/JwtAuthenticationFilter.java
JWT security and BCrypt configuration form the external-client authorization boundary. User registration/service behavior can call Billing through hw07/USERService/src/main/java/ru/otus/hw/client/BillingServiceClient.java, likely establishing an account as part of user lifecycle. User data has dedicated Flyway migrations under hw07/USERService/src/main/resources/db/migration.
Order Processing and Synchronous Billing
ORDERService owns order persistence and the public order API:
• hw07/ORDERService/src/main/java/ru/otus/hw/controller/OrderResource.java
• hw07/ORDERService/src/main/java/ru/otus/hw/service/OrderServiceImpl.java
• hw07/ORDERService/src/main/java/ru/otus/hw/models/Order.java
Order creation flows through the service layer to its database, then uses BillingServiceClient for synchronous billing operations (hw07/ORDERService/src/main/java/ru/otus/hw/client/BillingServiceClient.java). This is a direct service-to-service boundary configured via REST-client and billing-URL configuration.
Billing and Internal API Boundary
BILLINGService owns accounts and transaction records:
• hw07/BILLINGService/src/main/java/ru/otus/hw/controller/AccountResource.java
• hw07/BILLINGService/src/main/java/ru/otus/hw/controller/InternalAccountResource.java
• hw07/BILLINGService/src/main/java/ru/otus/hw/service/TransactionServiceImpl.java
It exposes both account-facing and internal account/order resources. InternalApiFilterConfig in billing and order services indicates protected internal calls using an API-key boundary:
• hw07/BILLINGService/src/main/java/ru/otus/hw/config/InternalApiFilterConfig.java
• hw07/ORDERService/src/main/java/ru/otus/hw/config/InternalApiFilterConfig.java
Account and transaction schemas are independently migrated in hw07/BILLINGService/src/main/resources/db/migration.
Asynchronous Notification Pipeline
After order activity, ORDERService publishes a shared notification event through RabbitMQ:
• hw07/ORDERService/src/main/java/ru/otus/hw/producer/NotificationEventPublisher.java
• hw07/COMMONDomain/src/main/java/ru/otus/hw/dto/NotificationEvent.java
NOTIFICATIONService consumes that event, persists notifications, and exposes a notification API:
• hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/consumer/NotificationConsumer.java
• hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/service/NotificationServiceImpl.java
• hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/config/RabbitMQListenerConfig.java
This separates notification delivery from the synchronous order/billing path. COMMONDomain is the explicit shared contract module for cross-service DTOs, errors, and common entity abstractions.
Infrastructure and Operations
Each service has its own Dockerfile and application configuration, while the Helm chart provisions application deployments/services, PostgreSQL stateful infrastructure, RabbitMQ, secrets/configuration, and ingress:
• hw07/hw07chart/templates/app-deployment.yaml
• hw07/hw07chart/templates/postgres-statefulset.yaml
• hw07/hw07chart/templates/rabbitmq.yaml
Earlier hw05 adds Prometheus/Grafana deployment assets, including service monitors and a PostgreSQL exporter, under hw05/prometheus-grafana-chart. The principal material runtimes are Java/Spring Boot, Gradle (final multi-service module), PostgreSQL with Flyway migrations, RabbitMQ, Docker, Kubernetes/Helm, and NGINX Ingress.
Main entry points: hw07chart NGINX Ingress · UserServiceApplication.java User service · OrderServiceImpl.java Order workflow · BillingServiceApplication.java Billing service
Components 18
HW07 services
Multi-service order and billing system.
- User service · Owns identity, profiles, roles, and JWTs.
hw07/USERService/src/main/java/ru/otus/hw/UserServiceApplication.java - Auth and user API
hw07/USERService/src/main/java/ru/otus/hw/controller/AuthResource.java - JWT security · JWT validation and BCrypt authorization boundary.
hw07/USERService/src/main/java/ru/otus/hw/security/JwtAuthenticationFilter.java - Order service · Owns the public order API and order lifecycle.
hw07/ORDERService/src/main/java/ru/otus/hw/OrderServiceApplication.java - Order workflow · Persists orders, bills synchronously, and publishes events.
hw07/ORDERService/src/main/java/ru/otus/hw/service/OrderServiceImpl.java - Billing service · Owns accounts and transaction records.
hw07/BILLINGService/src/main/java/ru/otus/hw/BillingServiceApplication.java - Account APIs · Separates account-facing and internal account operations.
hw07/BILLINGService/src/main/java/ru/otus/hw/controller/InternalAccountResource.java - Notification service · Consumes order events and exposes notifications.
hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/NotificationServiceApplication.java - Common domain contract · Shared DTOs, errors, and entity abstractions.
hw07/COMMONDomain/src/main/java/ru/otus/hw/dto/NotificationEvent.java
State and messaging
- User PostgreSQL · Flyway-managed user schema.
hw07/USERService/src/main/resources/db/migration - Order PostgreSQL
hw07/ORDERService/src/main/java/ru/otus/hw/models/Order.java - Billing PostgreSQL · Flyway-managed account and transaction schema.
hw07/BILLINGService/src/main/resources/db/migration - Notification store
hw07/NOTIFICATIONService/src/main/java/ru/otus/hw/service/NotificationServiceImpl.java - RabbitMQ
hw07/hw07chart/templates/rabbitmq.yaml
Deployment and operations
- NGINX Ingress
hw07/hw07chart - Helm deployment chart · Deploys services, PostgreSQL, RabbitMQ, configuration, and ingress.
hw07/hw07chart/templates/app-deployment.yaml - Prometheus and Grafana · Earlier course deployment monitoring assets.
hw05/prometheus-grafana-chart
Other components
- External clients
Connections 24
- External clients → NGINX Ingress: HTTP
- NGINX Ingress → User service: routes
- NGINX Ingress → Order service: routes
- NGINX Ingress → Billing service: routes
- NGINX Ingress → Notification service: routes
- User service → Auth and user API: serves
- Auth and user API → JWT security: secured by
- User service → User PostgreSQL: user data
- User service → Account APIs: account setup · REST client call during user lifecycle.
- Order service → Order workflow: executes
- Order workflow → Order PostgreSQL: persists
- Order workflow → Account APIs: synchronous billing · Protected internal REST call.
- Billing service → Account APIs: serves
- Billing service → Billing PostgreSQL: accounts and transactions
- Order workflow → RabbitMQ: publishes notification event
- RabbitMQ → Notification service: delivers event
- Notification service → Notification store: persists notifications
- Common domain contract → Order service: event contract
- Common domain contract → Notification service: event contract
- Helm deployment chart → NGINX Ingress: provisions
- Helm deployment chart → RabbitMQ: provisions
- Prometheus and Grafana → User service: monitors
- Prometheus and Grafana → Order service: monitors
- Prometheus and Grafana → Billing service: monitors