@eventcatalog/create-eventcatalog 2.0.21 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/index.js +9 -2
- package/package.json +1 -1
- package/templates/default/channels/inventory.{env}.events/index.md +157 -0
- package/templates/default/channels/orders.{env}.events/index.md +82 -0
- package/templates/default/channels/payment.{env}.events/index.md +88 -0
- package/templates/default/components/footer.astro +8 -0
- package/templates/default/domains/Orders/index.md +19 -3
- package/templates/default/{commands → domains/Orders/services/InventoryService/commands}/AddInventory/index.md +10 -0
- package/templates/default/domains/Orders/services/InventoryService/commands/PlaceOrder/index.md +36 -0
- package/templates/default/domains/Orders/services/InventoryService/commands/PlaceOrder/schema.json +124 -0
- package/templates/default/{commands → domains/Orders/services/InventoryService/commands}/UpdateInventory/index.md +9 -0
- package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/index.md +14 -3
- package/templates/default/domains/Orders/services/InventoryService/events/InventoryAdjusted/schema.json +35 -0
- package/templates/default/{events/Inventory/InventoryAdjusted/versioned/0.0.3 → domains/Orders/services/InventoryService/events/InventoryAdjusted/versioned/1.0.0}/index.md +1 -1
- package/templates/default/domains/Orders/services/InventoryService/events/InventoryAdjusted/versioned/1.0.0/schema.avro +10 -0
- package/templates/default/domains/Orders/services/InventoryService/events/OutOfStock/index.md +102 -0
- package/templates/default/{events/Inventory/OutOfStock → domains/Orders/services/InventoryService/events/OutOfStock/versioned/0.0.1}/index.md +1 -1
- package/templates/default/{services → domains/Orders/services}/InventoryService/index.md +49 -4
- package/templates/default/domains/Orders/services/InventoryService/queries/GetInventoryList/index.md +22 -0
- package/templates/default/domains/Orders/services/InventoryService/queries/GetInventoryList/schema.json +53 -0
- package/templates/default/domains/Orders/services/InventoryService/queries/GetInventoryStatus/index.md +41 -0
- package/templates/default/domains/Orders/services/InventoryService/queries/GetInventoryStatus/schema.json +28 -0
- package/templates/default/{services → domains/Orders/services}/InventoryService/versioned/0.0.1/index.md +2 -2
- package/templates/default/{services → domains/Orders/services}/NotificationService/index.md +21 -4
- package/templates/default/domains/Orders/services/NotificationService/queries/GetNotificationDetails/index.md +26 -0
- package/templates/default/domains/Orders/services/NotificationService/queries/GetNotificationDetails/schema.json +56 -0
- package/templates/default/domains/Orders/services/NotificationService/queries/GetUserNotifications/index.md +27 -0
- package/templates/default/domains/Orders/services/NotificationService/queries/GetUserNotifications/schema.json +47 -0
- package/templates/default/domains/Orders/services/OrdersService/changelog.md +3 -0
- package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderAmended/index.md +9 -0
- package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderCancelled/index.md +7 -1
- package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderConfirmed/index.md +7 -1
- package/templates/default/{services → domains/Orders/services}/OrdersService/index.md +13 -4
- package/templates/default/domains/Orders/services/OrdersService/openapi.yml +185 -0
- package/templates/default/domains/Orders/services/OrdersService/order-service-asyncapi.yaml +148 -0
- package/templates/default/domains/Orders/services/OrdersService/queries/GetOrder/index.md +26 -0
- package/templates/default/domains/Orders/services/OrdersService/versioned/0.0.2/changelog.md +3 -0
- package/templates/default/domains/Orders/services/OrdersService/versioned/0.0.2/index.md +34 -0
- package/templates/default/domains/Orders/services/OrdersService/versioned/0.0.2/openapi.yml +96 -0
- package/templates/default/domains/Orders/services/OrdersService/versioned/0.0.2/order-service-asyncapi.yaml +148 -0
- package/templates/default/domains/Orders/versioned/0.0.1/index.md +1 -0
- package/templates/default/domains/Orders/versioned/0.0.2/index.md +49 -0
- package/templates/default/domains/Payment/index.md +1 -6
- package/templates/default/{events/Payment → domains/Payment/services/PaymentService/events}/PaymentInitiated/index.md +9 -1
- package/templates/default/domains/Payment/services/PaymentService/events/PaymentProcessed/index.md +46 -0
- package/templates/default/{events/Payment/PaymentProcessed → domains/Payment/services/PaymentService/events/PaymentProcessed/versioned/0.0.1}/index.md +5 -1
- package/templates/default/{services → domains/Payment/services}/PaymentService/index.md +3 -8
- package/templates/default/domains/Payment/services/PaymentService/queries/GetPaymentStatus/index.md +26 -0
- package/templates/default/domains/Payment/services/PaymentService/queries/GetPaymentStatus/schema.json +40 -0
- package/templates/default/domains/Subscriptions/index.md +24 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/commands/CancelSubscription/index.md +25 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/commands/SubscribeUser/index.md +25 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/events/UserSubscriptionCancelled/index.md +25 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/events/UserSubscriptionStarted/index.md +25 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/index.md +42 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/queries/GetSubscriptionStatus/index.md +26 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/queries/GetSubscriptionStatus/schema.json +46 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/queries/GetSubscriptionStatus/versioned/0.0.1/index.md +26 -0
- package/templates/default/domains/Subscriptions/services/SubscriptionService/queries/GetSubscriptionStatus/versioned/0.0.1/schema.json +46 -0
- package/templates/default/eventcatalog.config.js +0 -6
- package/templates/default/events/Inventory/InventoryAdjusted/schema.json +0 -17
- package/templates/default/events/Inventory/InventoryAdjusted/versioned/0.0.3/schema.avro +0 -14
- package/templates/default/services/OrdersService/openapi.yml +0 -170
- /package/templates/default/{services → domains/Orders/services}/InventoryService/changelog.md +0 -0
- /package/templates/default/{commands → domains/Orders/services/InventoryService/commands}/AddInventory/schema.json +0 -0
- /package/templates/default/{commands → domains/Orders/services/InventoryService/commands}/UpdateInventory/schema.json +0 -0
- /package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/changelog.md +0 -0
- /package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/schema.avro +0 -0
- /package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/versioned/0.0.1/changelog.md +0 -0
- /package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/versioned/0.0.1/index.md +0 -0
- /package/templates/default/{events/Inventory → domains/Orders/services/InventoryService/events}/InventoryAdjusted/versioned/0.0.1/schema.avro +0 -0
- /package/templates/default/{events/Inventory/InventoryAdjusted/versioned/0.0.3 → domains/Orders/services/InventoryService/events/InventoryAdjusted/versioned/1.0.0}/changelog.md +0 -0
- /package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderAmended/schema.avro +0 -0
- /package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderAmended/schema.json +0 -0
- /package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderCancelled/schema.json +0 -0
- /package/templates/default/{events/Order → domains/Orders/services/OrdersService/events}/OrderConfirmed/schema.json +0 -0
- /package/templates/default/{flows/Payment → domains/Payment/flows}/PaymentProcessed/index.md +0 -0
- /package/templates/default/{flows/Subscriptions → domains/Subscriptions/flows}/CancelSubscription/index.md +0 -0
- /package/templates/default/{flows/Subscriptions → domains/Subscriptions/flows}/CancelSubscription/versioned/0.0.1/index.md +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
# @eventcatalog/create-catalog
|
|
2
2
|
|
|
3
3
|
CLI utility to create new Eventcatalog. Full documentation at https://eventcatalog.dev.
|
|
4
|
+
|
|
5
|
+
# Sponsors
|
|
6
|
+
|
|
7
|
+
Thank you to our project sponsors.
|
|
8
|
+
|
|
9
|
+
## Gold sponsors
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
<img alt="hookdeck" src="./images/sponsors/hookdeck.svg" />
|
|
13
|
+
<p style="margin: 0; padding: 0;">Serverless infrastructure for event-driven architecture. </p>
|
|
14
|
+
<a href="https://hookdeck.com/?ref=eventcatalog-sponsor" target="_blank" >Learn more</a>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<hr />
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
<img alt="gravitee" src="./images/sponsors/gravitee-logo-black.svg" width="50%" />
|
|
21
|
+
<p style="margin: 0; padding: 0;">Manage, secure, and govern every API in your organization</p>
|
|
22
|
+
<a href="https://gravitee.io?utm_source=eventcatalog&utm_medium=web&utm_campaign=sponsorship" target="_blank" >Learn more</a>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<hr />
|
|
26
|
+
|
|
27
|
+
<div align="center">
|
|
28
|
+
<img alt="oso" src="./images/sponsors/oso-logo-green.png" width="40%" />
|
|
29
|
+
<p style="margin: 0; padding: 0;">Delivering Apache Kafka professional services to your business</p>
|
|
30
|
+
<a href="https://oso.sh/?utm_source=eventcatalog&utm_medium=web&utm_campaign=sponsorship" target="_blank" >Learn more</a>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<hr />
|
|
34
|
+
|
|
35
|
+
_Sponsors help make EventCatalog sustainable, want to help the project? Get in touch! Or [visit our sponsor page](https://www.eventcatalog.dev/support)._
|
package/dist/index.js
CHANGED
|
@@ -22466,7 +22466,7 @@ var import_os2 = __toESM(require("os"));
|
|
|
22466
22466
|
var package_default = {
|
|
22467
22467
|
name: "@eventcatalog/create-eventcatalog",
|
|
22468
22468
|
description: "Create EventCatalog with one command",
|
|
22469
|
-
version: "2.0
|
|
22469
|
+
version: "2.1.0",
|
|
22470
22470
|
bin: {
|
|
22471
22471
|
"create-catalog": "./dist/index.js"
|
|
22472
22472
|
},
|
|
@@ -22746,8 +22746,9 @@ function validateNpmName(name) {
|
|
|
22746
22746
|
// index.ts
|
|
22747
22747
|
var projectPath = "";
|
|
22748
22748
|
var organizationName = "";
|
|
22749
|
-
var program = new import_commander.default.Command(package_default.name).version(package_default.version).arguments("<project-directory>").usage(`${import_chalk5.default.green("<project-directory>")} [options]`).action((name) => {
|
|
22749
|
+
var program = new import_commander.default.Command(package_default.name).version(package_default.version).arguments("<project-directory>").usage(`${import_chalk5.default.green("<project-directory>")} [options]`).action((name, options) => {
|
|
22750
22750
|
projectPath = name;
|
|
22751
|
+
organizationName = options.organizationName || "";
|
|
22751
22752
|
}).option(
|
|
22752
22753
|
"--ts, --typescript",
|
|
22753
22754
|
`
|
|
@@ -22801,6 +22802,12 @@ var program = new import_commander.default.Command(package_default.name).version
|
|
|
22801
22802
|
In this case, you must specify the path to the example separately:
|
|
22802
22803
|
--example-path foo/bar
|
|
22803
22804
|
`
|
|
22805
|
+
).option(
|
|
22806
|
+
"--organization-name [name]",
|
|
22807
|
+
`
|
|
22808
|
+
|
|
22809
|
+
The organization name.
|
|
22810
|
+
`
|
|
22804
22811
|
).allowUnknownOption().parse(process.argv);
|
|
22805
22812
|
var packageManager = !!program.useNpm ? "npm" : !!program.usePnpm ? "pnpm" : getPkgManager();
|
|
22806
22813
|
async function run() {
|
package/package.json
CHANGED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: inventory.{env}.events
|
|
3
|
+
name: Inventory Events Channel
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
summary: |
|
|
6
|
+
Central event stream for all inventory-related events including stock updates, allocations, and adjustments
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
address: inventory.{env}.events
|
|
10
|
+
protocols:
|
|
11
|
+
- kafka
|
|
12
|
+
|
|
13
|
+
parameters:
|
|
14
|
+
env:
|
|
15
|
+
enum:
|
|
16
|
+
- dev
|
|
17
|
+
- sit
|
|
18
|
+
- prod
|
|
19
|
+
description: 'Environment to use'
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Overview
|
|
23
|
+
The Inventory Events channel is the central stream for all inventory-related events across the system. This includes stock level changes, inventory allocations, adjustments, and stocktake events. Events for a specific SKU are guaranteed to be processed in sequence when using productId as the partition key.
|
|
24
|
+
|
|
25
|
+
<ChannelInformation />
|
|
26
|
+
|
|
27
|
+
### Publishing and Subscribing to Events
|
|
28
|
+
|
|
29
|
+
#### Publishing Example
|
|
30
|
+
```python
|
|
31
|
+
from kafka import KafkaProducer
|
|
32
|
+
import json
|
|
33
|
+
from datetime import datetime
|
|
34
|
+
|
|
35
|
+
# Kafka configuration
|
|
36
|
+
bootstrap_servers = ['localhost:9092']
|
|
37
|
+
topic = f'inventory.{env}.events'
|
|
38
|
+
|
|
39
|
+
# Create a Kafka producer
|
|
40
|
+
producer = KafkaProducer(
|
|
41
|
+
bootstrap_servers=bootstrap_servers,
|
|
42
|
+
value_serializer=lambda v: json.dumps(v).encode('utf-8')
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Example inventory update event
|
|
46
|
+
inventory_event = {
|
|
47
|
+
"eventType": "STOCK_LEVEL_CHANGED",
|
|
48
|
+
"timestamp": datetime.utcnow().isoformat(),
|
|
49
|
+
"version": "1.0",
|
|
50
|
+
"payload": {
|
|
51
|
+
"productId": "PROD-456",
|
|
52
|
+
"locationId": "WH-123",
|
|
53
|
+
"previousQuantity": 100,
|
|
54
|
+
"newQuantity": 95,
|
|
55
|
+
"changeReason": "ORDER_FULFILLED",
|
|
56
|
+
"unitOfMeasure": "EACH",
|
|
57
|
+
"batchInfo": {
|
|
58
|
+
"batchId": "BATCH-789",
|
|
59
|
+
"expiryDate": "2025-12-31"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"metadata": {
|
|
63
|
+
"source": "warehouse_system",
|
|
64
|
+
"correlationId": "inv-xyz-123",
|
|
65
|
+
"userId": "john.doe"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Send the message - using productId as key for partitioning
|
|
70
|
+
producer.send(
|
|
71
|
+
topic,
|
|
72
|
+
key=inventory_event['payload']['productId'].encode('utf-8'),
|
|
73
|
+
value=inventory_event
|
|
74
|
+
)
|
|
75
|
+
producer.flush()
|
|
76
|
+
|
|
77
|
+
print(f"Inventory event sent to topic {topic}")
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Subscription example
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from kafka import KafkaConsumer
|
|
85
|
+
import json
|
|
86
|
+
from datetime import datetime
|
|
87
|
+
|
|
88
|
+
class InventoryEventConsumer:
|
|
89
|
+
def __init__(self):
|
|
90
|
+
# Kafka configuration
|
|
91
|
+
self.topic = f'inventory.{env}.events'
|
|
92
|
+
self.consumer = KafkaConsumer(
|
|
93
|
+
self.topic,
|
|
94
|
+
bootstrap_servers=['localhost:9092'],
|
|
95
|
+
group_id='inventory-processor-group',
|
|
96
|
+
auto_offset_reset='earliest',
|
|
97
|
+
enable_auto_commit=False,
|
|
98
|
+
value_deserializer=lambda x: json.loads(x.decode('utf-8')),
|
|
99
|
+
key_deserializer=lambda x: x.decode('utf-8') if x else None
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def process_event(self, event):
|
|
103
|
+
"""Process individual inventory events based on type"""
|
|
104
|
+
event_type = event.get('eventType')
|
|
105
|
+
|
|
106
|
+
if event_type == 'STOCK_LEVEL_CHANGED':
|
|
107
|
+
self.handle_stock_level_change(event)
|
|
108
|
+
elif event_type == 'LOW_STOCK_ALERT':
|
|
109
|
+
self.handle_low_stock_alert(event)
|
|
110
|
+
# Add more event type handlers as needed
|
|
111
|
+
|
|
112
|
+
def handle_stock_level_change(self, event):
|
|
113
|
+
"""Handle stock level change events"""
|
|
114
|
+
payload = event['payload']
|
|
115
|
+
print(f"Stock level change detected for product {payload['productId']}")
|
|
116
|
+
print(f"New quantity: {payload['newQuantity']}")
|
|
117
|
+
# Add your business logic here
|
|
118
|
+
|
|
119
|
+
def handle_low_stock_alert(self, event):
|
|
120
|
+
"""Handle low stock alert events"""
|
|
121
|
+
payload = event['payload']
|
|
122
|
+
print(f"Low stock alert for product {payload['productId']}")
|
|
123
|
+
print(f"Current quantity: {payload['currentQuantity']}")
|
|
124
|
+
# Add your business logic here
|
|
125
|
+
|
|
126
|
+
def start_consuming(self):
|
|
127
|
+
"""Start consuming messages from the topic"""
|
|
128
|
+
try:
|
|
129
|
+
print(f"Starting consumption from topic: {self.topic}")
|
|
130
|
+
for message in self.consumer:
|
|
131
|
+
try:
|
|
132
|
+
# Process the message
|
|
133
|
+
event = message.value
|
|
134
|
+
print(f"Received event: {event['eventType']} for product: {event['payload']['productId']}")
|
|
135
|
+
|
|
136
|
+
# Process the event
|
|
137
|
+
self.process_event(event)
|
|
138
|
+
|
|
139
|
+
# Commit the offset after successful processing
|
|
140
|
+
self.consumer.commit()
|
|
141
|
+
|
|
142
|
+
except Exception as e:
|
|
143
|
+
print(f"Error processing message: {str(e)}")
|
|
144
|
+
# Implement your error handling logic here
|
|
145
|
+
# You might want to send to a DLQ (Dead Letter Queue)
|
|
146
|
+
|
|
147
|
+
except Exception as e:
|
|
148
|
+
print(f"Consumer error: {str(e)}")
|
|
149
|
+
finally:
|
|
150
|
+
# Clean up
|
|
151
|
+
self.consumer.close()
|
|
152
|
+
|
|
153
|
+
if __name__ == "__main__":
|
|
154
|
+
# Create and start the consumer
|
|
155
|
+
consumer = InventoryEventConsumer()
|
|
156
|
+
consumer.start_consuming()
|
|
157
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: orders.{env}.events
|
|
3
|
+
name: Order Events Channel
|
|
4
|
+
version: 1.0.1
|
|
5
|
+
summary: |
|
|
6
|
+
Central event stream for all order-related events in the order processing lifecycle
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
address: orders.{env}.events
|
|
10
|
+
protocols:
|
|
11
|
+
- kafka
|
|
12
|
+
|
|
13
|
+
parameters:
|
|
14
|
+
env:
|
|
15
|
+
enum:
|
|
16
|
+
- dev
|
|
17
|
+
- sit
|
|
18
|
+
- prod
|
|
19
|
+
description: 'Environment to use'
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Overview
|
|
23
|
+
The Orders Events channel is the central stream for all order-related events across the order processing lifecycle. This includes order creation, updates, payment status, fulfillment status, and customer communications. All events related to a specific order are guaranteed to be processed in sequence when using orderId as the partition key.
|
|
24
|
+
|
|
25
|
+
<ChannelInformation />
|
|
26
|
+
|
|
27
|
+
### Publishing a message using Kafka
|
|
28
|
+
|
|
29
|
+
Here is an example of how to publish an order event using Kafka:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from kafka import KafkaProducer
|
|
33
|
+
import json
|
|
34
|
+
from datetime import datetime
|
|
35
|
+
|
|
36
|
+
# Kafka configuration
|
|
37
|
+
bootstrap_servers = ['localhost:9092']
|
|
38
|
+
topic = f'orders.{env}.events'
|
|
39
|
+
|
|
40
|
+
# Create a Kafka producer
|
|
41
|
+
producer = KafkaProducer(
|
|
42
|
+
bootstrap_servers=bootstrap_servers,
|
|
43
|
+
value_serializer=lambda v: json.dumps(v).encode('utf-8')
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Example order created event
|
|
47
|
+
order_event = {
|
|
48
|
+
"eventType": "ORDER_CREATED",
|
|
49
|
+
"timestamp": datetime.utcnow().isoformat(),
|
|
50
|
+
"version": "1.0",
|
|
51
|
+
"payload": {
|
|
52
|
+
"orderId": "12345",
|
|
53
|
+
"customerId": "CUST-789",
|
|
54
|
+
"items": [
|
|
55
|
+
{
|
|
56
|
+
"productId": "PROD-456",
|
|
57
|
+
"quantity": 2,
|
|
58
|
+
"price": 29.99
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"totalAmount": 59.98,
|
|
62
|
+
"shippingAddress": {
|
|
63
|
+
"street": "123 Main St",
|
|
64
|
+
"city": "Springfield",
|
|
65
|
+
"country": "US"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"metadata": {
|
|
69
|
+
"source": "web_checkout",
|
|
70
|
+
"correlationId": "abc-xyz-123"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Send the message - using orderId as key for partitioning
|
|
75
|
+
producer.send(
|
|
76
|
+
topic,
|
|
77
|
+
key=order_event['payload']['orderId'].encode('utf-8'),
|
|
78
|
+
value=order_event
|
|
79
|
+
)
|
|
80
|
+
producer.flush()
|
|
81
|
+
|
|
82
|
+
print(f"Order event sent to topic {topic}")
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: payments.{env}.events
|
|
3
|
+
name: Payment Events Channel
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
summary: |
|
|
6
|
+
All events contain payment ID for traceability and ordered processing.
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
address: payments.{env}.events
|
|
10
|
+
protocols:
|
|
11
|
+
- kafka
|
|
12
|
+
|
|
13
|
+
parameters:
|
|
14
|
+
env:
|
|
15
|
+
enum:
|
|
16
|
+
- dev
|
|
17
|
+
- sit
|
|
18
|
+
- prod
|
|
19
|
+
description: 'Environment to use for payment events'
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Overview
|
|
23
|
+
The Payments Events channel is the central stream for all payment lifecycle events. This includes payment initiation, authorization, capture, completion and failure scenarios. Events for a specific payment are guaranteed to be processed in sequence when using paymentId as the partition key.
|
|
24
|
+
|
|
25
|
+
<ChannelInformation />
|
|
26
|
+
|
|
27
|
+
### Publishing Events Using Kafka
|
|
28
|
+
|
|
29
|
+
Here's an example of publishing a payment event:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from kafka import KafkaProducer
|
|
33
|
+
import json
|
|
34
|
+
from datetime import datetime
|
|
35
|
+
|
|
36
|
+
# Kafka configuration
|
|
37
|
+
bootstrap_servers = ['localhost:9092']
|
|
38
|
+
topic = f'payments.{env}.events'
|
|
39
|
+
|
|
40
|
+
# Create Kafka producer
|
|
41
|
+
producer = KafkaProducer(
|
|
42
|
+
bootstrap_servers=bootstrap_servers,
|
|
43
|
+
value_serializer=lambda v: json.dumps(v).encode('utf-8')
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Example payment processed event
|
|
47
|
+
payment_event = {
|
|
48
|
+
"eventType": "PAYMENT_PROCESSED",
|
|
49
|
+
"timestamp": datetime.utcnow().isoformat(),
|
|
50
|
+
"version": "1.0",
|
|
51
|
+
"payload": {
|
|
52
|
+
"paymentId": "PAY-123-456",
|
|
53
|
+
"orderId": "ORD-789",
|
|
54
|
+
"amount": {
|
|
55
|
+
"value": 99.99,
|
|
56
|
+
"currency": "USD"
|
|
57
|
+
},
|
|
58
|
+
"status": "SUCCESS",
|
|
59
|
+
"paymentMethod": {
|
|
60
|
+
"type": "CREDIT_CARD",
|
|
61
|
+
"last4": "4242",
|
|
62
|
+
"expiryMonth": "12",
|
|
63
|
+
"expiryYear": "2025",
|
|
64
|
+
"network": "VISA"
|
|
65
|
+
},
|
|
66
|
+
"transactionDetails": {
|
|
67
|
+
"processorId": "stripe_123xyz",
|
|
68
|
+
"authorizationCode": "AUTH123",
|
|
69
|
+
"captureId": "CAP456"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"metadata": {
|
|
73
|
+
"correlationId": "corr-123-abc",
|
|
74
|
+
"merchantId": "MERCH-456",
|
|
75
|
+
"source": "payment_service",
|
|
76
|
+
"environment": "prod",
|
|
77
|
+
"idempotencyKey": "PAY-123-456-2024-11-11-99.99"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Send message - using paymentId as key for partitioning
|
|
82
|
+
producer.send(
|
|
83
|
+
topic,
|
|
84
|
+
key=payment_event['payload']['paymentId'].encode('utf-8'),
|
|
85
|
+
value=payment_event
|
|
86
|
+
)
|
|
87
|
+
producer.flush()
|
|
88
|
+
```
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: Orders
|
|
3
3
|
name: Orders
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
owners:
|
|
6
6
|
- dboyne
|
|
7
|
+
- full-stack
|
|
7
8
|
services:
|
|
8
9
|
- id: InventoryService
|
|
9
10
|
version: 0.0.2
|
|
@@ -17,11 +18,21 @@ badges:
|
|
|
17
18
|
textColor: blue
|
|
18
19
|
---
|
|
19
20
|
|
|
21
|
+
import Footer from '@catalog/components/footer.astro';
|
|
22
|
+
|
|
20
23
|
## Overview
|
|
21
24
|
|
|
25
|
+
<Admonition type="warning">Please ensure all services are updated to the latest version for compatibility and performance improvements.</Admonition>
|
|
26
|
+
|
|
22
27
|
The Orders domain handles all operations related to customer orders, from creation to fulfillment. This documentation provides an overview of the events and services involved in the Orders domain, helping developers and stakeholders understand the event-driven architecture.
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
|
|
30
|
+
<Tiles >
|
|
31
|
+
<Tile icon="UserGroupIcon" href="/docs/teams/full-stack" title="Contact the team" description="Any questions? Feel free to contact the owners" />
|
|
32
|
+
<Tile icon="RectangleGroupIcon" href={`/visualiser/domains/${frontmatter.id}/${frontmatter.version}`} title={`${frontmatter.services.length} services are in this domain`} description="This service sends messages to downstream consumers" />
|
|
33
|
+
</Tiles>
|
|
34
|
+
|
|
35
|
+
|
|
25
36
|
|
|
26
37
|
## Bounded context
|
|
27
38
|
|
|
@@ -53,4 +64,9 @@ Documented flow when a user cancels their subscription.
|
|
|
53
64
|
|
|
54
65
|
<Flow id="CancelSubscription" version="latest" includeKey={false} />
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
### Payment processing flow
|
|
68
|
+
Documented flow when a user makes a payment within the order domain
|
|
69
|
+
|
|
70
|
+
<Flow id="PaymentFlow" version="latest" includeKey={false} />
|
|
71
|
+
|
|
72
|
+
<Footer />
|
|
@@ -14,9 +14,15 @@ badges:
|
|
|
14
14
|
- content: Recently updated!
|
|
15
15
|
backgroundColor: green
|
|
16
16
|
textColor: green
|
|
17
|
+
channels:
|
|
18
|
+
- id: inventory.{env}.events
|
|
19
|
+
parameters:
|
|
20
|
+
env: staging
|
|
17
21
|
schemaPath: 'schema.json'
|
|
18
22
|
---
|
|
19
23
|
|
|
24
|
+
import Footer from '@catalog/components/footer.astro';
|
|
25
|
+
|
|
20
26
|
## Overview
|
|
21
27
|
|
|
22
28
|
The AddInventory command is issued to add new stock to the inventory. This command is used by the inventory management system to update the quantity of products available in the warehouse or store.
|
|
@@ -40,3 +46,7 @@ The AddInventory command is issued to add new stock to the inventory. This comma
|
|
|
40
46
|
## Schema
|
|
41
47
|
|
|
42
48
|
<Schema file="schema.json"/>
|
|
49
|
+
|
|
50
|
+
<Footer />
|
|
51
|
+
|
|
52
|
+
|
package/templates/default/domains/Orders/services/InventoryService/commands/PlaceOrder/index.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PlaceOrder
|
|
3
|
+
name: Place Order
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: |
|
|
6
|
+
Command that will place an order
|
|
7
|
+
owners:
|
|
8
|
+
- dboyne
|
|
9
|
+
- msmith
|
|
10
|
+
- asmith
|
|
11
|
+
- full-stack
|
|
12
|
+
- mobile-devs
|
|
13
|
+
badges:
|
|
14
|
+
- content: Recently updated!
|
|
15
|
+
backgroundColor: green
|
|
16
|
+
textColor: green
|
|
17
|
+
schemaPath: 'schema.json'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
import Footer from '@catalog/components/footer.astro';
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
The Order Placement Command is a versatile and robust system designed to streamline the process of placing an order. This command takes care of all the essential details needed to complete a purchase, ensuring a smooth and efficient transaction from start to finish.
|
|
25
|
+
|
|
26
|
+
## Architecture diagram
|
|
27
|
+
|
|
28
|
+
<NodeGraph/>
|
|
29
|
+
|
|
30
|
+
## Schema
|
|
31
|
+
|
|
32
|
+
<SchemaViewer file="schema.json"/>
|
|
33
|
+
|
|
34
|
+
<Footer />
|
|
35
|
+
|
|
36
|
+
|
package/templates/default/domains/Orders/services/InventoryService/commands/PlaceOrder/schema.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Order",
|
|
4
|
+
"description": "A schema representing an order placed by a customer",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"orderId": {
|
|
8
|
+
"description": "Unique identifier for the order",
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"customer": {
|
|
12
|
+
"description": "Information about the customer placing the order",
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"customerId": {
|
|
16
|
+
"description": "Unique identifier for the customer",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"description": "Name of the customer",
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"email": {
|
|
24
|
+
"description": "Email address of the customer",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"format": "email"
|
|
27
|
+
},
|
|
28
|
+
"phone": {
|
|
29
|
+
"description": "Phone number of the customer",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "^[+]?[0-9]{10,15}$"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"required": ["customerId", "name", "email"]
|
|
35
|
+
},
|
|
36
|
+
"items": {
|
|
37
|
+
"description": "List of items in the order",
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"itemId": {
|
|
43
|
+
"description": "Unique identifier for the item",
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"name": {
|
|
47
|
+
"description": "Name of the item",
|
|
48
|
+
"type": "string"
|
|
49
|
+
},
|
|
50
|
+
"quantity": {
|
|
51
|
+
"description": "Quantity of the item ordered",
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"minimum": 1
|
|
54
|
+
},
|
|
55
|
+
"price": {
|
|
56
|
+
"description": "Price per unit of the item",
|
|
57
|
+
"type": "number",
|
|
58
|
+
"minimum": 0
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"required": ["itemId", "name", "quantity", "price"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"shippingAddress": {
|
|
65
|
+
"description": "Address where the order will be shipped",
|
|
66
|
+
"type": "object",
|
|
67
|
+
"properties": {
|
|
68
|
+
"street": {
|
|
69
|
+
"description": "Street address",
|
|
70
|
+
"type": "string"
|
|
71
|
+
},
|
|
72
|
+
"city": {
|
|
73
|
+
"description": "City",
|
|
74
|
+
"type": "string"
|
|
75
|
+
},
|
|
76
|
+
"state": {
|
|
77
|
+
"description": "State or province",
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"zip": {
|
|
81
|
+
"description": "ZIP or postal code",
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"country": {
|
|
85
|
+
"description": "Country",
|
|
86
|
+
"type": "string"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"required": ["street", "city", "state", "zip", "country"]
|
|
90
|
+
},
|
|
91
|
+
"payment": {
|
|
92
|
+
"description": "Payment information for the order",
|
|
93
|
+
"type": "object",
|
|
94
|
+
"properties": {
|
|
95
|
+
"paymentMethod": {
|
|
96
|
+
"description": "Payment method used",
|
|
97
|
+
"type": "string",
|
|
98
|
+
"enum": ["Credit Card", "PayPal", "Bank Transfer"]
|
|
99
|
+
},
|
|
100
|
+
"transactionId": {
|
|
101
|
+
"description": "Transaction ID for the payment",
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
"amount": {
|
|
105
|
+
"description": "Total amount paid",
|
|
106
|
+
"type": "number",
|
|
107
|
+
"minimum": 0
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"required": ["paymentMethod", "transactionId", "amount"]
|
|
111
|
+
},
|
|
112
|
+
"orderDate": {
|
|
113
|
+
"description": "Date when the order was placed",
|
|
114
|
+
"type": "string",
|
|
115
|
+
"format": "date-time"
|
|
116
|
+
},
|
|
117
|
+
"status": {
|
|
118
|
+
"description": "Current status of the order",
|
|
119
|
+
"type": "string",
|
|
120
|
+
"enum": ["Pending", "Processing", "Shipped", "Delivered", "Cancelled"]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"required": ["orderId", "customer", "items", "shippingAddress", "payment", "orderDate", "status"]
|
|
124
|
+
}
|
|
@@ -14,9 +14,15 @@ badges:
|
|
|
14
14
|
- content: Recently updated!
|
|
15
15
|
backgroundColor: green
|
|
16
16
|
textColor: green
|
|
17
|
+
channels:
|
|
18
|
+
- id: inventory.{env}.events
|
|
19
|
+
parameters:
|
|
20
|
+
env: staging
|
|
17
21
|
schemaPath: "schema.json"
|
|
18
22
|
---
|
|
19
23
|
|
|
24
|
+
import Footer from '@catalog/components/footer.astro';
|
|
25
|
+
|
|
20
26
|
## Overview
|
|
21
27
|
|
|
22
28
|
The UpdateInventory command is issued to update the existing stock levels of a product in the inventory. This command is used by the inventory management system to adjust the quantity of products available in the warehouse or store, either by increasing or decreasing the current stock levels.
|
|
@@ -25,6 +31,8 @@ The UpdateInventory command is issued to update the existing stock levels of a p
|
|
|
25
31
|
|
|
26
32
|
<NodeGraph />
|
|
27
33
|
|
|
34
|
+
<SchemaViewer file="schema.json" title="JSON Schema" maxHeight="500" />
|
|
35
|
+
|
|
28
36
|
## Payload example
|
|
29
37
|
|
|
30
38
|
```json title="Payload example"
|
|
@@ -40,3 +48,4 @@ The UpdateInventory command is issued to update the existing stock levels of a p
|
|
|
40
48
|
|
|
41
49
|
<Schema file="schema.json"/>
|
|
42
50
|
|
|
51
|
+
<Footer />
|