How f-lab-edu/off-coupon works
Main Components
• Client/API Layer: Represent the external entry points for HTTP clients (i.e. REST endpoints exposed via controllers like CouponIssueController, MemberController, etc.). This layer also includes security components (CustomAuthentication providers, handlers, and user detail service) for authentication/authorization.
• Application/Service Layer: This is where the core business logic resides. Separate components here include:
• Coupon issuance services (both synchronous and asynchronous flows)
• Order and coupon use management (OrderService, CouponUse logic)
• Member management (MemberService)
• Statistics and MyPage services for reporting and user interactions
• Scheduling components (DynamicScheduler, ScheduleRunner, etc.) for periodic tasks such as coupon issuing jobs.
• Integration & Asynchronous Processing:
• Messaging components using RabbitMQ (Producer, MessageQueueCountChecker, various coupon issue consumers, etc.)
• Distributed lock components using different strategies: NamedLock, Lettuce (Redis), and Redisson (look in the “component/lock” package and corresponding tests).
• Persistence/Repository Layer:
• MySQL repositories (implemented via MyBatis mappers and repository interfaces for Coupon, Member, Event, etc.)
• Redis repositories (and caching components for coupon and event caches)
• External Systems & Infrastructure:
• MySQL database (the main persistent store)
• Redis instance (for caching and distributed locking)
• RabbitMQ (for asynchronous messaging and queuing)
• Docker-based deployments and load-test setups indicate containerization and performance testing capabilities.
Relationships and Data Flows
• Controllers calling the service layer and from there the flow splitting to either synchronous coupon issuance or asynchronous operations via RabbitMQ.
• That services interact with distributed lock modules to ensure consistency before accessing the MySQL backend.
• Service layer interacting with persistence layers (MyBatis mappers, repositories).
• Scheduled tasks as separate components that trigger service methods at predetermined intervals.
• Optionally, mark the testing & CICD components (Jenkins pipelines, Docker, Gradle build scripts) as supporting infrastructure around the main system.
Architectural Patterns and Technologies
• Layered (or n-tier) architecture: Clearly separate Controllers, Services, Repositories, and External Integrations.
• Use of distributed locking patterns with multiple implementations (Lettuce, Redisson, MySQL NamedLock) to address high concurrency.
• Asynchronous processing via RabbitMQ and scheduled tasks indicating event-driven design.
• Technologies: Java 17, Spring Boot (core framework), MySQL, MyBatis for ORM, Redis for caching and locking, RabbitMQ for messaging, Docker for containerization, Gradle as the build tool.
• Distributed systems concerns are addressed with high-availability patterns and robust exception handling (check exception packages for coupon, member, event, etc.).