Architecture Patterns
Comprehensive architecture and design patterns for building scalable applications with the Context-Action framework, centered on Setup-First Architecture that prioritizes proper configuration and initialization.
Prerequisites
Before implementing any architecture pattern, ensure proper setup configuration:
- Multi-Context Setup Guide - Complete setup patterns for complex architectures including MVVM, Domain Context, and Enterprise configurations
- Basic Action Setup - Foundation action context setup for all patterns
- Basic Store Setup - Foundation store context setup for all patterns
- Provider Composition Setup - Advanced provider organization patterns
Available Architecture Patterns
MVVM Architecture
- MVVM Pattern - Model-View-ViewModel architecture with perfect layer separation
- Setup Guide: MVVM Architecture Setup
- Model Layer: Type-safe state management with Store Only Pattern
- ViewModel Layer: Business logic with Action Only Pattern
- Performance Layer: Direct DOM manipulation with RefContext Pattern
- View Layer: Pure React components for presentation
Domain Context Architecture
- Domain Context Pattern - Document-centric domain separation for multi-domain apps
- Setup Guide: Domain Context Architecture Setup
- Business Context: Core business logic and domain rules
- UI Context: Screen state and user interactions
- Validation Context: Data validation and error handling
- Design Context: Theme management and visual states
- Architecture Context: System configuration and technical decisions
Pattern Composition
- Composition Strategies - Advanced pattern composition for complex applications
- Setup Guide: Provider Composition Patterns
- Single Domain Composition: Action + Store + Ref patterns
- Multi-Domain Composition: Domain contexts with pattern layers
- Enterprise Scale: Combined architecture approaches
Context Management
- Context Splitting Patterns - Strategies for managing and splitting large contexts
- Setup Guide: Cross-Context Communication Setup
- Domain-based, layer-based, and feature-based splitting strategies
- Gradual migration patterns and cross-context communication
- Performance optimization and best practices for context management
Architecture Decision Matrix
Setup-Based Decision Framework
Choose architecture based on Setup Complexity and Application Scale:
| Setup Requirements | Single Domain | Multi-Domain | Enterprise Scale |
|---|---|---|---|
| Basic Setup | Action or Store Only | Not Recommended | Not Recommended |
| Multi-Context Setup | MVVM Architecture Setup | Domain Context Setup | Enterprise Setup |
| Advanced Setup | Nested MVVM | Event Bus Integration | Context Bridge |
When to Use MVVM Architecture
- ✅ Complex single-domain applications requiring clear layer separation
- ✅ Team specialization by technical layers (Model, ViewModel, View)
- ✅ Applications with complex business logic requiring structured approach
- ✅ Performance-critical applications needing RefContext optimization
- Setup Required: MVVM Architecture Setup
When to Use Domain Context Architecture
- ✅ Multi-domain business applications with distinct business areas
- ✅ Team boundaries aligned with business domains (User, Product, Order domains)
- ✅ Microservice architecture alignment requiring domain separation
- ✅ Document-centric workflow management with domain-specific contexts
- Setup Required: Domain Context Architecture Setup
When to Use Combined Approach
- ✅ Enterprise-scale applications requiring both domain and technical separation
- ✅ Multiple business domains with complex technical requirements
- ✅ Large teams with both domain and technical specialization
- ✅ Applications requiring graduated complexity and incremental architecture evolution
- Setup Required: Enterprise Multi-Context Setup
Setup-First Quick Start Guide
1. Complete Setup Configuration
Before implementing patterns, establish proper setup:
// Choose your primary setup approach
import {
// For MVVM: Layer-based setup
createStoreContext, // Model layer
createActionContext, // ViewModel layer
createRefContext, // Performance layer
// For Domain Context: Domain-based setup
composeProviders, // Provider composition
// For Enterprise: Advanced setup
// See Multi-Context Setup Guide
} from '@context-action/react';2. Architecture Implementation Path
Path A: MVVM Architecture (Technical Layer Separation)
- Setup: Follow MVVM Architecture Setup
- Implementation: Apply MVVM Pattern guidelines
- Optimization: Use Context Splitting for performance
- Advanced: Implement Composition Strategies for complex scenarios
Path B: Domain Context Architecture (Business Domain Separation)
- Setup: Follow Domain Context Architecture Setup
- Implementation: Apply Domain Context Pattern guidelines
- Communication: Implement Cross-Context Communication
- Scaling: Use Enterprise Setup Patterns
Path C: Combined Enterprise Architecture
- Setup: Follow Enterprise Multi-Context Setup
- Foundation: Establish Context Bridge patterns
- Implementation: Combine both MVVM and Domain patterns as needed
- Management: Use Nested Domain Composition
3. Setup Validation Checklist
✅ Prerequisites Met: All required setup guides have been followed
✅ Type Safety: All contexts have proper TypeScript configurations
✅ Provider Composition: Providers are organized using composeProviders
✅ Performance Optimization: RefContext is configured for performance-critical paths
✅ Cross-Context Communication: Event bus or context bridge is configured if needed
✅ Export Strategy: Proper barrel exports and domain bundles are established
Quick Architecture Comparison
| Architecture | Setup Complexity | Best For | Setup Guide |
|---|---|---|---|
| MVVM | Moderate | Single domain, technical teams | MVVM Setup |
| Domain Context | Moderate to High | Multi-domain, business teams | Domain Setup |
| Combined Enterprise | High | Large scale, complex requirements | Enterprise Setup |
Integration with Framework Patterns
All architecture patterns integrate seamlessly with the Context-Action framework's core patterns:
Action Integration
- Action Patterns: Reference Action Pattern Documentation
- Memory Management: Action patterns include advanced memory management with handler limits
- Setup Foundation: Use Basic Action Setup as foundation
Store Integration
- Store Patterns: Reference Store Pattern Documentation
- Setup Foundation: Use Basic Store Setup as foundation
Ref Integration
- Ref Patterns: Reference Ref Pattern Documentation
- Setup Foundation: Use Ref Context Setup for performance optimization