https://github.com/ddd-by-examples/library-php
WIP: A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
https://github.com/ddd-by-examples/library-php
aggregates book-library cqrs domain-driven-design events php
Last synced: about 1 year ago
JSON representation
WIP: A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
- Host: GitHub
- URL: https://github.com/ddd-by-examples/library-php
- Owner: ddd-by-examples
- License: mit
- Created: 2019-10-26T08:55:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T15:58:25.000Z (over 1 year ago)
- Last Synced: 2025-03-30T05:09:34.814Z (about 1 year ago)
- Topics: aggregates, book-library, cqrs, domain-driven-design, events, php
- Language: PHP
- Size: 373 KB
- Stars: 99
- Watchers: 17
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Library (PHP)
[](https://php.net/)
[](https://github.com/ddd-by-examples/library-php/actions/workflows/ci.yml)

**The project is currently under development. Some solutions are temporary and may change.**
Which doesn't mean you can't learn from it 😉.
A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
Reference: https://github.com/ddd-by-examples/library
## About
This is a project of a library, driven by real [business requirements](#domain-description).
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)
## How to build and run
The code below will boot the project, install all dependencies and run the build script (code style check, static analysis and all tests):
```shell
make up
make ci
```
### Interactive shell
```shell
make bash
```
## References
1. [Introducing EventStorming](https://leanpub.com/introducing_eventstorming) by Alberto Brandolini
2. [Domain Modelling Made Functional](https://pragprog.com/book/swdddf/domain-modeling-made-functional) by Scott Wlaschin
3. [Software Architecture for Developers](https://softwarearchitecturefordevelopers.com) by Simon Brown
4. [Clean Architecture](https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164) by Robert C. Martin
5. [Domain-Driven Design: Tackling Complexity in the Heart of Software](https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215) by Eric Evans