Skip to content

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:

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 RequirementsSingle DomainMulti-DomainEnterprise Scale
Basic SetupAction or Store OnlyNot RecommendedNot Recommended
Multi-Context SetupMVVM Architecture SetupDomain Context SetupEnterprise Setup
Advanced SetupNested MVVMEvent Bus IntegrationContext 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:

typescript
// 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)

  1. Setup: Follow MVVM Architecture Setup
  2. Implementation: Apply MVVM Pattern guidelines
  3. Optimization: Use Context Splitting for performance
  4. Advanced: Implement Composition Strategies for complex scenarios

Path B: Domain Context Architecture (Business Domain Separation)

  1. Setup: Follow Domain Context Architecture Setup
  2. Implementation: Apply Domain Context Pattern guidelines
  3. Communication: Implement Cross-Context Communication
  4. Scaling: Use Enterprise Setup Patterns

Path C: Combined Enterprise Architecture

  1. Setup: Follow Enterprise Multi-Context Setup
  2. Foundation: Establish Context Bridge patterns
  3. Implementation: Combine both MVVM and Domain patterns as needed
  4. 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

ArchitectureSetup ComplexityBest ForSetup Guide
MVVMModerateSingle domain, technical teamsMVVM Setup
Domain ContextModerate to HighMulti-domain, business teamsDomain Setup
Combined EnterpriseHighLarge scale, complex requirementsEnterprise Setup

Integration with Framework Patterns

All architecture patterns integrate seamlessly with the Context-Action framework's core patterns:

Action Integration

Store Integration

Ref Integration

Released under the Apache-2.0 License.