How youssefalmia/report-workflow works
Project Type and Purpose
• This project is a backend workflow management system built in Java with Spring Boot.
• It automates report handling with structured steps (create, review, validate) and uses Camunda BPMN for workflow orchestration.
• It integrates security measures (JWT authentication, RBAC), event-driven state updates, and a flexible workflow strategy using a factory pattern.
Analyzing the File Structure
• The top-level directories and files indicate a Maven-based Spring Boot project.
• The “src/main/java” tree shows a clear separation:
• Configuration classes (e.g., SecurityConfig, AsyncConfig, OpenApiConfig)
• Controllers (e.g., AuthController, ReportController) that expose REST API endpoints.
• Domain classes (entities, enums, and repositories) for the persistence layer.
• DTOs and Mappers for translating data.
• A service layer that contains business logic (including Camunda integration, workflow strategies, and event listeners).
• Utility classes (e.g., JwtUtil, CamundaDatabaseCleaner).
• The “src/main/resources” directory contains the BPMN definition and application properties.
• Testing is well-organized across unit, integration, and performance tests.
Key Components
A. REST API Layer:
• That these endpoints use JWT tokens and enforce RBAC via Spring Security.
B. Security & Configuration:
• A component for SecurityConfig and JwtAuthFilter showcasing token-based authentication, role validation, and custom error handling.
• Dual enforcement: security filtering via Spring Security and method-level checks (@PreAuthorize).
C. Service Layer:
• ReportWorkflowService that delegates workflow operations to a chosen strategy.
• Workflow Strategy and Factory Pattern:
• IReportWorkflowStrategy interface and concrete implementations like CamundaReportWorkflow.
• ReportWorkflowFactory which selects the proper strategy based on configuration.
D. Workflow Management Integration:
• Camunda BPMN as an external engine.
• BPMN file (located in “src/main/resources/bpm/camunda/report-workflow.bpmn”) and its mapping into the application.
E. Event-Driven State Updates:
• A sub-component for ReportStateListener that captures task and execution events.
• ReportStateEventListener to update the database accordingly (including logging transitions and saving ReportTransitionLog entries).
F. Persistence Layer:
• Domain models (Report, User, ReportTransitionLog) and their corresponding repositories.
• Use of H2 in-memory database as configured in application.properties.
G. Supporting Utilities and Testing:
• Optionally, include utility classes like JwtUtil for token management.
Relationships And Data Flow
• How ReportService uses ReportWorkflowService, which internally obtains a workflow strategy from ReportWorkflowFactory.
• That security checks occur at two levels: a pre-request filtering stage and within the service methods.
• That state transitions (created, reviewed, validated/refused) are recorded in the database and logged.
Architectural Patterns and Technologies
• Use of the Strategy Pattern and Factory Pattern in the workflow mechanism.
• Integration with the Camunda BPM engine.
• Layered architecture: controllers (presentation), services (business logic), domain/repositories (persistence), and configuration/security.
• Libraries and technologies: Spring Boot, Spring Security, Maven, Camunda BPM, JWT, and H2 database.
Putting It All Together
• Branch out to the event-driven components (ReportStateListener and ReportStateEventListener) that update the database represented in the persistence layer.
• Security layer as an overlay that intercepts incoming API requests.