@eventcatalog/create-eventcatalog 3.0.9 → 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/amazon-api-gateway/eventcatalog.config.js +3 -0
- package/templates/asyncapi/eventcatalog.config.js +3 -0
- package/templates/confluent/eventcatalog.config.js +3 -0
- 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
- package/templates/default/eventcatalog.config.js +3 -0
- package/templates/empty/eventcatalog.config.js +3 -0
- package/templates/eventbridge/eventcatalog.config.js +3 -0
- package/templates/openapi/eventcatalog.config.js +3 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: FraudDetectionService
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Fraud Detection Service
|
|
5
|
+
summary: Analyzes payment transactions for fraudulent activity and risk assessment
|
|
6
|
+
repository:
|
|
7
|
+
url: https://github.com/eventcatalog/fraud-detection-service
|
|
8
|
+
receives:
|
|
9
|
+
- id: PaymentInitiated
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
- id: PaymentProcessed
|
|
12
|
+
version: 0.0.1
|
|
13
|
+
- id: SubscriptionPaymentDue
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
sends:
|
|
16
|
+
- id: FraudCheckCompleted
|
|
17
|
+
version: 0.0.1
|
|
18
|
+
- id: FraudDetected
|
|
19
|
+
version: 0.0.1
|
|
20
|
+
- id: RiskScoreCalculated
|
|
21
|
+
version: 0.0.1
|
|
22
|
+
owners:
|
|
23
|
+
- riskTeam
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
import Footer from '@catalog/components/footer.astro'
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
The Fraud Detection Service is responsible for analyzing payment transactions in real-time to detect potential fraudulent activity. It uses machine learning models and rule-based systems to assess risk and prevent financial losses.
|
|
31
|
+
|
|
32
|
+
## Key Features
|
|
33
|
+
|
|
34
|
+
- **Real-time Transaction Analysis**: Analyzes transactions as they occur
|
|
35
|
+
- **Machine Learning Models**: Uses ML to identify suspicious patterns
|
|
36
|
+
- **Risk Scoring**: Calculates risk scores for each transaction
|
|
37
|
+
- **Automated Blocking**: Can automatically block high-risk transactions
|
|
38
|
+
- **Manual Review Queue**: Flags medium-risk transactions for manual review
|
|
39
|
+
|
|
40
|
+
## API Endpoints
|
|
41
|
+
|
|
42
|
+
### REST API
|
|
43
|
+
- `POST /api/fraud/check` - Submit transaction for fraud check
|
|
44
|
+
- `GET /api/fraud/risk-score/{transactionId}` - Get risk score for transaction
|
|
45
|
+
- `PUT /api/fraud/override/{transactionId}` - Manual override of fraud decision
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
fraud_detection:
|
|
51
|
+
risk_thresholds:
|
|
52
|
+
high: 80
|
|
53
|
+
medium: 50
|
|
54
|
+
low: 20
|
|
55
|
+
auto_block_threshold: 90
|
|
56
|
+
ml_model_version: "2.3.1"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<Footer />
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ProcessPayment
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Process Payment
|
|
5
|
+
summary: Command to process a payment through the payment gateway
|
|
6
|
+
tags:
|
|
7
|
+
- payment
|
|
8
|
+
- command
|
|
9
|
+
- cross-domain
|
|
10
|
+
badges:
|
|
11
|
+
- content: Command
|
|
12
|
+
backgroundColor: blue
|
|
13
|
+
textColor: white
|
|
14
|
+
schemaPath: schema.json
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
import Footer from '@catalog/components/footer.astro'
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
The `ProcessPayment` command is used to initiate payment processing through the payment gateway. This command can be triggered by various sources including the Billing Service for subscription payments.
|
|
22
|
+
|
|
23
|
+
## Command Sources
|
|
24
|
+
|
|
25
|
+
This command can be triggered by:
|
|
26
|
+
- **BillingService** (Subscriptions Domain) - For recurring subscription payments
|
|
27
|
+
- **OrdersService** (Orders Domain) - For one-time order payments
|
|
28
|
+
- **PaymentService** (Payment Domain) - For payment retries
|
|
29
|
+
|
|
30
|
+
## Command Flow
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
sequenceDiagram
|
|
34
|
+
participant BS as BillingService
|
|
35
|
+
participant PGS as PaymentGatewayService
|
|
36
|
+
participant FDS as FraudDetectionService
|
|
37
|
+
participant EXT as External Gateway
|
|
38
|
+
|
|
39
|
+
BS->>PGS: ProcessPayment
|
|
40
|
+
PGS->>FDS: Check Fraud
|
|
41
|
+
FDS-->>PGS: Risk Assessment
|
|
42
|
+
PGS->>EXT: Process Payment
|
|
43
|
+
EXT-->>PGS: Payment Result
|
|
44
|
+
PGS-->>BS: PaymentProcessed/Failed
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Schema
|
|
48
|
+
|
|
49
|
+
<SchemaViewer title="ProcessPayment Schema" schemaPath={frontmatter.schemaPath} />
|
|
50
|
+
|
|
51
|
+
## Example Request
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"paymentId": "pay_123456",
|
|
56
|
+
"amount": 49.99,
|
|
57
|
+
"currency": "USD",
|
|
58
|
+
"paymentMethod": {
|
|
59
|
+
"type": "card",
|
|
60
|
+
"token": "tok_visa_4242"
|
|
61
|
+
},
|
|
62
|
+
"metadata": {
|
|
63
|
+
"subscriptionId": "sub_ABC123",
|
|
64
|
+
"invoiceId": "inv_123456",
|
|
65
|
+
"customerId": "cust_XYZ789"
|
|
66
|
+
},
|
|
67
|
+
"idempotencyKey": "sub_ABC123_2024_02",
|
|
68
|
+
"captureImmediately": true
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
<Footer />
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"paymentId": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "Unique identifier for this payment"
|
|
8
|
+
},
|
|
9
|
+
"amount": {
|
|
10
|
+
"type": "number",
|
|
11
|
+
"description": "Payment amount"
|
|
12
|
+
},
|
|
13
|
+
"currency": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Currency code (ISO 4217)"
|
|
16
|
+
},
|
|
17
|
+
"paymentMethod": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"type": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["card", "bank_transfer", "paypal", "digital_wallet"]
|
|
23
|
+
},
|
|
24
|
+
"token": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Payment method token"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": ["type", "token"]
|
|
30
|
+
},
|
|
31
|
+
"metadata": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"subscriptionId": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"invoiceId": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"customerId": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"orderId": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"idempotencyKey": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Key to prevent duplicate payments"
|
|
51
|
+
},
|
|
52
|
+
"captureImmediately": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"description": "Whether to capture payment immediately or just authorize"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["paymentId", "amount", "currency", "paymentMethod", "idempotencyKey"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PaymentFailed
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Payment Failed
|
|
5
|
+
summary: Emitted when a payment attempt fails
|
|
6
|
+
badges:
|
|
7
|
+
- content: Error Event
|
|
8
|
+
backgroundColor: red
|
|
9
|
+
textColor: white
|
|
10
|
+
schemaPath: schema.json
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
import Footer from '@catalog/components/footer.astro'
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
The `PaymentFailed` event is emitted when a payment attempt fails for any reason. This event is consumed by various services to handle payment failures appropriately.
|
|
18
|
+
|
|
19
|
+
## Consumers
|
|
20
|
+
|
|
21
|
+
This event is consumed by:
|
|
22
|
+
- **BillingService** (Subscriptions Domain) - To handle subscription payment failures
|
|
23
|
+
- **OrdersService** (Orders Domain) - To handle order payment failures
|
|
24
|
+
- **NotificationService** (Orders Domain) - To notify customers of payment failures
|
|
25
|
+
|
|
26
|
+
## Failure Reasons
|
|
27
|
+
|
|
28
|
+
Common failure reasons include:
|
|
29
|
+
- **insufficient_funds** - Card has insufficient funds
|
|
30
|
+
- **card_declined** - Card was declined by issuer
|
|
31
|
+
- **expired_card** - Card has expired
|
|
32
|
+
- **fraud_suspected** - Payment flagged as potentially fraudulent
|
|
33
|
+
- **network_error** - Payment gateway network error
|
|
34
|
+
- **invalid_payment_method** - Payment method is invalid
|
|
35
|
+
|
|
36
|
+
## Schema
|
|
37
|
+
|
|
38
|
+
<SchemaViewer title="PaymentFailed Schema" schemaPath={frontmatter.schemaPath} />
|
|
39
|
+
|
|
40
|
+
## Example Payload
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"paymentId": "pay_123456",
|
|
45
|
+
"amount": 49.99,
|
|
46
|
+
"currency": "USD",
|
|
47
|
+
"failureReason": "insufficient_funds",
|
|
48
|
+
"failureMessage": "Your card has insufficient funds",
|
|
49
|
+
"metadata": {
|
|
50
|
+
"subscriptionId": "sub_ABC123",
|
|
51
|
+
"invoiceId": "inv_123456",
|
|
52
|
+
"customerId": "cust_XYZ789"
|
|
53
|
+
},
|
|
54
|
+
"canRetry": true,
|
|
55
|
+
"nextRetryAt": "2024-02-02T00:00:00Z",
|
|
56
|
+
"timestamp": "2024-02-01T10:30:00Z"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
<Footer />
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"paymentId": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "Unique identifier for the failed payment"
|
|
8
|
+
},
|
|
9
|
+
"amount": {
|
|
10
|
+
"type": "number",
|
|
11
|
+
"description": "Payment amount that failed"
|
|
12
|
+
},
|
|
13
|
+
"currency": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Currency code (ISO 4217)"
|
|
16
|
+
},
|
|
17
|
+
"failureReason": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": [
|
|
20
|
+
"insufficient_funds",
|
|
21
|
+
"card_declined",
|
|
22
|
+
"expired_card",
|
|
23
|
+
"fraud_suspected",
|
|
24
|
+
"network_error",
|
|
25
|
+
"invalid_payment_method",
|
|
26
|
+
"authentication_required",
|
|
27
|
+
"other"
|
|
28
|
+
],
|
|
29
|
+
"description": "Reason for payment failure"
|
|
30
|
+
},
|
|
31
|
+
"failureMessage": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Human-readable failure message"
|
|
34
|
+
},
|
|
35
|
+
"metadata": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"subscriptionId": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"invoiceId": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"customerId": {
|
|
45
|
+
"type": "string"
|
|
46
|
+
},
|
|
47
|
+
"orderId": {
|
|
48
|
+
"type": "string"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"canRetry": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"description": "Whether this payment can be retried"
|
|
55
|
+
},
|
|
56
|
+
"nextRetryAt": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"format": "date-time",
|
|
59
|
+
"description": "Suggested time for next retry attempt"
|
|
60
|
+
},
|
|
61
|
+
"timestamp": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"format": "date-time",
|
|
64
|
+
"description": "When the failure occurred"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"required": ["paymentId", "amount", "currency", "failureReason", "timestamp"]
|
|
68
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PaymentGatewayService
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Payment Gateway Service
|
|
5
|
+
summary: Manages integration with external payment processors (Stripe, PayPal, etc.)
|
|
6
|
+
tags:
|
|
7
|
+
- payment
|
|
8
|
+
- gateway
|
|
9
|
+
- integration
|
|
10
|
+
repository:
|
|
11
|
+
url: https://github.com/eventcatalog/payment-gateway-service
|
|
12
|
+
receives:
|
|
13
|
+
- id: ProcessPayment
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
- id: RefundPayment
|
|
16
|
+
version: 0.0.1
|
|
17
|
+
- id: FraudCheckCompleted
|
|
18
|
+
version: 0.0.1
|
|
19
|
+
sends:
|
|
20
|
+
- id: PaymentAuthorized
|
|
21
|
+
version: 0.0.1
|
|
22
|
+
- id: PaymentCaptured
|
|
23
|
+
version: 0.0.1
|
|
24
|
+
- id: PaymentFailed
|
|
25
|
+
version: 0.0.1
|
|
26
|
+
- id: RefundProcessed
|
|
27
|
+
version: 0.0.1
|
|
28
|
+
owners:
|
|
29
|
+
- paymentsTeam
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
import Footer from '@catalog/components/footer.astro'
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
The Payment Gateway Service acts as an abstraction layer between our payment system and external payment processors. It handles the complexity of integrating with multiple payment providers and provides a unified interface for payment operations.
|
|
37
|
+
|
|
38
|
+
## Supported Payment Providers
|
|
39
|
+
|
|
40
|
+
- **Stripe**: Credit/debit cards, digital wallets
|
|
41
|
+
- **PayPal**: PayPal accounts, PayPal Credit
|
|
42
|
+
- **Square**: In-person and online payments
|
|
43
|
+
- **Adyen**: Global payment processing
|
|
44
|
+
- **Braintree**: Multiple payment methods
|
|
45
|
+
|
|
46
|
+
## Key Features
|
|
47
|
+
|
|
48
|
+
- **Multi-provider Support**: Switch between providers seamlessly
|
|
49
|
+
- **Retry Logic**: Automatic retry for failed transactions
|
|
50
|
+
- **Tokenization**: Secure card data handling
|
|
51
|
+
- **Webhook Management**: Handles provider webhooks
|
|
52
|
+
- **Currency Conversion**: Support for 150+ currencies
|
|
53
|
+
|
|
54
|
+
## API Endpoints
|
|
55
|
+
|
|
56
|
+
### REST API
|
|
57
|
+
- `POST /api/gateway/authorize` - Authorize a payment
|
|
58
|
+
- `POST /api/gateway/capture` - Capture an authorized payment
|
|
59
|
+
- `POST /api/gateway/refund` - Process a refund
|
|
60
|
+
- `GET /api/gateway/status/{transactionId}` - Get transaction status
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
payment_gateway:
|
|
66
|
+
providers:
|
|
67
|
+
stripe:
|
|
68
|
+
api_key: ${STRIPE_API_KEY}
|
|
69
|
+
webhook_secret: ${STRIPE_WEBHOOK_SECRET}
|
|
70
|
+
paypal:
|
|
71
|
+
client_id: ${PAYPAL_CLIENT_ID}
|
|
72
|
+
client_secret: ${PAYPAL_CLIENT_SECRET}
|
|
73
|
+
retry:
|
|
74
|
+
max_attempts: 3
|
|
75
|
+
backoff_ms: 1000
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
<Footer />
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Category
|
|
3
|
+
name: Category
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: categoryId
|
|
6
|
+
aggregateRoot: true
|
|
7
|
+
summary: Represents a product category with hierarchical structure support.
|
|
8
|
+
properties:
|
|
9
|
+
- name: categoryId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for the category
|
|
13
|
+
- name: name
|
|
14
|
+
type: string
|
|
15
|
+
required: true
|
|
16
|
+
description: Name of the category
|
|
17
|
+
- name: description
|
|
18
|
+
type: string
|
|
19
|
+
required: false
|
|
20
|
+
description: Description of the category
|
|
21
|
+
- name: slug
|
|
22
|
+
type: string
|
|
23
|
+
required: true
|
|
24
|
+
description: URL-friendly identifier for the category
|
|
25
|
+
- name: parentCategoryId
|
|
26
|
+
type: UUID
|
|
27
|
+
required: false
|
|
28
|
+
description: Parent category for hierarchical structure
|
|
29
|
+
references: Category
|
|
30
|
+
referencesIdentifier: categoryId
|
|
31
|
+
relationType: hasOne
|
|
32
|
+
- name: childCategories
|
|
33
|
+
type: array
|
|
34
|
+
items:
|
|
35
|
+
type: Category
|
|
36
|
+
required: false
|
|
37
|
+
description: Subcategories under this category
|
|
38
|
+
references: Category
|
|
39
|
+
referencesIdentifier: parentCategoryId
|
|
40
|
+
relationType: hasMany
|
|
41
|
+
- name: level
|
|
42
|
+
type: integer
|
|
43
|
+
required: true
|
|
44
|
+
description: Depth level in the category hierarchy (0 = root)
|
|
45
|
+
- name: isActive
|
|
46
|
+
type: boolean
|
|
47
|
+
required: true
|
|
48
|
+
description: Whether the category is currently active
|
|
49
|
+
- name: sortOrder
|
|
50
|
+
type: integer
|
|
51
|
+
required: false
|
|
52
|
+
description: Display order within the same level
|
|
53
|
+
- name: icon
|
|
54
|
+
type: string
|
|
55
|
+
required: false
|
|
56
|
+
description: Icon URL or identifier for the category
|
|
57
|
+
- name: imageUrl
|
|
58
|
+
type: string
|
|
59
|
+
required: false
|
|
60
|
+
description: Category banner or thumbnail image
|
|
61
|
+
- name: seoTitle
|
|
62
|
+
type: string
|
|
63
|
+
required: false
|
|
64
|
+
description: SEO-optimized title for the category page
|
|
65
|
+
- name: seoDescription
|
|
66
|
+
type: string
|
|
67
|
+
required: false
|
|
68
|
+
description: SEO meta description for the category page
|
|
69
|
+
- name: products
|
|
70
|
+
type: array
|
|
71
|
+
items:
|
|
72
|
+
type: Product
|
|
73
|
+
required: false
|
|
74
|
+
description: Products belonging to this category
|
|
75
|
+
references: Product
|
|
76
|
+
referencesIdentifier: categoryId
|
|
77
|
+
relationType: hasMany
|
|
78
|
+
- name: createdAt
|
|
79
|
+
type: DateTime
|
|
80
|
+
required: true
|
|
81
|
+
description: Date and time when the category was created
|
|
82
|
+
- name: updatedAt
|
|
83
|
+
type: DateTime
|
|
84
|
+
required: false
|
|
85
|
+
description: Date and time when the category was last updated
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Overview
|
|
89
|
+
|
|
90
|
+
The Category entity organizes products into a hierarchical structure, supporting multi-level categorization. It enables efficient product discovery and navigation through the e-commerce catalog.
|
|
91
|
+
|
|
92
|
+
### Entity Properties
|
|
93
|
+
<EntityPropertiesTable />
|
|
94
|
+
|
|
95
|
+
## Relationships
|
|
96
|
+
|
|
97
|
+
* **Parent Category:** Each category can have one parent `Category` (identified by `parentCategoryId`).
|
|
98
|
+
* **Child Categories:** A category can have multiple child `Category` entities creating a hierarchy.
|
|
99
|
+
* **Products:** A category contains multiple `Product` entities (identified by `categoryId`).
|
|
100
|
+
|
|
101
|
+
## Hierarchy Examples
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Electronics (Level 0)
|
|
105
|
+
├── Computers (Level 1)
|
|
106
|
+
│ ├── Laptops (Level 2)
|
|
107
|
+
│ ├── Desktops (Level 2)
|
|
108
|
+
│ └── Tablets (Level 2)
|
|
109
|
+
├── Mobile Phones (Level 1)
|
|
110
|
+
│ ├── Smartphones (Level 2)
|
|
111
|
+
│ └── Feature Phones (Level 2)
|
|
112
|
+
└── Audio (Level 1)
|
|
113
|
+
├── Headphones (Level 2)
|
|
114
|
+
└── Speakers (Level 2)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Business Rules
|
|
118
|
+
|
|
119
|
+
* Root categories have `parentCategoryId` as null and `level` as 0
|
|
120
|
+
* Child categories must have a valid `parentCategoryId`
|
|
121
|
+
* Category slugs must be unique across the entire catalog
|
|
122
|
+
* Categories cannot be deleted if they contain products or subcategories
|
|
123
|
+
* Inactive categories should hide all associated products from public view
|
|
124
|
+
* Maximum hierarchy depth should be limited (e.g., 5 levels)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Inventory
|
|
3
|
+
name: Inventory
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: inventoryId
|
|
6
|
+
summary: Tracks stock levels and availability for products.
|
|
7
|
+
properties:
|
|
8
|
+
- name: inventoryId
|
|
9
|
+
type: UUID
|
|
10
|
+
required: true
|
|
11
|
+
description: Unique identifier for the inventory record
|
|
12
|
+
- name: productId
|
|
13
|
+
type: UUID
|
|
14
|
+
required: true
|
|
15
|
+
description: Product this inventory record tracks
|
|
16
|
+
references: Product
|
|
17
|
+
referencesIdentifier: productId
|
|
18
|
+
relationType: hasOne
|
|
19
|
+
- name: sku
|
|
20
|
+
type: string
|
|
21
|
+
required: true
|
|
22
|
+
description: Stock Keeping Unit matching the product SKU
|
|
23
|
+
- name: quantityOnHand
|
|
24
|
+
type: integer
|
|
25
|
+
required: true
|
|
26
|
+
description: Current available stock quantity
|
|
27
|
+
- name: quantityReserved
|
|
28
|
+
type: integer
|
|
29
|
+
required: true
|
|
30
|
+
description: Quantity reserved for pending orders
|
|
31
|
+
- name: quantityAvailable
|
|
32
|
+
type: integer
|
|
33
|
+
required: true
|
|
34
|
+
description: Calculated available quantity (onHand - reserved)
|
|
35
|
+
- name: minimumStockLevel
|
|
36
|
+
type: integer
|
|
37
|
+
required: true
|
|
38
|
+
description: Minimum stock level before reorder alert
|
|
39
|
+
- name: maximumStockLevel
|
|
40
|
+
type: integer
|
|
41
|
+
required: false
|
|
42
|
+
description: Maximum stock level for inventory management
|
|
43
|
+
- name: reorderPoint
|
|
44
|
+
type: integer
|
|
45
|
+
required: true
|
|
46
|
+
description: Stock level that triggers reorder process
|
|
47
|
+
- name: reorderQuantity
|
|
48
|
+
type: integer
|
|
49
|
+
required: true
|
|
50
|
+
description: Quantity to order when restocking
|
|
51
|
+
- name: unitCost
|
|
52
|
+
type: decimal
|
|
53
|
+
required: false
|
|
54
|
+
description: Cost per unit for inventory valuation
|
|
55
|
+
- name: warehouseLocation
|
|
56
|
+
type: string
|
|
57
|
+
required: false
|
|
58
|
+
description: Physical location or bin where item is stored
|
|
59
|
+
- name: lastRestockedAt
|
|
60
|
+
type: DateTime
|
|
61
|
+
required: false
|
|
62
|
+
description: Date and time of last restock
|
|
63
|
+
- name: lastSoldAt
|
|
64
|
+
type: DateTime
|
|
65
|
+
required: false
|
|
66
|
+
description: Date and time of last sale
|
|
67
|
+
- name: isTrackingEnabled
|
|
68
|
+
type: boolean
|
|
69
|
+
required: true
|
|
70
|
+
description: Whether inventory tracking is enabled for this product
|
|
71
|
+
- name: backorderAllowed
|
|
72
|
+
type: boolean
|
|
73
|
+
required: true
|
|
74
|
+
description: Whether backorders are allowed when out of stock
|
|
75
|
+
- name: createdAt
|
|
76
|
+
type: DateTime
|
|
77
|
+
required: true
|
|
78
|
+
description: Date and time when the inventory record was created
|
|
79
|
+
- name: updatedAt
|
|
80
|
+
type: DateTime
|
|
81
|
+
required: false
|
|
82
|
+
description: Date and time when the inventory record was last updated
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Overview
|
|
86
|
+
|
|
87
|
+
The Inventory entity manages stock levels and availability for products in the e-commerce system. It tracks current quantities, reserved stock, and provides reorder management capabilities.
|
|
88
|
+
|
|
89
|
+
### Entity Properties
|
|
90
|
+
<EntityPropertiesTable />
|
|
91
|
+
|
|
92
|
+
## Relationships
|
|
93
|
+
|
|
94
|
+
* **Product:** Each inventory record belongs to one `Product` (identified by `productId`).
|
|
95
|
+
* **OrderItem:** Inventory quantities are affected by `OrderItem` entities when orders are placed.
|
|
96
|
+
|
|
97
|
+
## Stock Calculations
|
|
98
|
+
|
|
99
|
+
* **Available Quantity** = Quantity On Hand - Quantity Reserved
|
|
100
|
+
* **Reorder Needed** = Quantity Available <= Reorder Point
|
|
101
|
+
* **Stock Value** = Quantity On Hand × Unit Cost
|
|
102
|
+
|
|
103
|
+
## Examples
|
|
104
|
+
|
|
105
|
+
* **Inventory #1:** iPhone 15 Pro - 25 on hand, 5 reserved, 20 available, reorder at 10 units.
|
|
106
|
+
* **Inventory #2:** Running Shoes Size 9 - 0 on hand, 2 reserved, backorder allowed.
|
|
107
|
+
|
|
108
|
+
## Business Rules
|
|
109
|
+
|
|
110
|
+
* Quantity on hand cannot be negative
|
|
111
|
+
* Quantity reserved cannot exceed quantity on hand
|
|
112
|
+
* Available quantity is automatically calculated
|
|
113
|
+
* Reorder alerts are triggered when available = reorder point
|
|
114
|
+
* Stock reservations are created when orders are placed
|
|
115
|
+
* Stock is decremented when orders are shipped
|
|
116
|
+
* Inventory adjustments must be logged for audit trail
|