feat(fintech): add full functional Bank domain with events, observers, and smart constructors#14
Open
TATCHIwillyjunior wants to merge 5 commits into
Conversation
…and enforce domain invariants -Introduce Price, Quantity, and Total branded types -Add factory functions to validate user input and prevent invalid values -Replace primitive price, quantity, and total with domain‑safe constructors -Add consistency rule ensuring total === price × quantity -Add upper/lower bounds for price, quantity, and total -Wrap order creation in a try/catch to surface validation errors -Preserve original structure while enforcing domain rules
…nt flow - Added /domain/bank/ folder with: - types.ts (AccountId, Balance, DailyLimit, PositiveAmount, BankAccount) - factories.ts (smart constructors for all branded types + createBankAccount) - bank.ts (pure withdraw() domain logic emitting events) - Added /domain/events/events.ts with: - WithdrawalMadeEvent - LargeWithdrawalEvent - DomainEvent union - Added /infrastructure/observers/: - observer.ts (Observer type, registry, emit(), registerObserver()) - sms.ts (Fraud Detection observer using SMS mock) - audit.ts (Audit Log observer) - Added index.ts wiring: - register observers - create account - perform withdrawal - emit events - log updated account - Ensured full functional style (no classes) - Ensured branded types and smart constructors - Ensured domain purity and observer separation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the complete FinTech (Bank) domain implemented in a fully functional style, aligned with the existing DDD + Observer architecture used in the project.
What’s Included
🏦 Bank Domain
types.tswith branded types:factories.ts:bank.ts:📣 Domain Events
events.tswith:👀 Observers (Infrastructure)
observer.ts:sms.ts:audit.ts:🧪 index.ts (Wiring)
Architecture Notes
product/domain for consistencyReady for Review
Let me know if you'd like any adjustments or additional documentation.