Inventory Service
The inventory service consists of the context ProductItem
.
It is responsible for managing the inventory - consisting of ProductItems
of a ProductVariant
. It is part of the order and return saga, where it reserves and releases the required ProductItems
.
Domain Model
Imported entities from other bounded contexts are marked with a dashed border.
API
The service provides a GraphQL API, which is documented in the GraphQL API documentation.
Technology Stack
- Language: TypeScript
- Framework: NestJS
- GraphQL Library: @nestjs/graphql with @nestjs/apollo (code first)
- Database: MongoDB
- Entity Management: Mongoose
Repository Structure
The repository is structured as follows:
/src/
: Source code of the serviceevents/
: Dapr event handlingdto/
: Event DTOs
health/
: Health APIinventory/
:ProductItem
Moduledto
: Inventory DTOsentities/
: Inventory persistet entitiesgraphql-types/
: Types for graphQL
product-variant-partial/
:ProductVariantPartial
Moduleentities/
: ProuctVariantPartial persistet entities
shared/
: Shared Code between different modulesconstants
: Shared constantsdecorators
: Shared decoratorsenums
: Shared enumeratorsguards
: Shared guardsinterfaces
: Shared interfaceslogger
: Logging configurationscalars
: Shared graphQL scalarsutils
: Shared helpers
Defined Events
This section lists events that are defined by the inventory service and can be used by other services.
Published Defined Events
inventory/product/created
This event is published when a new product is created.
{
id: string,
internalName: string,
isPubliclyVisible: boolean,
defaultVariantId: string,
categoryIds: string[]
}
inventory/product-item/reservation-succeeded
This event is published when all ProductItems
for the ProductVariants
of an Orders
OrderItems
were reserved successfully.
{
order: Order;
}
inventory/product-item/reservation-failed
This event is published when at least one ProductItem
for the ProductVariants
of an Orders
OrderItems
could not be reserved.
{
order: Order,
failedProductVariantIds: string[]
}
Subscribed Defined Events
n/a
Imported Events
This section lists events defined by other services that are used by the catalog service.
Published Imported Events
n/a
Subscribed Imported Events
- catalog/product-variant/created: Used to import
ProductVariant
from theCatalog
bounded context. - order/order/created: Used to reserve the
ProductItems
for anOrder
. - payment/payment/payment-enabled: Send Inventory to Fullfillment
- payment/payment/payment-failed: Releases Product Items related to the order
- shipment/shipment/status-updated: Updates the inventory status based on the shipment status
- shipment/shipment/created: Updates the inventory status based on the shipment status
- discount/order/validation-failed: Releases Product Items related to the order