ddd-by-examples /library
A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
★ 5,999⑂ 846👁 208⑃ 43● 41▤ 0◈ 0
5,999
stars
+4
846
forks
208
watchers
43
prs
41
issues
0
releases
0
discussions
README
Table of contents
1. About
2. Domain description
3. General assumptions
3.1 Process discovery
3.2 Project structure and architecture
3.3 Aggregates
3.4 Events
3.4.1 Events in Repositories
3.5 ArchUnit
3.6 Functional thinking
3.7 No ORM
3.8 Architecture-code gap
3.9 Model-code gap
3.10 Spring
3.11 Tests
4. How to contribute
5. References
About
This is a project of a library, driven by real business requirements.
We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development,
Event Storming, User Story Mapping.
Domain description
A public library allows patrons to place books on hold at its various library branches.
Available books can be placed on hold only by one patron at any given point in time.
Books are either circulating or restricted, and can have retrieval or usage fees.
A restricted book can only be held by a researcher patron. A regular patron is limited
to five holds at any given moment, while a researcher patron is allowed an unlimited number
of holds. An open-ended book hold is active until the patron checks out the book, at which time it
is completed. A closed-ended book hold that is not completed within a fixed number of
days after it was requested will expire. This check is done at the beginning of a day by
taking a look at daily sheet with expiring holds. Only a researcher patron can request
an open-ended hold duration. Any patron with more than two overdue checkouts at a library
branch will get a rejection if trying a hold at that same library branch. A book can be
checked out for up to 60 days. Check for overdue checkouts is done by taking a look at
daily sheet with overdue checkouts. Patron interacts with his/her current holds, checkouts, etc.
by taking a look at patron profile. Patron profile looks like a daily sheet, but the
information there is limited to one patron and is not necessarily daily. Currently a
patron can see current holds (not canceled nor expired) and current checkouts (including overdue).
Also, he/she is able to hold a book and cancel a hold.
How actually a patron knows which books are there to lend? Library has its catalogue of
books where books are added together with their specific instances. A specific book
instance of a book can be added only if there is book with matching ISBN already in
the catalogue. Book must have non-empty title and price. At the time of adding an instance
we decide whether it will be Circulating or Restricted. This enables
us to have book with same ISBN as circulated and restricted at the same time (for instance,
there is a book signed by the author that we want to keep as Restricted)
General assumptions
Process discovery
The first thing we started with was domain exploration with the help of Big Picture EventStorming.
The description you found in the previous chapter, landed on our virtual wall:
!Event Storming Domain description
The EventStorming sessTop issues
#6Implement new subdomain - fees calculation 31 comments · 2019-03-28#16Documentation image is not clear4 comments · 2019-04-04#41Question about packaging3 comments · 2019-10-01#47GroovyTemplateAutoConfiguration - Cannot find template.2 comments · 2019-12-16#45Not all tests are deterministic2 comments · 2019-12-16#5Create concept of PublishedEvent2 comments · 2019-03-28#82Patron Aggregate Concurrency Control1 comments · 2025-12-25#71Food for thoughts about extensions1 comments · 2022-07-30