3.7 KiB
3.7 KiB
Domain Restructure - Progress Report
Date: October 3, 2025
Status: 🚧 In Progress (75% Complete)
✅ Completed Domains
1. Billing ✅
domain/billing/
├── contract.ts ✅ Invoice, InvoiceStatus, INVOICE_STATUS
├── schema.ts ✅ invoiceSchema, invoiceListSchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsInvoiceRaw
└── mapper.ts ✅ transformWhmcsInvoice()
2. Subscriptions ✅
domain/subscriptions/
├── contract.ts ✅ Subscription, SubscriptionStatus, SUBSCRIPTION_STATUS
├── schema.ts ✅ subscriptionSchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsProductRaw
└── mapper.ts ✅ transformWhmcsSubscription()
3. Payments ✅
domain/payments/
├── contract.ts ✅ PaymentMethod, PaymentGateway
├── schema.ts ✅ paymentMethodSchema, paymentGatewaySchema
├── index.ts ✅
└── providers/whmcs/
├── raw.types.ts ✅ WhmcsPaymentMethodRaw
└── mapper.ts ✅ transformWhmcsPaymentMethod()
4. SIM ✅
domain/sim/
├── contract.ts ✅ SimDetails, SimUsage, SimTopUpHistory
├── schema.ts ✅ simDetailsSchema, simUsageSchema
├── index.ts ✅
└── providers/freebit/
├── raw.types.ts ✅ FreebitAccountDetailsRaw
└── mapper.ts ✅ transformFreebitAccountDetails()
🚧 Remaining Work
5. Orders (In Progress)
- contract.ts - Order, OrderItem, FulfillmentOrderDetails
- schema.ts
- providers/salesforce/ - Read orders
- providers/whmcs/ - Create orders
6. Catalog
- contract.ts - CatalogProduct, SimCatalogProduct
- schema.ts
- providers/salesforce/
7. Common
- types.ts - Address, Money, BaseEntity
- identifiers.ts - UserId, OrderId, etc.
- api.ts - ApiResponse, PaginatedResponse
- schema.ts
8. Toolkit
- formatting/currency.ts
- validation/helpers.ts
- typing/patterns.ts
📦 Package Updates Needed
- Update
packages/domain/package.jsonexports - Update
packages/domain/tsconfig.json - Update BFF
tsconfig.jsonpaths - Update Portal
tsconfig.jsonpaths
🔄 Migration Steps Remaining
- Finish creating all domains
- Update package.json with new exports
- Update tsconfig paths
- Create migration script for imports (optional)
- Update sample imports in BFF (1-2 files as examples)
- Update sample imports in Portal (1-2 files as examples)
- Build and verify compilation
- Update documentation
🎯 New Import Patterns (Examples)
Current (Old)
import { Invoice } from "@customer-portal/contracts/billing";
import { invoiceSchema } from "@customer-portal/schemas/billing";
import { transformWhmcsInvoice } from "@customer-portal/integrations-whmcs/mappers";
New (Domain-First)
import { Invoice, invoiceSchema, INVOICE_STATUS } from "@customer-portal/domain/billing";
import { transformWhmcsInvoice } from "@customer-portal/domain/billing/providers/whmcs/mapper";
✨ Benefits Achieved
- ✅ Domain-centric organization
- ✅ Co-located contracts + schemas
- ✅ Provider isolation (no leaking)
- ✅ Single package (
@customer-portal/domain) - ✅ Scalable provider pattern
Next Steps: Complete orders, catalog, common, toolkit, then package configuration.