{"id":17749893,"url":"https://github.com/mat3e/3pigs-ddd","last_synced_at":"2025-05-12T13:14:57.780Z","repository":{"id":37595375,"uuid":"292954209","full_name":"mat3e/3pigs-ddd","owner":"mat3e","description":"DDD \u0026 Clean Architecture on the example of The Three Little Pigs","archived":false,"fork":false,"pushed_at":"2024-02-03T20:25:22.000Z","size":995,"stargazers_count":41,"open_issues_count":0,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T13:14:43.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mat3e.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-09-04T21:56:59.000Z","updated_at":"2025-04-10T21:47:48.000Z","dependencies_parsed_at":"2024-02-03T21:27:33.387Z","dependency_job_id":"530382c7-084c-4d2c-8387-84994b8c7f87","html_url":"https://github.com/mat3e/3pigs-ddd","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat3e%2F3pigs-ddd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat3e%2F3pigs-ddd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat3e%2F3pigs-ddd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mat3e%2F3pigs-ddd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mat3e","download_url":"https://codeload.github.com/mat3e/3pigs-ddd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-26T11:25:22.960Z","updated_at":"2025-05-12T13:14:57.724Z","avatar_url":"https://github.com/mat3e.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# _The Three Little Pigs_ with DDD and clean architecture\n\n[My tech talk](https://github.com/mat3e/talks/tree/master/docs/3pigs), fairy tale\nsources: [1](https://www.gillbooks.ie/AcuCustom/Sitename/DAM/101/WWSI_OM_0902.pdf), [2](http://www.hellokids.com/c_14958/reading-learning/stories-for-children/animal-stories-for-kids/the-three-little-pigs), [3](https://sacred-texts.com/neu/eng/eft/eft15.htm), [4](https://americanliterature.com/childrens-stories/the-three-little-pigs).\n\n\u003e Java, Groovy + Spock, Kotlin, Maven, Spring\n\nThe main focus should be on _The Three Little Pigs_, but to show an alternative, more pragmatic approach there is also\n_Little Red Riding Hood_ module, utilizing package-private access more, close to what's presented\nin [this great tech talk by Jakub Nabrdalik](https://www.youtube.com/watch?v=KrLFs6f2bOA).\n\n## Web app\n\nApp starts as an ordinary web app for\n\n```properties\nspring.main.web-application-type=servlet\n```\n\n### _The Three Little Pigs_\n\nAvailable operations:\n\n1. Build house: `POST` `localhost:8080/houses`\n   ```json\n    {\n        \"owner\": \"VERY_LAZY\"\n    }\n    ```\n   Possible values for `owner`:\n    * `VERY_LAZY`\n    * `LAZY`\n    * `NOT_LAZY`\n    * `NOT_LAZY_ANYMORE`\n2. Verify the house state: `GET` `localhost:8080/houses/{id}`\n3. Blow house down: `DELETE` `localhost:8080/houses/{id}`\n\nThere is a dedicated [Postman](https://www.postman.com/) collection with all these operations already\ndefined: `pigs3/adapters/src/main/resources/3Pigs.postman_collection.json`.\n\n### _Little Red Riding Hood_\n\nThere is a dedicated [Postman](https://www.postman.com/) collection with all the operations ready to\nuse: `redhood/src/main/resources/RedHood.postman_collection.json`.\n\n## Console app\n\nWhen\n\n```properties\nspring.main.web-application-type=none\n```\n\napp prints the whole _The Three Little Pigs_ story in the console.\n\n---\n\n## EventStorming\n\nAn example session with myself, for _The Three Little Pigs_. There was no need to run Process Level ES as we already had\na single BoundedContext, and it was doable to jump straight into Design Level.\n\nFor the second module I also run Big Picture ES which helped to realize that the main things are interactions and wolf's\nintentions.\n\n### Big Picture\n\n![Big Picture](./es.jpg)\n\n### Design Level - commands, rules \u0026 actors\n\n![Design Level rules](./es2.jpg)\n\n### Design Level - naming aggregates\n\n![Design Level aggregates](./es3.jpg)\n\n## Possible improvements\n\n* `House` could have mechanisms for rebuilding\n* Story can be extended - currently there is nothing about wolf climbing through the chimney and pigs lighting the fire\n    * New `House` method, e.g. `litFire`\n    * New `BigBadWolfService` method, e.g. `comeDownTheChimneyOf`\n    * Event, e.g. `WolfStartedClimbing` instead of `WolfResignedFromAttacking`, new event from `House`,\n      e.g. `WolfEscaped` (when burns in the fireplace)\n    * `WolfStartedClimbing` should call both `litFire` and `comeDownTheChimneyOf` in a proper order\n    * `WolfEscaped` should result in knowledge sharing\n* Full Event Sourcing - `House` can be built just from events, no snapshots in the current form\n* Rely fully on `DomainEventPublisher` - although `@DomainEvents` annotation looks\n  nice, it relies on `ApplicationEventPublisher` which has known limitations, especially without additional tooling\n  like [Spring Modulith](https://spring.io/blog/2022/10/21/introducing-spring-modulith)\n* Instead of \"technical\" packages corresponding with Clean Architecture and DDD, there could be more process-oriented\n  packages, like `building` (or `construcitng`) and `destroying`, where the domain logic would lay, similar as presented\n  in [this great tech talk by Victor Rentea](https://www.youtube.com/watch?v=H7HWOlANX78)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmat3e%2F3pigs-ddd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmat3e%2F3pigs-ddd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmat3e%2F3pigs-ddd/lists"}