How 1suspensive/lovepdf works
Main Components
• Client / User Interface – This represents API consumers (such as frontend apps or postman) that make HTTP requests.
• API Gateway / Controller Layer – Represented by the controllers in the infraestructure/controllers package (e.g., PDFBasicFunctionsController, UserAuthenticationController, UserPDFController). Also include ExceptionController.
• Service / Application Layer – This includes your application services (in the application/services folder) and use case implementations. Separate PDF-specific functions (encrypt, decrypt, merge, etc.) from user-related functionalities.
• Domain Layer – Capture business models, value objects (e.g., User, Role), DTOs (data transfer objects), and exceptions. Note that this is where the core business logic is defined (in the domain/models, domain/models/dto, and domain/models/exceptions folders) along with the use case interfaces defined in the domain/ports/input and domain/ports/output.
• Infrastructure / Adapters – This layer includes the adapters interacting with external systems (e.g., JWT adapter, UserMongoAdapter), configuration files (e.g., SecurityConfig, JwtFilter), mappers, and utilities. It connects to the MongoDB (as indicated by the UserMongoRepository and properties configuration) and also contains the classes for encryption and JWT utilities.
Relationships and Data Flow
• Requests from an external client hit the REST controllers.
• The controllers forward these requests to the appropriate application services (or use cases) which implement business logic.
• The application services leverage domain-level interfaces (ports) which are implemented by infrastructure adapters.
• The repository adapter (such as UserMongoAdapter along with UserMongoRepository) handles database operations in MongoDB.
• Security is enforced by using a JwtFilter (configured via SecurityConfig) and JWT utilities for authentication.
• Data transformation between domain objects and HTTP payloads is handled by the mappers (e.g., UserMapper).
Important Architectural Patterns
• Layered or Hexagonal/Ports-and-Adapters Architecture: Clearly delineate the core domain logic from peripheral concerns.
• Separation of Concerns: Each layer (controller, application, domain, infrastructure) handles its own responsibilities.
• Use of Use Cases: Implementing business rules as discrete use case classes for different PDF and user functions.
• JWT Security: Emphasis on authentication and authorization via the security adapter and filter.
Relevant Technologies
• Java 21 and SpringBoot 3.3.3 for rapid API development.
• Gradle for build automation.
• Docker and docker-compose for containerized deployment.
• MongoDB (as implied by configuration and repository naming) for data persistence.
• JWT libraries and RSA encryption utilities for security.
Elements
• Clear labels for each component and layer.
• Notes on technology choices where applicable (e.g., Docker for deployment, Gradle for building, SpringBoot as the framework).