Bounded Contexts and Context Map¶
This document defines the bounded contexts and their relationships for the Employment Services SaaS domain. It is written for architects and engineers designing the domain boundaries and service architecture.
Bounded contexts define clear domain boundaries, ensuring each context has a single responsibility and well-defined integration points. This document maps the Employment Services domain into bounded contexts and shows how they interact.
Important
Each bounded context becomes a microservice generated by the Factory. Clear boundaries ensure maintainability, scalability, and independent evolution of services.
Bounded Contexts Overview¶
| Context Name | Responsibility | Key Capabilities |
|---|---|---|
| Tenant Management | Tenants, subscriptions, editions | Tenant onboarding, subscription management, edition features, tenant settings |
| Customer Accounts | Customer organizations, contacts | Customer organization management, contact management, customer profiles |
| Project & Engagement | Projects, engagements, milestones, contracts | Project creation, engagement management, milestone tracking, contract terms |
| Squad & Staffing | Squad definitions, roles, capacity | Squad composition, role definitions, capacity management, squad assignments |
| Work Management | Epics, stories, task tracking | Epic management, user story tracking, task assignment, sprint planning |
| Billing & Invoicing | Pricing, invoices, payments | Pricing models, invoice generation, payment processing, billing reports |
| Reporting & Analytics | KPIs, dashboards, metrics | Dashboard generation, KPI calculation, report generation, analytics |
Context Descriptions¶
Tenant Management¶
Purpose: Manages multi-tenant SaaS infrastructure: tenant creation, subscription management, edition features, and tenant-level configuration.
Key Aggregates: - Tenant - Tenant organization with subscription and edition - TenantEditionAssignment - Edition features assigned to tenant - TenantSettings - Tenant-level configuration
Integration Emphasis: - Provides tenant context to all other contexts - Integrates with Config Platform for tenant settings - Integrates with Identity Platform for tenant isolation
Customer Accounts¶
Purpose: Manages customer organizations and their contacts within a tenant. Handles customer profiles, contact management, and organizational structure.
Key Aggregates: - CustomerOrganization - Customer organization within tenant - Contact - Individual contacts within customer organization - CustomerProfile - Customer profile and preferences
Integration Emphasis: - Depends on Tenant Management for tenant context - Used by Project & Engagement for project ownership - Used by Billing for billing relationships
Project & Engagement¶
Purpose: Core domain for managing projects and engagements. Handles project lifecycle, engagement contracts, milestones, and deliverables.
Key Aggregates: - Project - Project definition and metadata - Engagement - Contract between customer and squad - Milestone - Project milestones and deliverables - ContractTerms - Engagement terms and conditions
Integration Emphasis: - Depends on Customer Accounts for project ownership - Depends on Squad & Staffing for squad assignments - Emits events consumed by Work Management and Billing
Squad & Staffing¶
Purpose: Manages squad definitions, compositions, capacity, and assignments to engagements.
Key Aggregates: - Squad - Squad definition with composition and capacity - SquadMember - Individual squad member with role - Assignment - Assignment of squad to engagement - CapacitySlot - Available capacity slots
Integration Emphasis: - Used by Project & Engagement for squad assignments - Emits events for capacity changes - Integrates with Factory for squad execution
Work Management¶
Purpose: Manages work items: epics, user stories, tasks, and sprints. Tracks work progress and completion.
Key Aggregates: - Epic - High-level feature or capability - UserStory - User story with acceptance criteria - Task - Individual task or work item - Sprint - Sprint definition and tracking
Integration Emphasis: - Depends on Project & Engagement for project context - Consumes engagement events - Emits work completion events for billing
Billing & Invoicing¶
Purpose: Manages pricing models, invoice generation, payment processing, and billing reports.
Key Aggregates: - PricePlan - Pricing plan definition - Invoice - Invoice with line items - Payment - Payment record and status - BillingCycle - Billing cycle and period
Integration Emphasis: - Consumes events from Project & Engagement and Work Management - Integrates with external payment processors - Emits billing events for reporting
Reporting & Analytics¶
Purpose: Aggregates data from other contexts to provide dashboards, KPIs, and analytics.
Key Aggregates: - Dashboard - Dashboard definition and configuration - KPI - Key performance indicator definition - Report - Report definition and generation - Metric - Calculated metric values
Integration Emphasis: - Consumes events from all contexts - Queries Audit Platform for audit data - Provides analytics APIs for dashboards
Context Map (Relationships)¶
flowchart TD
TM[Tenant Management] --> CA[Customer Accounts]
TM --> PE[Project & Engagement]
TM --> SS[Squad & Staffing]
CA --> PE
PE --> SS
PE --> WM[Work Management]
PE --> BI[Billing & Invoicing]
SS --> PE
WM --> BI
BI --> RA[Reporting & Analytics]
WM --> RA
PE --> RA
style TM fill:#e1f5ff
style CA fill:#fff4e1
style PE fill:#e8f5e9
style SS fill:#f3e5f5
style WM fill:#fff4e1
style BI fill:#e8f5e9
style RA fill:#f3e5f5
Relationship Types¶
Upstream/Downstream: - Tenant Management → Upstream (provides tenant context to all) - Customer Accounts → Downstream from Tenant Management - Project & Engagement → Downstream from Tenant Management and Customer Accounts - Squad & Staffing → Downstream from Tenant Management - Work Management → Downstream from Project & Engagement - Billing & Invoicing → Downstream from Project & Engagement and Work Management - Reporting & Analytics → Downstream from all contexts
Integration Patterns: - Events - Most contexts communicate via events - APIs - Direct API calls for synchronous operations - Shared Data - Tenant context shared across all contexts
See: Event-Driven Mindset for event patterns.
Mapping to Factory-Generated Services¶
One Context = One Microservice (Recommended)¶
Service Mapping:
| Bounded Context | Microservice Name | Template |
|---|---|---|
| Tenant Management | TenantManagement.Service |
Microservice Template |
| Customer Accounts | CustomerAccounts.Service |
Microservice Template |
| Project & Engagement | ProjectEngagement.Service |
Microservice Template |
| Squad & Staffing | SquadStaffing.Service |
Microservice Template |
| Work Management | WorkManagement.Service |
Microservice Template |
| Billing & Invoicing | BillingInvoicing.Service |
Microservice Template |
| Reporting & Analytics | ReportingAnalytics.Service |
Microservice Template |
MVP: Combined Services (Alternative)¶
For MVP, consider combining:
- Tenant Management + Customer Accounts →
TenantService - Project & Engagement + Work Management →
ProjectService - Squad & Staffing →
SquadService - Billing & Invoicing →
BillingService - Reporting & Analytics →
AnalyticsService
Rationale: - Faster initial delivery - Fewer services to manage - Can split later as needed
See: Microservice Template for template details.
See: Getting Started with Factory for Factory usage.
Related Documents¶
- Domain Overview - Domain overview
- Domain Vision and Scope - Vision and scope
- Domain Model and Aggregates - Domain model
- Modularization - Modularization principles
- Clean Architecture & DDD - Architecture principles
- Event-Driven Mindset - Event patterns