How juanpabloleonf/microservice-album-song works
Main Components
• API / REST Entry Point: Represent the REST controllers responsible for accepting HTTP requests. In this project, these are in the infrastructure layer under “app/src/infrastructure/inputs/rest/controllers” (album_controller.py and song_controller.py). Also include the REST DTO mappers.
• Application Layer: Represent the “app/src/application” directory which contains the business logic, including DTOs (data transfer objects), handlers, mappers, and utility functions. This is where the incoming request data is processed.
• Domain Layer: Capture the core of the business logic, including the domain models (album_model.py, song_model.py), the persistence interfaces (i_persistence_album.py, i_persistence_song.py), and the use cases (use_case_album.py, use_case_song.py). This layer is independent of external systems.
• Infrastructure / Output Layer: Represent the MySQL adapter layer found under “app/src/infrastructure/outputs/mysql”, which includes entities, repositories, and mappers that transform domain objects to database representations. This emphasizes the separation from business logic.
• Configuration & Deployment: Include the configuration settings (CORS, Swagger, environment variables, middleware) in “app/configuration” and the project’s deployment aspects – note the Dockerfile, docker-compose.yml, and main.py that bootstraps the FastAPI server using uvicorn.
Relationships and Interactions
• Present a clear interaction between the application layer and the domain layer. Emphasize that business rules are enforced by use cases and domain services, using interfaces (ports).
• That the domain layer interfaces into persistence by calling the interfaces defined for repositories, which the infrastructure layer actually implements.
• That the infrastructure layer uses adapters and mappers to convert objects between the domain and the database (MySQL) representations.
• Finally, include configuration components feeding into all layers (e.g., dependency injection and environment configurations), ensuring that global error handling and security (CORS, encryption) are also represented.
Architectural Patterns and Design Principles
• Hexagonal architecture (ports and adapters) pattern. Group the layers around the central domain logic.
• Separation of concerns—controllers handle I/O, the application layer encapsulates business processing and coordination, and the domain layer remains free of external dependencies.
• Dependency injection, which is used to decouple implementations from abstractions, evidenced by the Injector modules in “app/configuration”.
Relevant Technologies
• Docker and docker-compose, which are essential for containerizing and deploying the microservice.
• Usage of Cryptography for sensitive data handling.