-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventcatalog-ai-demo.txt
4643 lines (3895 loc) · 139 KB
/
eventcatalog-ai-demo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
================================================================================
File: .dockerignore
Size: 92 B
================================================================================
.eventcatalog-core/
.git/
dist/
node_modules/
.gitignore
.dockerignore
Dockerfile
README.md
================================================================================
File: .gitignore
Size: 243 B
================================================================================
# Dependencies
/node_modules
# Production
/build
# Generated files
.astro
out
dist
# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.eventcatalog-core
================================================================================
File: Dockerfile
Size: 461 B
================================================================================
## Stage 1: Build the app
FROM node:lts AS build
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm install
# Copy source code
COPY . .
# Fix for Astro in Docker: https://github.com/withastro/astro/issues/2596
ENV NODE_OPTIONS=--max_old_space_size=2048
# Build the app
RUN npm run build
## Stage 2: Serve app with httpd server
FROM httpd:2.4
# Copy built app to serve
COPY --from=build /app/dist /usr/local/apache2/htdocs
================================================================================
File: README.md
Size: 801 B
================================================================================
# EventCatalog AI Demo
This is a demo of how to use AI to ask questions about your EventCatalog.
This demo uses [git2txt](https://github.com/addyosmani/git2txt) to extract the text from the git repo and uses this for the LLM context.
How to run the demo:
1. Clone the repo or [Create your own EventCatalog](https://www.eventcatalog.dev/)
2. Run npx `git2txt https://github.com/event-catalog/eventcatalog-ai-demo` (replace with your repo)
3. Open your AI Agent and add the context from the previous step.
4. Ask questions about your EventCatalog!
## Get these features with EventCatalog
We are working on [EventCatalog Studio](https://studio.eventcatalog.dev/), a visual designer for event-driven architectures.
You can sign up for the beta [here](https://eventcatalog.dev/studio).
License: MIT
================================================================================
File: channels/inventory.{env}.events/index.md
Size: 4.88 kB
================================================================================
---
id: inventory.{env}.events
name: Inventory Events Channel
version: 1.0.0
summary: |
Central event stream for all inventory-related events including stock updates, allocations, and adjustments
owners:
- dboyne
address: inventory.{env}.events
protocols:
- kafka
parameters:
env:
enum:
- dev
- sit
- prod
description: 'Environment to use'
---
### Overview
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.
<ChannelInformation />
### Publishing and Subscribing to Events
#### Publishing Example
```python
from kafka import KafkaProducer
import json
from datetime import datetime
# Kafka configuration
bootstrap_servers = ['localhost:9092']
topic = f'inventory.{env}.events'
# Create a Kafka producer
producer = KafkaProducer(
bootstrap_servers=bootstrap_servers,
value_serializer=lambda v: json.dumps(v).encode('utf-8')
)
# Example inventory update event
inventory_event = {
"eventType": "STOCK_LEVEL_CHANGED",
"timestamp": datetime.utcnow().isoformat(),
"version": "1.0",
"payload": {
"productId": "PROD-456",
"locationId": "WH-123",
"previousQuantity": 100,
"newQuantity": 95,
"changeReason": "ORDER_FULFILLED",
"unitOfMeasure": "EACH",
"batchInfo": {
"batchId": "BATCH-789",
"expiryDate": "2025-12-31"
}
},
"metadata": {
"source": "warehouse_system",
"correlationId": "inv-xyz-123",
"userId": "john.doe"
}
}
# Send the message - using productId as key for partitioning
producer.send(
topic,
key=inventory_event['payload']['productId'].encode('utf-8'),
value=inventory_event
)
producer.flush()
print(f"Inventory event sent to topic {topic}")
```
### Subscription example
```python
from kafka import KafkaConsumer
import json
from datetime import datetime
class InventoryEventConsumer:
def __init__(self):
# Kafka configuration
self.topic = f'inventory.{env}.events'
self.consumer = KafkaConsumer(
self.topic,
bootstrap_servers=['localhost:9092'],
group_id='inventory-processor-group',
auto_offset_reset='earliest',
enable_auto_commit=False,
value_deserializer=lambda x: json.loads(x.decode('utf-8')),
key_deserializer=lambda x: x.decode('utf-8') if x else None
)
def process_event(self, event):
"""Process individual inventory events based on type"""
event_type = event.get('eventType')
if event_type == 'STOCK_LEVEL_CHANGED':
self.handle_stock_level_change(event)
elif event_type == 'LOW_STOCK_ALERT':
self.handle_low_stock_alert(event)
# Add more event type handlers as needed
def handle_stock_level_change(self, event):
"""Handle stock level change events"""
payload = event['payload']
print(f"Stock level change detected for product {payload['productId']}")
print(f"New quantity: {payload['newQuantity']}")
# Add your business logic here
def handle_low_stock_alert(self, event):
"""Handle low stock alert events"""
payload = event['payload']
print(f"Low stock alert for product {payload['productId']}")
print(f"Current quantity: {payload['currentQuantity']}")
# Add your business logic here
def start_consuming(self):
"""Start consuming messages from the topic"""
try:
print(f"Starting consumption from topic: {self.topic}")
for message in self.consumer:
try:
# Process the message
event = message.value
print(f"Received event: {event['eventType']} for product: {event['payload']['productId']}")
# Process the event
self.process_event(event)
# Commit the offset after successful processing
self.consumer.commit()
except Exception as e:
print(f"Error processing message: {str(e)}")
# Implement your error handling logic here
# You might want to send to a DLQ (Dead Letter Queue)
except Exception as e:
print(f"Consumer error: {str(e)}")
finally:
# Clean up
self.consumer.close()
if __name__ == "__main__":
# Create and start the consumer
consumer = InventoryEventConsumer()
consumer.start_consuming()
```
================================================================================
File: channels/orders.{env}.events/index.md
Size: 2.06 kB
================================================================================
---
id: orders.{env}.events
name: Order Events Channel
version: 1.0.1
summary: |
Central event stream for all order-related events in the order processing lifecycle
owners:
- dboyne
address: orders.{env}.events
protocols:
- kafka
parameters:
env:
enum:
- dev
- sit
- prod
description: 'Environment to use'
---
### Overview
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.
<ChannelInformation />
### Publishing a message using Kafka
Here is an example of how to publish an order event using Kafka:
```python
from kafka import KafkaProducer
import json
from datetime import datetime
# Kafka configuration
bootstrap_servers = ['localhost:9092']
topic = f'orders.{env}.events'
# Create a Kafka producer
producer = KafkaProducer(
bootstrap_servers=bootstrap_servers,
value_serializer=lambda v: json.dumps(v).encode('utf-8')
)
# Example order created event
order_event = {
"eventType": "ORDER_CREATED",
"timestamp": datetime.utcnow().isoformat(),
"version": "1.0",
"payload": {
"orderId": "12345",
"customerId": "CUST-789",
"items": [
{
"productId": "PROD-456",
"quantity": 2,
"price": 29.99
}
],
"totalAmount": 59.98,
"shippingAddress": {
"street": "123 Main St",
"city": "Springfield",
"country": "US"
}
},
"metadata": {
"source": "web_checkout",
"correlationId": "abc-xyz-123"
}
}
# Send the message - using orderId as key for partitioning
producer.send(
topic,
key=order_event['payload']['orderId'].encode('utf-8'),
value=order_event
)
producer.flush()
print(f"Order event sent to topic {topic}")
================================================================================
File: channels/payment.{env}.events/index.md
Size: 2.22 kB
================================================================================
---
id: payments.{env}.events
name: Payment Events Channel
version: 1.0.0
summary: |
All events contain payment ID for traceability and ordered processing.
owners:
- dboyne
address: payments.{env}.events
protocols:
- kafka
parameters:
env:
enum:
- dev
- sit
- prod
description: 'Environment to use for payment events'
---
### Overview
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.
<ChannelInformation />
### Publishing Events Using Kafka
Here's an example of publishing a payment event:
```python
from kafka import KafkaProducer
import json
from datetime import datetime
# Kafka configuration
bootstrap_servers = ['localhost:9092']
topic = f'payments.{env}.events'
# Create Kafka producer
producer = KafkaProducer(
bootstrap_servers=bootstrap_servers,
value_serializer=lambda v: json.dumps(v).encode('utf-8')
)
# Example payment processed event
payment_event = {
"eventType": "PAYMENT_PROCESSED",
"timestamp": datetime.utcnow().isoformat(),
"version": "1.0",
"payload": {
"paymentId": "PAY-123-456",
"orderId": "ORD-789",
"amount": {
"value": 99.99,
"currency": "USD"
},
"status": "SUCCESS",
"paymentMethod": {
"type": "CREDIT_CARD",
"last4": "4242",
"expiryMonth": "12",
"expiryYear": "2025",
"network": "VISA"
},
"transactionDetails": {
"processorId": "stripe_123xyz",
"authorizationCode": "AUTH123",
"captureId": "CAP456"
}
},
"metadata": {
"correlationId": "corr-123-abc",
"merchantId": "MERCH-456",
"source": "payment_service",
"environment": "prod",
"idempotencyKey": "PAY-123-456-2024-11-11-99.99"
}
}
# Send message - using paymentId as key for partitioning
producer.send(
topic,
key=payment_event['payload']['paymentId'].encode('utf-8'),
value=payment_event
)
producer.flush()
```
================================================================================
File: components/footer.astro
Size: 190 B
================================================================================
---
import config from '@config';
---
<div class="w-full text-right">
<span class="italic text-gray-800">Event-driven architecture documentation: {config.organizationName}</span>
</div>
================================================================================
File: domains/Orders/changelog.md
Size: 101 B
================================================================================
---
createdAt: 2024-08-01
---
### Service added to domain
Added the InventoryService to the domain.
================================================================================
File: domains/Orders/index.md
Size: 2.22 kB
================================================================================
---
id: Orders
name: Orders
version: 0.0.3
owners:
- dboyne
- full-stack
services:
- id: InventoryService
version: 0.0.2
- id: NotificationService
version: 0.0.2
- id: OrdersService
version: 0.0.2
badges:
- content: New domain
backgroundColor: blue
textColor: blue
---
import Footer from '@catalog/components/footer.astro';
## Overview
<Admonition type="warning">Please ensure all services are updated to the latest version for compatibility and performance improvements.</Admonition>
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.
<Tiles >
<Tile icon="UserGroupIcon" href="/docs/teams/full-stack" title="Contact the team" description="Any questions? Feel free to contact the owners" />
<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" />
</Tiles>
## Bounded context
<NodeGraph />
### Order example (sequence diagram)
```mermaid
sequenceDiagram
participant Customer
participant OrdersService
participant InventoryService
participant NotificationService
Customer->>OrdersService: Place Order
OrdersService->>InventoryService: Check Inventory
InventoryService-->>OrdersService: Inventory Available
OrdersService->>InventoryService: Reserve Inventory
OrdersService->>NotificationService: Send Order Confirmation
NotificationService-->>Customer: Order Confirmation
OrdersService->>Customer: Order Placed Successfully
OrdersService->>InventoryService: Update Inventory
```
## Flows
### Cancel Subscription flow
Documented flow when a user cancels their subscription.
<Flow id="CancelSubscription" version="latest" includeKey={false} />
### Payment processing flow
Documented flow when a user makes a payment within the order domain
<Flow id="PaymentFlow" version="latest" includeKey={false} />
<Footer />
================================================================================
File: domains/Orders/services/InventoryService/changelog.md
Size: 207 B
================================================================================
---
createdAt: 2024-08-01
---
### Service receives additional events
Service now receives [OrderAmended](/docs/events/OrderAmended/0.0.1) and [UpdateInventory](/docs/commands/UpdateInventory/0.0.3) events.
================================================================================
File: domains/Orders/services/InventoryService/commands/AddInventory/index.md
Size: 993 B
================================================================================
---
id: AddInventory
name: Add inventory
version: 0.0.3
summary: |
Command that will add item to a given inventory id
owners:
- dboyne
- msmith
- asmith
- full-stack
- mobile-devs
badges:
- content: Recently updated!
backgroundColor: green
textColor: green
channels:
- id: inventory.{env}.events
parameters:
env: staging
schemaPath: 'schema.json'
---
import Footer from '@catalog/components/footer.astro';
## Overview
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.
## Architecture diagram
<NodeGraph/>
## Payload example
```json title="Payload example"
{
"productId": "789e1234-b56c-78d9-e012-3456789fghij",
"quantity": 50,
"warehouseId": "456e7891-c23d-45f6-b78a-123456789abc",
"timestamp": "2024-07-04T14:48:00Z"
}
```
## Schema
<Schema file="schema.json"/>
<Footer />
================================================================================
File: domains/Orders/services/InventoryService/commands/AddInventory/schema.json
Size: 912 B
================================================================================
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AddInventoryCommand",
"type": "object",
"properties": {
"productId": {
"type": "string",
"format": "uuid",
"description": "The unique identifier of the product being added to the inventory."
},
"quantity": {
"type": "integer",
"description": "The quantity of the product being added to the inventory."
},
"warehouseId": {
"type": "string",
"format": "uuid",
"description": "The unique identifier of the warehouse where the inventory is being added."
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "The date and time when the inventory was added."
}
},
"required": ["productId", "quantity", "warehouseId", "timestamp"],
"additionalProperties": false
}
================================================================================
File: domains/Orders/services/InventoryService/commands/PlaceOrder/index.md
Size: 740 B
================================================================================
---
id: PlaceOrder
name: Place Order
version: 0.0.1
summary: |
Command that will place an order
owners:
- dboyne
- msmith
- asmith
- full-stack
- mobile-devs
badges:
- content: Recently updated!
backgroundColor: green
textColor: green
schemaPath: 'schema.json'
---
import Footer from '@catalog/components/footer.astro';
## Overview
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.
## Architecture diagram
<NodeGraph/>
## Schema
<SchemaViewer file="schema.json"/>
<Footer />
================================================================================
File: domains/Orders/services/InventoryService/commands/PlaceOrder/schema.json
Size: 3.54 kB
================================================================================
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Order",
"description": "A schema representing an order placed by a customer",
"type": "object",
"properties": {
"orderId": {
"description": "Unique identifier for the order",
"type": "string"
},
"customer": {
"description": "Information about the customer placing the order",
"type": "object",
"properties": {
"customerId": {
"description": "Unique identifier for the customer",
"type": "string"
},
"name": {
"description": "Name of the customer",
"type": "string"
},
"email": {
"description": "Email address of the customer",
"type": "string",
"format": "email"
},
"phone": {
"description": "Phone number of the customer",
"type": "string",
"pattern": "^[+]?[0-9]{10,15}$"
}
},
"required": ["customerId", "name", "email"]
},
"items": {
"description": "List of items in the order",
"type": "array",
"items": {
"type": "object",
"properties": {
"itemId": {
"description": "Unique identifier for the item",
"type": "string"
},
"name": {
"description": "Name of the item",
"type": "string"
},
"quantity": {
"description": "Quantity of the item ordered",
"type": "integer",
"minimum": 1
},
"price": {
"description": "Price per unit of the item",
"type": "number",
"minimum": 0
}
},
"required": ["itemId", "name", "quantity", "price"]
}
},
"shippingAddress": {
"description": "Address where the order will be shipped",
"type": "object",
"properties": {
"street": {
"description": "Street address",
"type": "string"
},
"city": {
"description": "City",
"type": "string"
},
"state": {
"description": "State or province",
"type": "string"
},
"zip": {
"description": "ZIP or postal code",
"type": "string"
},
"country": {
"description": "Country",
"type": "string"
}
},
"required": ["street", "city", "state", "zip", "country"]
},
"payment": {
"description": "Payment information for the order",
"type": "object",
"properties": {
"paymentMethod": {
"description": "Payment method used",
"type": "string",
"enum": ["Credit Card", "PayPal", "Bank Transfer"]
},
"transactionId": {
"description": "Transaction ID for the payment",
"type": "string"
},
"amount": {
"description": "Total amount paid",
"type": "number",
"minimum": 0
}
},
"required": ["paymentMethod", "transactionId", "amount"]
},
"orderDate": {
"description": "Date when the order was placed",
"type": "string",
"format": "date-time"
},
"status": {
"description": "Current status of the order",
"type": "string",
"enum": ["Pending", "Processing", "Shipped", "Delivered", "Cancelled"]
}
},
"required": ["orderId", "customer", "items", "shippingAddress", "payment", "orderDate", "status"]
}
================================================================================
File: domains/Orders/services/InventoryService/commands/UpdateInventory/index.md
Size: 1.18 kB
================================================================================
---
id: UpdateInventory
name: Update inventory
version: 0.0.3
summary: |
Command that will update a given inventory item
owners:
- dboyne
- msmith
- asmith
- full-stack
- mobile-devs
badges:
- content: Recently updated!
backgroundColor: green
textColor: green
channels:
- id: inventory.{env}.events
parameters:
env: staging
schemaPath: "schema.json"
---
import Footer from '@catalog/components/footer.astro';
## Overview
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.
## Architecture diagram
<NodeGraph />
<SchemaViewer file="schema.json" title="JSON Schema" maxHeight="500" />
## Payload example
```json title="Payload example"
{
"productId": "789e1234-b56c-78d9-e012-3456789fghij",
"quantityChange": -10,
"warehouseId": "456e7891-c23d-45f6-b78a-123456789abc",
"timestamp": "2024-07-04T14:48:00Z"
}
```
## Schema (JSON schema)
<Schema file="schema.json"/>
<Footer />
================================================================================
File: domains/Orders/services/InventoryService/commands/UpdateInventory/schema.json
Size: 1.02 kB
================================================================================
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "UpdateInventoryCommand",
"type": "object",
"properties": {
"productId": {
"type": "string",
"format": "uuid",
"description": "The unique identifier of the product whose inventory is being updated."
},
"quantityChange": {
"type": "integer",
"description": "The change in quantity of the product in the inventory. Positive values indicate an increase, while negative values indicate a decrease."
},
"warehouseId": {
"type": "string",
"format": "uuid",
"description": "The unique identifier of the warehouse where the inventory is being updated."
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "The date and time when the inventory update occurred."
}
},
"required": ["productId", "quantityChange", "warehouseId", "timestamp"],
"additionalProperties": false
}
================================================================================
File: domains/Orders/services/InventoryService/events/InventoryAdjusted/changelog.md
Size: 1.37 kB
================================================================================
---
createdAt: 2024-08-01
badges:
- content: ⭐️ JSON Schema
backgroundColor: purple
textColor: purple
---
### Added support for JSON Schema
InventoryAdjusted uses Avro but now also supports JSON Draft 7.
```json title="Employee JSON Draft"
// labeled-line-markers.jsx
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "Employee",
"properties": {
"Name": {
"type": "string"
},
"Age": {
"type": "integer"
},
"Town": {
"type": "string"
}
},
"required": ["Name", "Age", "Town"]
}
```
Using it with our Kafka Cluster
## 1. Create a new topic
```sh
# Create a topic named 'employee_topic'
kafka-topics.sh --create --topic employee_topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
```
## Step 2: Prepare the JSON Message
Create a JSON file named `employee.json` with the following content:
```json
{
"Name": "John Doe",
"Age": 30,
"Town": "Springfield"
}
```
## Step 3: Produce the Message to Kafka Topic
Use the Kafka producer CLI to send the JSON message:
```sh
cat employee.json | kafka-console-producer.sh --topic employee_topic --bootstrap-server localhost:9092
```
## Step 4: Verify the Message (Optional)
```sh
kafka-console-consumer.sh --topic employee_topic --from-beginning --bootstrap-server localhost:9092
```