
Enterprise Banking Microservices Platform
Professional Spring Boot microservices architecture demonstrating senior-level design patterns, annotations, and best practices for banking domain.
Architecture Overview
┌─────────────┐
│ Client │
└──────┬──────┘
│
v
┌──────────────────┐ ┌──────────────────┐
│ API Gateway │────▶│ Eureka Server │
│ Port: 8080 │ │ Port: 8761 │
└────────┬─────────┘ └──────────────────┘
│ ▲
│ │
├───────────────────────┼──────────────────┐
│ │ │
v │ v
┌────────────────┐ │ ┌─────────────────┐
│ Account Service│──────────────┘ │ Transaction Svc │
│ Port: 8081 │ │ Port: 8082 │
│ PostgreSQL │ │ MongoDB │
└────────┬───────┘ └────────┬────────┘
│ │
└──────────────┬──────────────────────────┘
│
v
┌───────────┐
│ Kafka │
└─────┬─────┘
│
v
┌──────────────────┐
│Notification Svc │
│ Port: 8083 │
└──────────────────┘
Technologies
- Java 21 (Virtual Threads)
- Spring Boot 3.2.1
- Spring Cloud 2023.0.0
- PostgreSQL 15
- MongoDB 7
- Apache Kafka 7.5
- Docker & Docker Compose
Services
1. Config Server (Port: 8888)
Centralized configuration management for all microservices.
Key Annotations:
@EnableConfigServer - Enables Spring Cloud Config Server
@SpringBootApplication - Main application entry point
2. Eureka Server (Port: 8761)
Service discovery and registration server.
Key Annotations:
@EnableEurekaServer - Enables Netflix Eureka service registry
3. API Gateway (Port: 8080)
Single entry point with routing, authentication, and circuit breakers.
Key Annotations:
@EnableDiscoveryClient - Registers with Eureka
@Configuration - Defines route configuration
@Bean - Creates RouteLocator for custom routing
@Component - Marks authentication filter
@Order - Controls filter execution order
4. Account Service (Port: 8081)
Core banking operations with PostgreSQL.
Domain Layer:
@Entity - Maps class to database table
@Table - Specifies table name and indexes
@Id - Marks primary key field
@GeneratedValue(strategy=IDENTITY) - Auto-generates ID values
@Column - Maps field to database column
@Enumerated(EnumType.STRING) - Stores enum as string
@ManyToOne - Defines many-to-one relationship
@OneToMany - Defines one-to-many relationship
@DynamicUpdate - Updates only modified columns
@CreatedDate - Auto-populates creation timestamp
@LastModifiedDate - Auto-updates modification timestamp
@EntityListeners - Enables JPA auditing
Repository Layer:
@Repository - Marks data access component
@EntityGraph - Solves N+1 query problem by eager fetching
@Query - Defines custom JPQL/SQL queries
Service Layer:
@Service - Marks business logic component
@Transactional - Manages database transactions
@Validated - Enables method-level validation
@RateLimiter - Limits request rate
@Bulkhead - Isolates concurrent requests
@CircuitBreaker - Prevents cascading failures
@TimeLimiter - Sets timeout for operations
@Retry - Retries failed operations
Controller Layer:
@RestController - Combines @Controller and @ResponseBody
@RequestMapping - Maps URL patterns to controller
@GetMapping - Handles HTTP GET requests
@PostMapping - Handles HTTP POST requests
@PutMapping - Handles HTTP PUT requests
@DeleteMapping - Handles HTTP DELETE requests
@PathVariable - Extracts values from URL path
@RequestParam - Extracts query parameters
@RequestBody - Binds request body to object
@Valid - Validates request data
@PreAuthorize - Enforces method-level security
Configuration:
@Configuration - Declares configuration class
@EnableJpaRepositories - Enables JPA repositories
@EnableJpaAuditing - Enables auditing for entities
@EnableConfigurationProperties - Enables type-safe configuration
@ConfigurationProperties - Binds properties to POJO
@EnableWebSecurity - Enables Spring Security
@EnableMethodSecurity - Enables method-level security
@ConditionalOnProperty - Conditionally loads configuration
@EnableAsync - Enables asynchronous processing
AOP:
@Aspect - Declares aspect class
@Component - Registers aspect as Spring bean
@Around - Wraps method execution
@Before - Executes before method
@AfterReturning - Executes after successful method
@AfterThrowing - Executes after exception
Exception Handling:
@RestControllerAdvice - Global exception handler
@ExceptionHandler - Handles specific exceptions
- Returns
ProblemDetail (RFC 7807 standard)
Messaging:
@Service - Kafka producer component
- Uses
KafkaTemplate for publishing events
Actuator:
@Endpoint - Creates custom actuator endpoint
@ReadOperation - Exposes read endpoint
@WriteOperation - Exposes write endpoint
- Implements
HealthIndicator - Custom health check
Validation:
@NotNull - Field cannot be null
@NotBlank - String cannot be empty
@Email - Validates email format
@Min - Minimum numeric value
@Max - Maximum numeric value
@Pattern - Validates regex pattern
@DecimalMin - Minimum decimal value
@DecimalMax - Maximum decimal value
5. Transaction Service (Port: 8082)
Transaction management with MongoDB and reactive programming.
Domain Layer:
@Document - Maps class to MongoDB collection
@Id - Marks document identifier
@Indexed - Creates MongoDB index
@CompoundIndex - Creates compound index
@Field - Maps field to document property
Repository Layer:
- Extends
ReactiveMongoRepository - Reactive data access
- Returns
Mono<T> - Single reactive result
- Returns
Flux<T> - Multiple reactive results
Controller Layer:
@RestController - REST endpoint
- Returns reactive types for non-blocking operations
Client:
@FeignClient - Declarative HTTP client
- Integrates with Eureka for load balancing
6. Notification Service (Port: 8083)
Event-driven notifications with Kafka consumer.
Configuration:
@Component - Marks configuration component
@RefreshScope - Allows dynamic config refresh
@ConfigurationProperties - Type-safe configuration
Messaging:
@Component - Kafka consumer component
@KafkaListener - Consumes Kafka messages
@RetryableTopic - Automatic retry with DLT
- Uses
ErrorHandlingDeserializer - Handles poison pills
Service:
@Service - Notification logic
@Async - Asynchronous execution with virtual threads
Annotation Reference
| Category | Annotation | Purpose |
|---|
| Core | @SpringBootApplication | Main application entry combining @Configuration, @EnableAutoConfiguration, @ComponentScan |
| @Configuration | Declares configuration class for bean definitions |
| @Bean | Registers method return value as Spring bean |
| @Component | Generic stereotype for Spring-managed component |
| Stereotype | @Service | Business logic layer component |
| @Repository | Data access layer component with exception translation |
| @RestController | REST controller combining @Controller and @ResponseBody |
| DI | Constructor injection | Preferred dependency injection method (no @Autowired needed for single constructor) |
| Web | @RequestMapping | Maps HTTP requests to handler methods |
| @GetMapping | Shortcut for GET requests |
| @PostMapping | Shortcut for POST requests |
| @PathVariable | Extracts URI template variables |
| @RequestParam | Binds query parameters |
| @RequestBody | Binds HTTP request body to object |
| Validation | @Valid | Triggers JSR-380 validation |
| @Validated | Spring validation with group support |
| @NotNull | Field required constraint |
| @Email | Email format constraint |
| JPA | @Entity | JPA entity class |
| @Table | Specifies table details |