Skip to content

Latest commit

 

History

History
78 lines (42 loc) · 4.11 KB

File metadata and controls

78 lines (42 loc) · 4.11 KB
graph LR
    User["User"]
    UserService["UserService"]
    UserRepository["UserRepository"]
    UserCreatedEvent["UserCreatedEvent"]
    UserUpdatedEvent["UserUpdatedEvent"]
    Base_Entity["Base Entity"]
    User -- "emits" --> UserCreatedEvent
    User -- "emits" --> UserUpdatedEvent
    UserService -- "interacts with" --> UserRepository
    UserService -- "interacts with" --> User
    User -- "inherits from" --> Base_Entity
Loading

CodeBoardingDemoContact

Details

The Domain Layer is encapsulated within the src/domain directory. Its boundaries are defined by: src/domain/entities/user.py, src/domain/services/user_service.py, src/domain/repositories/user_repository.py, src/domain/entities/base.py.

User

Represents the core business data and behavior of a user. It manages its own state, enforces invariants (e.g., email format, uniqueness), and signals domain events (UserCreatedEvent, UserUpdatedEvent) upon significant lifecycle changes. It also provides methods for data representation (e.g., to_dict). This is a fundamental Domain Entity.

Related Classes/Methods:

UserService

Orchestrates complex business logic that involves User entities but doesn't naturally belong to a single entity. This includes cross-entity validations (e.g., is_email_unique) that might require interaction with UserRepository ports. It ensures business rules are applied consistently. This is a Domain Service.

Related Classes/Methods:

UserRepository

Defines the contract (interface) for persistence operations related to User entities. It abstracts the underlying data storage mechanism, allowing the domain layer to remain independent of infrastructure concerns. This is a "port" in the Hexagonal Architecture, crucial for dependency inversion.

Related Classes/Methods:

UserCreatedEvent

Represents a significant occurrence in the domain when a new User entity is successfully created. It carries relevant data about the new user, enabling decoupled reactions within the same microservice or across different microservices (via an event bus). This is a Domain Event.

Related Classes/Methods:

UserUpdatedEvent

Represents a significant occurrence in the domain when an existing User entity is successfully updated. It carries relevant data about the updated user, enabling decoupled reactions. This is a Domain Event.

Related Classes/Methods:

Base Entity

Provides common attributes and behaviors for all domain entities, such as a unique identifier (id), ensuring consistency and reducing duplication across entities. User entity inherits from this base. This is an abstract base for Domain Entities.

Related Classes/Methods: