@eventcatalog/create-eventcatalog 3.0.10 → 3.0.11
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/default/domains/Orders/entities/CartItem/index.mdx +121 -0
- package/templates/default/domains/Orders/entities/Customer/index.mdx +57 -0
- package/templates/default/domains/Orders/entities/Order/index.mdx +96 -0
- package/templates/default/domains/Orders/entities/OrderItem/index.mdx +59 -0
- package/templates/default/domains/Orders/entities/ShoppingCart/index.mdx +148 -0
- package/templates/default/domains/Orders/index.mdx +13 -0
- package/templates/default/domains/Payment/entities/Address/index.mdx +162 -0
- package/templates/default/domains/Payment/entities/Invoice/index.mdx +89 -0
- package/templates/default/domains/Payment/entities/Payment/index.mdx +137 -0
- package/templates/default/domains/Payment/entities/PaymentMethod/index.mdx +77 -0
- package/templates/default/domains/Payment/entities/Transaction/index.mdx +77 -0
- package/templates/default/domains/Payment/index.mdx +17 -1
- package/templates/default/domains/Payment/services/FraudDetectionService/events/FraudCheckCompleted/index.mdx +48 -0
- package/templates/default/domains/Payment/services/FraudDetectionService/events/FraudCheckCompleted/schema.json +44 -0
- package/templates/default/domains/Payment/services/FraudDetectionService/index.mdx +59 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/commands/ProcessPayment/index.mdx +72 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/commands/ProcessPayment/schema.json +58 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/events/PaymentFailed/index.mdx +60 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/events/PaymentFailed/schema.json +68 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/index.mdx +78 -0
- package/templates/default/domains/ProductCatalog/entities/Category/index.mdx +124 -0
- package/templates/default/domains/ProductCatalog/entities/Inventory/index.mdx +116 -0
- package/templates/default/domains/ProductCatalog/entities/Product/index.mdx +115 -0
- package/templates/default/domains/ProductCatalog/entities/Review/index.mdx +154 -0
- package/templates/default/domains/ProductCatalog/index.mdx +74 -0
- package/templates/default/domains/Subscriptions/entities/BillingProfile/index.mdx +68 -0
- package/templates/default/domains/Subscriptions/entities/SubscriptionPeriod/index.mdx +73 -0
- package/templates/default/domains/Subscriptions/index.mdx +13 -2
- package/templates/default/domains/Subscriptions/services/BillingService/events/SubscriptionPaymentDue/index.mdx +60 -0
- package/templates/default/domains/Subscriptions/services/BillingService/events/SubscriptionPaymentDue/schema.json +54 -0
- package/templates/default/domains/Subscriptions/services/BillingService/index.mdx +86 -0
- package/templates/default/domains/Subscriptions/services/PlanManagementService/index.mdx +93 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Review
|
|
3
|
+
name: Review
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: reviewId
|
|
6
|
+
summary: Represents customer reviews and ratings for products.
|
|
7
|
+
properties:
|
|
8
|
+
- name: reviewId
|
|
9
|
+
type: UUID
|
|
10
|
+
required: true
|
|
11
|
+
description: Unique identifier for the review
|
|
12
|
+
- name: productId
|
|
13
|
+
type: UUID
|
|
14
|
+
required: true
|
|
15
|
+
description: Product being reviewed
|
|
16
|
+
references: Product
|
|
17
|
+
referencesIdentifier: productId
|
|
18
|
+
relationType: hasOne
|
|
19
|
+
- name: customerId
|
|
20
|
+
type: UUID
|
|
21
|
+
required: true
|
|
22
|
+
description: Customer who wrote the review
|
|
23
|
+
references: Customer
|
|
24
|
+
referencesIdentifier: customerId
|
|
25
|
+
relationType: hasOne
|
|
26
|
+
- name: orderId
|
|
27
|
+
type: UUID
|
|
28
|
+
required: false
|
|
29
|
+
description: Order associated with this review (for verified purchases)
|
|
30
|
+
references: Order
|
|
31
|
+
referencesIdentifier: orderId
|
|
32
|
+
relationType: hasOne
|
|
33
|
+
- name: rating
|
|
34
|
+
type: integer
|
|
35
|
+
required: true
|
|
36
|
+
description: Rating given by customer (1-5 stars)
|
|
37
|
+
minimum: 1
|
|
38
|
+
maximum: 5
|
|
39
|
+
- name: title
|
|
40
|
+
type: string
|
|
41
|
+
required: false
|
|
42
|
+
description: Review title or headline
|
|
43
|
+
- name: content
|
|
44
|
+
type: string
|
|
45
|
+
required: true
|
|
46
|
+
description: Review content and comments
|
|
47
|
+
- name: isVerifiedPurchase
|
|
48
|
+
type: boolean
|
|
49
|
+
required: true
|
|
50
|
+
description: Whether this review is from a verified purchase
|
|
51
|
+
- name: isRecommended
|
|
52
|
+
type: boolean
|
|
53
|
+
required: false
|
|
54
|
+
description: Whether customer recommends this product
|
|
55
|
+
- name: helpfulVotes
|
|
56
|
+
type: integer
|
|
57
|
+
required: true
|
|
58
|
+
description: Number of helpful votes received
|
|
59
|
+
- name: totalVotes
|
|
60
|
+
type: integer
|
|
61
|
+
required: true
|
|
62
|
+
description: Total number of votes received
|
|
63
|
+
- name: status
|
|
64
|
+
type: string
|
|
65
|
+
required: true
|
|
66
|
+
description: Current review status
|
|
67
|
+
enum: ['pending', 'approved', 'rejected', 'flagged']
|
|
68
|
+
- name: moderationNotes
|
|
69
|
+
type: string
|
|
70
|
+
required: false
|
|
71
|
+
description: Internal moderation notes
|
|
72
|
+
- name: images
|
|
73
|
+
type: array
|
|
74
|
+
items:
|
|
75
|
+
type: string
|
|
76
|
+
required: false
|
|
77
|
+
description: URLs of images uploaded with the review
|
|
78
|
+
- name: pros
|
|
79
|
+
type: array
|
|
80
|
+
items:
|
|
81
|
+
type: string
|
|
82
|
+
required: false
|
|
83
|
+
description: List of positive aspects mentioned
|
|
84
|
+
- name: cons
|
|
85
|
+
type: array
|
|
86
|
+
items:
|
|
87
|
+
type: string
|
|
88
|
+
required: false
|
|
89
|
+
description: List of negative aspects mentioned
|
|
90
|
+
- name: merchantResponse
|
|
91
|
+
type: object
|
|
92
|
+
required: false
|
|
93
|
+
description: Response from merchant to this review
|
|
94
|
+
properties:
|
|
95
|
+
- name: content
|
|
96
|
+
type: string
|
|
97
|
+
description: Merchant response content
|
|
98
|
+
- name: respondedAt
|
|
99
|
+
type: DateTime
|
|
100
|
+
description: When merchant responded
|
|
101
|
+
- name: respondedBy
|
|
102
|
+
type: string
|
|
103
|
+
description: Who responded for the merchant
|
|
104
|
+
- name: createdAt
|
|
105
|
+
type: DateTime
|
|
106
|
+
required: true
|
|
107
|
+
description: Date and time when the review was created
|
|
108
|
+
- name: updatedAt
|
|
109
|
+
type: DateTime
|
|
110
|
+
required: false
|
|
111
|
+
description: Date and time when the review was last updated
|
|
112
|
+
- name: moderatedAt
|
|
113
|
+
type: DateTime
|
|
114
|
+
required: false
|
|
115
|
+
description: Date and time when the review was moderated
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Overview
|
|
119
|
+
|
|
120
|
+
The Review entity captures customer feedback and ratings for products. It supports verified purchase validation, content moderation, community voting, and merchant responses to build trust and provide valuable product insights.
|
|
121
|
+
|
|
122
|
+
### Entity Properties
|
|
123
|
+
<EntityPropertiesTable />
|
|
124
|
+
|
|
125
|
+
## Relationships
|
|
126
|
+
|
|
127
|
+
* **Product:** Each review belongs to one `Product` (identified by `productId`).
|
|
128
|
+
* **Customer:** Each review is written by one `Customer` (identified by `customerId`).
|
|
129
|
+
* **Order:** Each review can be linked to one `Order` for purchase verification (identified by `orderId`).
|
|
130
|
+
|
|
131
|
+
## Review Lifecycle
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
submitted → pending → approved → published
|
|
135
|
+
↓ ↓
|
|
136
|
+
rejected flagged
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Examples
|
|
140
|
+
|
|
141
|
+
* **Review #1:** 5-star review for iPhone 15 Pro, verified purchase, "Excellent camera quality!"
|
|
142
|
+
* **Review #2:** 3-star review for Running Shoes, helpful votes: 15/20, includes photos
|
|
143
|
+
* **Review #3:** 1-star review flagged for inappropriate content, pending moderation
|
|
144
|
+
|
|
145
|
+
## Business Rules
|
|
146
|
+
|
|
147
|
+
* Reviews can only be submitted by customers who purchased the product
|
|
148
|
+
* Rating must be between 1-5 stars
|
|
149
|
+
* Verified purchase reviews are given higher weight in calculations
|
|
150
|
+
* Inappropriate content is flagged and requires moderation
|
|
151
|
+
* Customers can only review the same product once per purchase
|
|
152
|
+
* Helpful votes help surface most valuable reviews
|
|
153
|
+
* Merchant responses are limited to one per review
|
|
154
|
+
* Reviews older than 2 years may have reduced weight in calculations
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ProductCatalog
|
|
3
|
+
name: Product Catalog
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
summary: Manages product information, categories, inventory, and customer reviews in the e-commerce system.
|
|
6
|
+
owners:
|
|
7
|
+
- dboyne
|
|
8
|
+
entities:
|
|
9
|
+
- id: Product
|
|
10
|
+
- id: Category
|
|
11
|
+
- id: Inventory
|
|
12
|
+
- id: Review
|
|
13
|
+
services:
|
|
14
|
+
- id: ProductService
|
|
15
|
+
- id: CategoryService
|
|
16
|
+
- id: InventoryService
|
|
17
|
+
- id: ReviewService
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
The Product Catalog subdomain is responsible for managing all product-related information in the e-commerce system. This includes product details, hierarchical categorization, inventory tracking, and customer reviews.
|
|
23
|
+
|
|
24
|
+
### Architecture for the Product Catalog domain
|
|
25
|
+
|
|
26
|
+
<NodeGraph />
|
|
27
|
+
|
|
28
|
+
### Entity Map
|
|
29
|
+
|
|
30
|
+
A visualization of the entities in the Product Catalog domain. Here you can see the relationships between the entities and how they are used in the domain.
|
|
31
|
+
|
|
32
|
+
<EntityMap id="ProductCatalog" />
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Core Responsibilities
|
|
37
|
+
|
|
38
|
+
### Product Management
|
|
39
|
+
- Maintain product information including pricing, descriptions, and specifications
|
|
40
|
+
- Support product variants (size, color, style)
|
|
41
|
+
- Handle product lifecycle (active, discontinued, draft)
|
|
42
|
+
- Manage product relationships and cross-selling
|
|
43
|
+
|
|
44
|
+
### Category Management
|
|
45
|
+
- Organize products into hierarchical categories
|
|
46
|
+
- Support multi-level category structures
|
|
47
|
+
- Maintain category metadata and SEO information
|
|
48
|
+
- Handle category navigation and filtering
|
|
49
|
+
|
|
50
|
+
### Inventory Management
|
|
51
|
+
- Track stock levels and availability
|
|
52
|
+
- Manage reorder points and stock alerts
|
|
53
|
+
- Handle inventory reservations and allocations
|
|
54
|
+
- Support warehouse and location management
|
|
55
|
+
|
|
56
|
+
### Review Management
|
|
57
|
+
- Collect and manage customer product reviews
|
|
58
|
+
- Calculate review metrics and ratings
|
|
59
|
+
- Moderate review content
|
|
60
|
+
- Support review helpfulness and responses
|
|
61
|
+
|
|
62
|
+
## Key Entities
|
|
63
|
+
|
|
64
|
+
- **Product**: Central aggregate containing all product information
|
|
65
|
+
- **Category**: Hierarchical product categorization system
|
|
66
|
+
- **Inventory**: Stock tracking and availability management
|
|
67
|
+
- **Review**: Customer feedback and rating system
|
|
68
|
+
|
|
69
|
+
## Business Rules
|
|
70
|
+
|
|
71
|
+
- Products must belong to an active category
|
|
72
|
+
- Inventory levels affect product availability
|
|
73
|
+
- Reviews require verified purchases
|
|
74
|
+
- Category hierarchies have maximum depth limits
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: BillingProfile
|
|
3
|
+
name: BillingProfile
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: billingProfileId
|
|
6
|
+
summary: Stores billing-related contact information and preferences for a customer, often used for invoices and communication.
|
|
7
|
+
|
|
8
|
+
properties:
|
|
9
|
+
- name: billingProfileId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for the billing profile.
|
|
13
|
+
- name: customerId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
description: Identifier of the customer this billing profile belongs to.
|
|
17
|
+
references: Customer
|
|
18
|
+
referencesIdentifier: customerId
|
|
19
|
+
relationType: hasOne
|
|
20
|
+
- name: billingEmail
|
|
21
|
+
type: string
|
|
22
|
+
required: false # May default to customer's primary email
|
|
23
|
+
description: Specific email address for sending invoices and billing notifications
|
|
24
|
+
- name: companyName # Optional, for B2B
|
|
25
|
+
type: string
|
|
26
|
+
required: false
|
|
27
|
+
description: Company name for billing purposes.
|
|
28
|
+
- name: taxId # Optional, for B2B or specific regions
|
|
29
|
+
type: string
|
|
30
|
+
required: false
|
|
31
|
+
description: Tax identification number (e.g., VAT ID, EIN).
|
|
32
|
+
- name: billingAddressId
|
|
33
|
+
type: UUID
|
|
34
|
+
required: true
|
|
35
|
+
description: Identifier for the primary billing address associated with this profile.
|
|
36
|
+
- name: preferredPaymentMethodId # Optional default for invoices/subscriptions
|
|
37
|
+
type: UUID
|
|
38
|
+
required: false
|
|
39
|
+
description: Customer's preferred payment method for charges related to this profile.
|
|
40
|
+
- name: createdAt
|
|
41
|
+
type: DateTime
|
|
42
|
+
required: true
|
|
43
|
+
description: Timestamp when the billing profile was created.
|
|
44
|
+
- name: updatedAt
|
|
45
|
+
type: DateTime
|
|
46
|
+
required: true
|
|
47
|
+
description: Timestamp when the billing profile was last updated.
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Overview
|
|
51
|
+
|
|
52
|
+
The BillingProfile entity consolidates billing-specific details for a customer, such as the billing address, contact email for invoices, tax information, and potentially preferred payment methods. This might be distinct from the customer's general contact information or shipping addresses.
|
|
53
|
+
|
|
54
|
+
### Entity Properties
|
|
55
|
+
<EntityPropertiesTable />
|
|
56
|
+
|
|
57
|
+
## Relationships
|
|
58
|
+
|
|
59
|
+
* **Customer:** A billing profile belongs to one `Customer`. A customer might potentially have multiple profiles in complex scenarios, but often just one.
|
|
60
|
+
* **Address:** Linked to a primary billing `Address`.
|
|
61
|
+
* **PaymentMethod:** May specify a preferred `PaymentMethod`.
|
|
62
|
+
* **Invoice:** Invoices are typically generated using information from the BillingProfile.
|
|
63
|
+
* **Subscription:** Subscriptions may use the associated customer's BillingProfile for charging.
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
* Jane Doe's personal billing profile with her home address and primary email.
|
|
68
|
+
* Acme Corp's billing profile with their HQ address, VAT ID, and accounts payable email address.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: SubscriptionPeriod
|
|
3
|
+
name: SubscriptionPeriod
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: subscriptionPeriodId
|
|
6
|
+
summary: Represents a single billing cycle or interval within a subscription's lifetime.
|
|
7
|
+
|
|
8
|
+
properties:
|
|
9
|
+
- name: subscriptionPeriodId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for this specific subscription period.
|
|
13
|
+
- name: subscriptionId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
description: Identifier of the parent Subscription this period belongs to.
|
|
17
|
+
- name: planId # Denormalized for easier lookup?
|
|
18
|
+
type: UUID
|
|
19
|
+
required: true
|
|
20
|
+
description: Identifier of the Plan active during this period
|
|
21
|
+
- name: startDate
|
|
22
|
+
type: Date
|
|
23
|
+
required: true
|
|
24
|
+
description: The start date of this billing period.
|
|
25
|
+
- name: endDate
|
|
26
|
+
type: Date
|
|
27
|
+
required: true
|
|
28
|
+
description: The end date of this billing period.
|
|
29
|
+
- name: invoiceId # Optional, links to the invoice generated for this period
|
|
30
|
+
type: UUID
|
|
31
|
+
required: false
|
|
32
|
+
description: Identifier of the invoice created for this period's charge.
|
|
33
|
+
- name: paymentId # Optional, links to the payment made for this period's invoice
|
|
34
|
+
type: UUID
|
|
35
|
+
required: false
|
|
36
|
+
description: Identifier of the payment that settled the invoice for this period.
|
|
37
|
+
- name: status
|
|
38
|
+
type: string # (e.g., Active, Billed, Paid, Unpaid, PastDue)
|
|
39
|
+
required: true
|
|
40
|
+
description: Status specific to this period (reflects invoicing/payment state).
|
|
41
|
+
- name: amountBilled
|
|
42
|
+
type: decimal
|
|
43
|
+
required: false # May only be set once invoiced
|
|
44
|
+
description: The actual amount billed for this period (could differ from plan due to promotions, usage, etc.).
|
|
45
|
+
- name: currency
|
|
46
|
+
type: string # ISO 4217 code
|
|
47
|
+
required: false
|
|
48
|
+
description: Currency of the billed amount.
|
|
49
|
+
- name: createdAt
|
|
50
|
+
type: DateTime
|
|
51
|
+
required: true
|
|
52
|
+
description: Timestamp when this period record was created (often at the start of the period).
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Overview
|
|
56
|
+
|
|
57
|
+
The SubscriptionPeriod entity tracks the state and details of a specific billing cycle within a `Subscription`. It links the subscription to the relevant invoice and payment for that interval and records the exact dates and amount billed.
|
|
58
|
+
|
|
59
|
+
### Entity Properties
|
|
60
|
+
<EntityPropertiesTable />
|
|
61
|
+
|
|
62
|
+
## Relationships
|
|
63
|
+
|
|
64
|
+
* **Subscription:** A subscription period belongs to one `Subscription`.
|
|
65
|
+
* **Plan:** Reflects the `Plan` active during this period.
|
|
66
|
+
* **Invoice:** May be associated with one `Invoice` generated for this period.
|
|
67
|
+
* **Payment:** May be associated with one `Payment` that settled the period's invoice.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
* Period for Jane Doe's 'Pro Plan' from 2024-05-01 to 2024-05-31, invoiced via #INV-00123, status Paid.
|
|
72
|
+
* Period for Acme Corp's 'Enterprise Plan' from 2024-04-15 to 2024-05-14, status Billed, awaiting payment.
|
|
73
|
+
* The first period (trial) for a new subscription from 2024-05-20 to 2024-06-19, status Active, amountBilled $0.00.
|
|
@@ -7,8 +7,13 @@ summary: |
|
|
|
7
7
|
owners:
|
|
8
8
|
- dboyne
|
|
9
9
|
services:
|
|
10
|
-
- id:
|
|
10
|
+
- id: BillingService
|
|
11
11
|
version: 0.0.1
|
|
12
|
+
- id: PlanManagementService
|
|
13
|
+
version: 0.0.1
|
|
14
|
+
entities:
|
|
15
|
+
- id: BillingProfile
|
|
16
|
+
- id: SubscriptionPeriod
|
|
12
17
|
badges:
|
|
13
18
|
- content: Payment Domain
|
|
14
19
|
backgroundColor: blue
|
|
@@ -19,6 +24,12 @@ badges:
|
|
|
19
24
|
|
|
20
25
|
The Payment Domain encompasses all services and components related to handling financial transactions within the system. It is responsible for managing payments, transactions, billing, and financial records. The domain ensures secure, reliable, and efficient processing of all payment-related activities
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
### Architecture for the Subscription domain
|
|
23
28
|
|
|
24
29
|
<NodeGraph />
|
|
30
|
+
|
|
31
|
+
### Entity Map
|
|
32
|
+
|
|
33
|
+
A visualization of the entities in the Subscription domain. Here you can see the relationships between the entities and how they are used in the domain.
|
|
34
|
+
|
|
35
|
+
<EntityMap id="Subscription" />
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: SubscriptionPaymentDue
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Subscription Payment Due
|
|
5
|
+
summary: Emitted when a subscription payment is due for collection
|
|
6
|
+
tags:
|
|
7
|
+
- billing
|
|
8
|
+
- payment
|
|
9
|
+
- cross-domain
|
|
10
|
+
badges:
|
|
11
|
+
- content: Cross-Domain
|
|
12
|
+
backgroundColor: purple
|
|
13
|
+
textColor: white
|
|
14
|
+
schemaPath: schema.json
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
import Footer from '@catalog/components/footer.astro'
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
The `SubscriptionPaymentDue` event is emitted by the Billing Service when a subscription's billing cycle is due for payment. This event triggers the payment collection process in the Payment domain.
|
|
22
|
+
|
|
23
|
+
## Cross-Domain Communication
|
|
24
|
+
|
|
25
|
+
This event facilitates communication between:
|
|
26
|
+
- **Source**: Subscriptions Domain (BillingService)
|
|
27
|
+
- **Target**: Payment Domain (PaymentService, FraudDetectionService)
|
|
28
|
+
|
|
29
|
+
## Schema
|
|
30
|
+
|
|
31
|
+
<SchemaViewer title="SubscriptionPaymentDue Schema" schemaPath={frontmatter.schemaPath} />
|
|
32
|
+
|
|
33
|
+
## Event Flow
|
|
34
|
+
|
|
35
|
+
1. BillingService calculates when payment is due
|
|
36
|
+
2. Emits `SubscriptionPaymentDue` event
|
|
37
|
+
3. PaymentService receives and initiates payment
|
|
38
|
+
4. FraudDetectionService performs risk assessment
|
|
39
|
+
5. Payment is processed through PaymentGatewayService
|
|
40
|
+
|
|
41
|
+
## Example Payload
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"subscriptionId": "sub_ABC123",
|
|
46
|
+
"customerId": "cust_XYZ789",
|
|
47
|
+
"invoiceId": "inv_123456",
|
|
48
|
+
"amount": 49.99,
|
|
49
|
+
"currency": "USD",
|
|
50
|
+
"dueDate": "2024-02-01T00:00:00Z",
|
|
51
|
+
"billingPeriod": {
|
|
52
|
+
"start": "2024-02-01",
|
|
53
|
+
"end": "2024-02-29"
|
|
54
|
+
},
|
|
55
|
+
"planId": "pro-monthly",
|
|
56
|
+
"retryAttempt": 0
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
<Footer />
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"subscriptionId": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "Unique identifier for the subscription"
|
|
8
|
+
},
|
|
9
|
+
"customerId": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Unique identifier for the customer"
|
|
12
|
+
},
|
|
13
|
+
"invoiceId": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Unique identifier for the invoice"
|
|
16
|
+
},
|
|
17
|
+
"amount": {
|
|
18
|
+
"type": "number",
|
|
19
|
+
"description": "Amount due for payment"
|
|
20
|
+
},
|
|
21
|
+
"currency": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Currency code (ISO 4217)"
|
|
24
|
+
},
|
|
25
|
+
"dueDate": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"format": "date-time",
|
|
28
|
+
"description": "When the payment is due"
|
|
29
|
+
},
|
|
30
|
+
"billingPeriod": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"start": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"format": "date"
|
|
36
|
+
},
|
|
37
|
+
"end": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"format": "date"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"required": ["start", "end"]
|
|
43
|
+
},
|
|
44
|
+
"planId": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Subscription plan identifier"
|
|
47
|
+
},
|
|
48
|
+
"retryAttempt": {
|
|
49
|
+
"type": "integer",
|
|
50
|
+
"description": "Number of retry attempts for failed payments"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": ["subscriptionId", "customerId", "invoiceId", "amount", "currency", "dueDate"]
|
|
54
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: BillingService
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Billing Service
|
|
5
|
+
summary: Manages billing cycles, invoice generation, and payment scheduling for subscriptions
|
|
6
|
+
tags:
|
|
7
|
+
- billing
|
|
8
|
+
- subscriptions
|
|
9
|
+
- invoicing
|
|
10
|
+
repository:
|
|
11
|
+
url: https://github.com/eventcatalog/billing-service
|
|
12
|
+
receives:
|
|
13
|
+
- id: SubscriptionCreated
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
- id: SubscriptionUpdated
|
|
16
|
+
version: 0.0.1
|
|
17
|
+
- id: PaymentProcessed
|
|
18
|
+
version: 0.0.1
|
|
19
|
+
- id: PaymentFailed
|
|
20
|
+
version: 0.0.1
|
|
21
|
+
sends:
|
|
22
|
+
- id: InvoiceGenerated
|
|
23
|
+
version: 0.0.1
|
|
24
|
+
- id: SubscriptionPaymentDue
|
|
25
|
+
version: 0.0.1
|
|
26
|
+
- id: BillingCycleCompleted
|
|
27
|
+
version: 0.0.1
|
|
28
|
+
- id: ProcessPayment
|
|
29
|
+
version: 0.0.1
|
|
30
|
+
owners:
|
|
31
|
+
- billingTeam
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
import Footer from '@catalog/components/footer.astro'
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
The Billing Service is responsible for managing all billing-related operations for subscriptions. It calculates billing cycles, generates invoices, and coordinates with payment services to ensure timely payment collection.
|
|
39
|
+
|
|
40
|
+
## Key Features
|
|
41
|
+
|
|
42
|
+
- **Billing Cycle Management**: Handles daily, weekly, monthly, quarterly, and annual billing cycles
|
|
43
|
+
- **Invoice Generation**: Creates detailed invoices with line items and tax calculations
|
|
44
|
+
- **Payment Scheduling**: Schedules recurring payments based on billing cycles
|
|
45
|
+
- **Proration**: Calculates prorated charges for mid-cycle changes
|
|
46
|
+
- **Dunning Management**: Handles failed payment retry logic
|
|
47
|
+
|
|
48
|
+
## API Endpoints
|
|
49
|
+
|
|
50
|
+
### REST API
|
|
51
|
+
- `GET /api/billing/invoice/{subscriptionId}` - Get current invoice
|
|
52
|
+
- `GET /api/billing/history/{subscriptionId}` - Get billing history
|
|
53
|
+
- `POST /api/billing/preview` - Preview upcoming charges
|
|
54
|
+
- `PUT /api/billing/retry/{invoiceId}` - Retry failed payment
|
|
55
|
+
|
|
56
|
+
## Billing Cycle States
|
|
57
|
+
|
|
58
|
+
```mermaid
|
|
59
|
+
stateDiagram-v2
|
|
60
|
+
[*] --> Scheduled
|
|
61
|
+
Scheduled --> Processing
|
|
62
|
+
Processing --> Paid
|
|
63
|
+
Processing --> Failed
|
|
64
|
+
Failed --> Retrying
|
|
65
|
+
Retrying --> Paid
|
|
66
|
+
Retrying --> Suspended
|
|
67
|
+
Paid --> [*]
|
|
68
|
+
Suspended --> [*]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
billing_service:
|
|
75
|
+
cycles:
|
|
76
|
+
- daily
|
|
77
|
+
- weekly
|
|
78
|
+
- monthly
|
|
79
|
+
- quarterly
|
|
80
|
+
- annual
|
|
81
|
+
retry_attempts: 3
|
|
82
|
+
retry_interval_days: [1, 3, 7]
|
|
83
|
+
invoice_generation_lead_days: 7
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<Footer />
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PlanManagementService
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Plan Management Service
|
|
5
|
+
summary: Manages subscription plans, features, pricing tiers, and plan migrations
|
|
6
|
+
tags:
|
|
7
|
+
- plans
|
|
8
|
+
- pricing
|
|
9
|
+
- subscriptions
|
|
10
|
+
repository:
|
|
11
|
+
url: https://github.com/eventcatalog/plan-management-service
|
|
12
|
+
receives:
|
|
13
|
+
- id: CreatePlan
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
- id: UpdatePlan
|
|
16
|
+
version: 0.0.1
|
|
17
|
+
- id: MigratePlan
|
|
18
|
+
version: 0.0.1
|
|
19
|
+
sends:
|
|
20
|
+
- id: PlanCreated
|
|
21
|
+
version: 0.0.1
|
|
22
|
+
- id: PlanUpdated
|
|
23
|
+
version: 0.0.1
|
|
24
|
+
- id: PlanMigrationCompleted
|
|
25
|
+
version: 0.0.1
|
|
26
|
+
- id: FeatureAccessChanged
|
|
27
|
+
version: 0.0.1
|
|
28
|
+
owners:
|
|
29
|
+
- productTeam
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
import Footer from '@catalog/components/footer.astro'
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
The Plan Management Service handles the definition and management of subscription plans, including pricing, features, and plan migrations. It serves as the source of truth for what features and limits apply to each subscription tier.
|
|
37
|
+
|
|
38
|
+
## Key Features
|
|
39
|
+
|
|
40
|
+
- **Plan Definition**: Create and manage subscription plans with different tiers
|
|
41
|
+
- **Feature Flags**: Control feature access based on subscription plans
|
|
42
|
+
- **Usage Limits**: Define and enforce usage limits per plan
|
|
43
|
+
- **Plan Migration**: Handle upgrades and downgrades between plans
|
|
44
|
+
- **Pricing Management**: Manage pricing, discounts, and promotional offers
|
|
45
|
+
|
|
46
|
+
## Supported Plan Types
|
|
47
|
+
|
|
48
|
+
### Basic Plan
|
|
49
|
+
- Essential features
|
|
50
|
+
- Limited usage quotas
|
|
51
|
+
- Email support
|
|
52
|
+
|
|
53
|
+
### Professional Plan
|
|
54
|
+
- All Basic features
|
|
55
|
+
- Higher usage quotas
|
|
56
|
+
- Priority support
|
|
57
|
+
- Advanced analytics
|
|
58
|
+
|
|
59
|
+
### Enterprise Plan
|
|
60
|
+
- All Professional features
|
|
61
|
+
- Unlimited usage
|
|
62
|
+
- Dedicated support
|
|
63
|
+
- Custom integrations
|
|
64
|
+
- SLA guarantees
|
|
65
|
+
|
|
66
|
+
## API Endpoints
|
|
67
|
+
|
|
68
|
+
### REST API
|
|
69
|
+
- `GET /api/plans` - List all available plans
|
|
70
|
+
- `GET /api/plans/{planId}` - Get plan details
|
|
71
|
+
- `POST /api/plans` - Create new plan
|
|
72
|
+
- `PUT /api/plans/{planId}` - Update plan
|
|
73
|
+
- `POST /api/plans/migrate` - Migrate subscription to different plan
|
|
74
|
+
|
|
75
|
+
## Plan Structure
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"id": "pro-monthly",
|
|
80
|
+
"name": "Professional Monthly",
|
|
81
|
+
"price": 49.99,
|
|
82
|
+
"currency": "USD",
|
|
83
|
+
"interval": "monthly",
|
|
84
|
+
"features": {
|
|
85
|
+
"api_calls": 10000,
|
|
86
|
+
"storage_gb": 100,
|
|
87
|
+
"team_members": 10,
|
|
88
|
+
"priority_support": true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<Footer />
|