Skip to content

Domain implementation with branded types and observersFor pull request#8

Open
sashatemereva13 wants to merge 15 commits into
web-development-mart:mainfrom
sashatemereva13:for_pull_request
Open

Domain implementation with branded types and observersFor pull request#8
sashatemereva13 wants to merge 15 commits into
web-development-mart:mainfrom
sashatemereva13:for_pull_request

Conversation

@sashatemereva13

Copy link
Copy Markdown

This pull request implements the domain layer using Domain-Driven Design principles.

Key features implemented:

  • Branded Types to prevent primitive obsession (Price, Email, ProjectId)
  • Smart Constructors to validate data (createEmail, createPrice)
  • Observer pattern for domain events
  • Event-driven architecture using ProjectEvent
  • Domain entity Project with deployment rule validation
  • Stock/event observers for logging, email notifications, and database updates

Business rule enforced:

  • A project cannot be deployed unless it has been built.

@irinakiseleva0 irinakiseleva0 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the domain implementation!

The domain rules are clearly described and the use of smart constructors helps enforce validation. I also like the event-based approach which keeps the observers decoupled from the domain logic.

Overall the structure is clear and follows Domain-Driven Design principles well.

Comment thread src/docs/domain.md

## Error Handling / Invalid Data
We intentionally feed wrong data (bad email, negavite price, invalid status transactions).
The app must not crash: all failures are caught with try/catch and logged. No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice domain description and clear explanation of the business rules.
It helps understand how the domain logic is reflected in the code.

| { type: "ProjectDeployed"; projectId: ProjectId }
| { type: "DiscoveryCompleted"; projectId: ProjectId };

type Observer = (event: ProjectEvent) => void;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ProjectEvent type is clearly defined and helps keep observers
decoupled from the domain logic. Nice use of an event-based approach.

observers: [],
};

notify(project, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of a domain event when creating a project.
Emitting events helps keep the domain logic decoupled from infrastructure concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants