How gurudath-s/library-management-modulith works
Project Type and Purpose
• This is a backend‐only Modular Monolith application (no separate UI here) built with Spring Boot and Spring Modulith.
• It implements a Library Management System: user authentication, book catalog, transaction (borrow/return) processing, plus an analytics dashboard.
File Structure Analysis
• Top-level: Docker and build files, pom.xml, src/main contains Java packages under com.library.
• Under src/main/java/com/library: five modules by directory name:
• users
• books
• transactions
• analytics
• shared (common events/contracts)
• Each module follows an MVC-style layering: Controller → Service (implements ModuleAPI) → Repository.
• Shared emits domain events (BookAddedEvent, etc.) used by other modules.
• Security config and JWT filters live in users module.
Key README Insights
• Architecture Pattern: Spring Modulith (modular monolith) with explicit module boundaries and event bus.
• Modules communicate via type-safe Java interfaces (ModuleAPI) and Spring application events (@Externalized).
• Dependency graph:
Shared
↓
Users → Books → Transactions → Analytics
↘───────────↗
• Security: JWT, BCrypt, role-based access.
• Persistence: Spring Data JPA.
• Tech stack: Spring Boot 3.3, Spring Security, Spring Data, Jackson, Docker.
a. Main Components
• External Clients (e.g. REST consumers, Postman, front-end apps)
• API Gateway (if applicable, or direct REST controllers)
• Modules:
• User Management Module
• Book Management Module
• Transaction Management Module
• Analytics Module
• Shared Module (event definitions)
• Event Bus (Spring ApplicationEventPublisher)
• Relational Database (JPA/Hibernate)
• Security Layer (JWT filter chain within Users module)
• Docker / Compose environment (container boundary)
b. Relationships & Data Flows
• Clients → REST Controllers (AuthController, BookController, etc.)
• Controllers → Services (ModuleAPI implementations)
• Services → Repositories → Database
• Services → Event Bus → Other Modules (e.g. BookService publishes BookAddedEvent consumed by Analytics)
c. Important Patterns & Principles
• Modular Monolith: each package is an explicit module with public boundary interfaces.
• Layered Architecture: Controller, Service, Repository layers per module.
• Event-Driven Integration: domain events decouple modules.
• Security Cross-Cutting: JWT filter, method-level @PreAuthorize.
• DTO Pattern: clear request/response objects per module.
d. Technologies & Frameworks
• Spring Boot / Spring Web (REST)
• Spring Modulith (@Modulith, ModuleAPI, @Externalized)
• Spring Security (SecurityConfig, JwtAuthenticationFilter, JwtUtils)
• Spring Data JPA / Hibernate
• Jackson for JSON
• Docker, docker-compose for containerization
Detailed Coverage
• To capture:
• Module dependency graph (Shared → Users → Books → Transactions → Analytics)
• Cross-cutting Security (JWT filter before all controllers)
• Event-driven flows (BookAddedEvent, BookBorrowedEvent, BookReturnedEvent, UserRegisteredEvent)
• Docker boundary showing application container and database container