Skip to content

Architecture

Billing is a Layer 3 host built on the Base Template layering (see template layering and reuse). The canonical layer suffixes (DomainModel, EntityModel, PersistenceModel.NHibernate, ServiceModel(.RestApi/.Grpc), MessagingModel, FlowModel.MassTransit, ActorModel.Orleans, etc.) are described in solution structure.

Service contracts

Code-first WCF-style contracts (ServiceModel.Grpc adapters - no .proto files) in ConnectSoft.Saas.Billing.ServiceModel:

Contract Operations gRPC adapter
ISubscriptionManagementService CreateAsync, UpgradeAsync, ChangeEditionAsync, CancelAsync GrpcSubscriptionManagementService
ISubscriptionQueryService GetSubscriptionForTenantAsync, GetSubscriptionByIdAsync GrpcSubscriptionQueryService

REST surface (SubscriptionsController, api/subscriptions)

HTTP Route Operation
POST /draft CreateAsync
PUT /activate UpgradeAsync
POST /assign-edition ChangeEditionAsync
PUT /cancel CancelAsync
POST /queries/by-tenant GetSubscriptionForTenantAsync
POST /queries/by-id GetSubscriptionByIdAsync

REST controllers and gRPC adapters both implement the same ServiceModel interfaces, giving cross-adapter parity (verified in acceptance tests).

Messaging

MassTransit with MassTransitAdapter as IEventBus; UseInMemoryOutbox on the in-memory transport path. Billing publishes subscription/invoice/payment events and consumes tenant/catalog/entitlements/metering events through six sagas (see features). Topology in BillingMassTransitTopology.

Persistence

NHibernate + Fluent mappings (SubscriptionEntityMap, SubscriptionCycleEntityMap, SubscriptionSeatPolicyEntityMap), repositories (SubscriptionsRepository, SubscriptionsKeyedRepository), FluentMigrator (MicroserviceMigration, SampleBillingSeed). Shipped dialect is SQL Server (MsSql2012Dialect); appsettings also defines PostgreSQL/MySQL connection strings (see configuration). Multitenancy uses the shared SaasTenantFilter row filter on TenantId.

Concurrency

SubscriptionEditorGrain (Orleans, keyed by tenant id) serializes writes per tenant, backed by SubscriptionsGrainStorage (AdoNet on SQL Server).

See also