How juanpabloleonf/microservice-movie works
Main Components
• Configuration: Contains the setup for the FastAPI server (CORS, Swagger, exception handling, environment configuration, routers) under app/configuration.
• Application Layer: Contains the business logic, DTOs, handlers, mappers, and utility functions (inside app/src/application). This layer orchestrates the communication between external interfaces and the business/domain logic.
• Domain Layer: Holds the core modeling of the domain, including the movie model, persistence interfaces, services, and use case implementations (found in app/src/domain). This is the heart of the hexagonal architecture.
• Infrastructure Layer: Divided into two key parts:
• Inputs (REST controllers): Present in app/src/infrastructure/inputs/rest – manages incoming HTTP requests, validates and maps data from external sources.
• Outputs (MySQL related artifacts): Found in app/src/infrastructure/outputs/mysql – adapts the domain logic to the MySQL database by providing repositories, entities, mappers, and database settings.
• Deployment/Orchestration: Docker and docker-compose configurations indicate containerized deployment.
Relationships and Interactions
• The main data flow starts at the REST API endpoints (infrastructure/inputs/rest/controllers) which receive and validate HTTP requests.
• Requests are then mapped (using DTOs and mappers) and sent into the Application layer, which coordinates use cases (inside domain/useCases) and business logic.
• The domain layer encapsulates the movie model and uses defined interfaces (persistence and service interfaces) to interact with the database.
• The Infrastructure layer on the outputs side communicates with the MySQL database through repositories and adapters.
• Configuration components (including environment settings and middleware) ensure proper server behavior and manage cross-cutting concerns (e.g., error handling, CORS, dependency injection).
Architectural Patterns and Design Principles
• Hexagonal Architecture: Emphasize the separation between core domain logic and external adapters (REST input & MySQL output).
• Inversion of Control (IoC) and Dependency Injection: The project uses Injector for decoupling and dynamic binding, significant in the configuration modules.
• Layered Architecture: Separate layers for configuration, application logic, domain modeling, and infrastructure concerns.
• API Documentation and Error Handling: Clear concerns for API docs (Swagger/Redoc) and unified error handling.
Relevant Technologies and Frameworks
• FastAPI: For handling HTTP requests and serving the REST API.
• SQLAlchemy: Likely used in the infrastructure MySQL repository for ORM.
• Pydantic: Used for request validation and DTO creation.
• Docker & Docker Compose: For container orchestration and deployment.
• Cryptography: Placed in the context of data protection and secure processing.
• Clear labels for each main component: “Configuration”, “Application”, “Domain”, “Infrastructure – Inputs (REST)”, “Infrastructure – Outputs (MySQL)”, “Deployment (Docker)”.
• Additional notes or callouts for important design choices such as dependency injection, global exception handling, asynchronous context management, and API documentation endpoints.
• Inside, create the “Application” bubble where DTOs, handlers (commands), and mappers reside.
• Center the “Domain” bubble that contains movie models, interfaces (persistence and services), and use cases.
• On the side, add a “Configuration” section that feeds into the REST API and application layers, noting environment variables, middleware, and global exception handlers.
• Finally, indicate the deployment environment with Docker, linking it to the main service and database container.