How lucassempre/lote_suinos works
Main Components
• Backend Server: This is primarily Django with its standard components such as ASGI, WSGI, and the settings.
• Core Domain (Use Case):
• Domain Models (lote_suinos/core/domain/models.py)
• Domain Repositories (lote_suinos/core/domain/repositories.py)
• Application Logic (lote_suinos/core/application/lote.py)
• Task management for asynchronous behavior (lote_suinos/core/application/tasks.py)
• Infrastructure (Adapters):
• Django ORM Models (lote_suinos/core/infrastructure/models.py)
• Concrete Repository Implementation (lote_suinos/core/infrastructure/repository.py)
• Serializers for DRF (lote_suinos/core/infrastructure/serializers.py)
• Migrations for managing DB schema (lote_suinos/core/infrastructure/migrations)
• Interfaces (Ports):
• REST API View Layer (lote_suinos/core/interfaces/views.py)
• URL routing (lote_suinos/core/interfaces/urls.py)
• Asynchronous Processing:
• Celery worker (lote_suinos/celery.py) consuming tasks which are enqueued via RabbitMQ.
• External Components:
• RabbitMQ: for enqueuing messages.
• Docker & Docker Compose: for containerizing and orchestrating the application.
• Nginx: as indicated by the custom nginx.conf provided in the entrypoint directory.
Relationships and Interactions
• The user/request enters the system via REST API endpoints exposed in the Interfaces layer. This layer is implemented using Django Rest Framework (DRF).
• The Interfaces layer communicates with the Core Application layer where the business logic (CRUD operations) is implemented.
• The Application layer leverages Domain models and repository interfaces defined in the Core Domain.
• When an asynchronous task is needed, such as processing a CRUD request asynchronously, the code enqueues a message to RabbitMQ.
• The Celery worker listens on the RabbitMQ queue and picks up tasks, processing them through the Application layer (see lote_suinos/core/application/tasks.py).
• Data persistence and retrieval are handled by the Infrastructure layer using Django’s ORM, as defined in models.py, repository.py, and serializers.
• The hexagonal architecture emphasizes that the core domain/business logic is isolated from frameworks and external technology. Adapters such as the DRF interface and ORM integrations connect the core to the outside world.
Architectural Patterns & Design Principles
• Hexagonal (Ports and Adapters) Architecture: This divides the project into loosely coupled components (domain, application, infrastructure, interfaces).
• Asynchronous Message Processing: Highlight how tasks are enqueued and processed asynchronously.
• Containers/Deployment: Indicate that Docker and Docker Compose are used to run the application along with its dependencies (e.g., RabbitMQ, possibly Nginx).