https://github.com/4lessandrodev/ddd-app
sample app for types-ddd v3
https://github.com/4lessandrodev/ddd-app
app-example domain-driven-design sample
Last synced: 8 months ago
JSON representation
sample app for types-ddd v3
- Host: GitHub
- URL: https://github.com/4lessandrodev/ddd-app
- Owner: 4lessandrodev
- Created: 2022-08-10T05:15:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T03:57:24.000Z (over 1 year ago)
- Last Synced: 2024-04-28T07:22:27.096Z (over 1 year ago)
- Topics: app-example, domain-driven-design, sample
- Language: TypeScript
- Homepage:
- Size: 676 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DDD APP
## Simple App
App built using `types-ddd` v3 [Link Here](https://www.npmjs.com/package/types-ddd)
A minimum project to test the domain driven design lib

### How to run this app
- Install deps
```sh
$ yarn install
```
- Run the tests
```sh
$ yarn test
```
- Run the app
```sh
$ yarn dev
```
- Run integration tests
```sh
$ yarn test:e2e
```
- On your terminal run commands or copy curl to execute in postman*
```sh
# List products
$ curl http://localhost:3000/products | jq '.'
```
```sh
# Create Product
$ curl -X POST -H "Content-Type: application/json" \
-d '{ "name": "valid", "price": 21.00 }' \
http://localhost:3000/products | jq '.'
```
```sh
# Update Product
$ curl -X PUT -H "Content-Type: application/json" \
-d '{ "name": "items", "price": 42.00 }' \
http://localhost:3000/products/:id | jq '.'
```
```sh
# List Invoices
$ curl http://localhost:3000/invoices | jq '.'
```
## Business Rules
When a product (Product Context) is created, an event is dispatched to the Invoice Context domain. The domain generates an invoice aggregate and validates business rules, then dispatches another event to its own context in the infrastructure to build and save the invoice.
```mermaid
graph LR
A[Create Product] -->|Event| B[Invoice]
B -->|Processing| C[Print Invoice]
```