Skip to content

Commit 7d0f98a

Browse files
author
LittleCoinCoin
committed
docs: diagrams
Original diagrams `chain_of_responsibility_overview.puml`, `three_component_architecture.puml`, `version_agnostic_access.puml` were too complicated. Replacing them in favor several PlantUML diagrams to inform separately about - the objects involved in the chain of responsibility pattern (overview and detailed) - the objects involved in the strategy pattern - the objects involved in the creation of the chain of responsibility - the sequence through the chain of responsibility (overview and detailed) - Add the rendered svg to the documentation
1 parent 02b37f3 commit 7d0f98a

24 files changed

+746
-667
lines changed

docs/articles/devs/architecture/ChainOfResponsibilityPattern.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ This article is about:
1313

1414
The Chain of Responsibility pattern is the central architectural feature of Hatch-Validator, implemented consistently across three major component types. This pattern enables extensible functionality by allowing new components to inherit and modify only the changed logic from previous versions, creating a maintainable and scalable system.
1515

16+
![Chain of Responsibility Pattern Overview](../../../resources/images/chain_of_responsibility_simplified.svg)
17+
18+
*The diagram above shows the simplified Chain of Responsibility pattern structure across all three component types: Validators, Package Accessors, and Registry Accessors.*
19+
1620
### Core Principles
1721

1822
**Delegation Over Inheritance**: Components delegate unchanged concerns to previous versions rather than using traditional class inheritance.
@@ -51,6 +55,10 @@ Validators delegate to the chain for validation concerns that remain unchanged:
5155
- **No new requirements**: No new validation requirements introduced
5256
- **Previous implementation sufficient**: Previous version's strategy meets current needs
5357

58+
![Chain Delegation Sequence](../../../resources/images/chain_of_responsibility_delegation_sequence.svg)
59+
60+
*The diagram above shows the detailed delegation flow through the validator chain, demonstrating how components check if they can handle a request and delegate to the next component when needed.*
61+
5462
## Universal Implementation Pattern
5563

5664
### Three Component Types
@@ -74,7 +82,7 @@ The Chain of Responsibility pattern is implemented identically across three comp
7482

7583
### Abstract Base Classes
7684

77-
All component types follow the same abstract base class pattern:
85+
All component types follow the same abstract base class pattern (replace `ComponentBase` with the actual base class name for each component type)
7886

7987
```python
8088
# Universal pattern implemented by all three component types
@@ -102,7 +110,7 @@ class ComponentBase(ABC):
102110

103111
### Factory Pattern Integration
104112

105-
All component types use identical factory patterns for chain construction:
113+
All component types use identical factory patterns for chain construction (replace `ComponentFactory` and `ComponentBase` with the actual factory and base class names for each component type)
106114

107115
```python
108116
# Universal factory pattern used by all three component types
@@ -254,6 +262,10 @@ components[1].set_next(components[2]) # v1.2.0 → v1.1.0
254262

255263
Validators implement the Strategy Pattern alongside Chain of Responsibility to encapsulate validation algorithms. This dual-pattern architecture provides fine-grained control over which validation concerns use strategy composition versus chain delegation.
256264

265+
![Strategy Pattern Implementation](../../../resources/images/strategy_pattern_focus.svg)
266+
267+
*The diagram above shows how validation strategies are organized and implemented within the validator architecture, demonstrating the interface hierarchy and concrete strategy implementations.*
268+
257269
### Strategy Interface Hierarchy
258270

259271
Located in `hatch_validator/core/validation_strategy.py`:

docs/articles/devs/architecture/ComponentTypes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ This article is about:
1111

1212
Hatch-Validator implements the Chain of Responsibility pattern across three distinct component types, each serving a specific purpose in the validation and data access ecosystem. These components work together to provide comprehensive, version-agnostic functionality for package management and validation.
1313

14+
![Component Architecture Overview](../../../resources/images/component_architecture_simplified.svg)
15+
16+
*The diagram above shows the three-component architecture with unified Chain of Responsibility patterns across Validators, Package Accessors, and Registry Accessors.*
17+
1418
## Validators
1519

1620
### Purpose and Scope
@@ -259,6 +263,10 @@ class DependencyValidation:
259263

260264
Factory classes coordinate component creation:
261265

266+
![Factory Pattern Implementation](../../../resources/images/factory_pattern_focus.svg)
267+
268+
*The diagram above shows how factory classes automatically discover components, handle version precedence, and build chains with proper linking across all three component types.*
269+
262270
```python
263271
# Coordinated factory usage
264272
def create_validation_system(metadata: Dict[str, Any], registry_data: Dict[str, Any]):

docs/articles/users/GettingStarted.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ The validator uses the Chain of Responsibility design pattern to handle differen
3434
3. Delegates requests through the chain
3535
4. Returns results using a consistent interface
3636

37+
![Version-Agnostic Access Flow](../../resources/images/version_agnostic_access_simplified.svg)
38+
39+
*The diagram above shows how client requests are handled through version-agnostic access, where factories create appropriate chains and components delegate to maintain consistent interfaces.*
40+
3741
## Basic Package Validation
3842

3943
### Simple Validation Example

docs/articles/users/data_access/VersionAgnosticAccess.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ The system automatically detects schema versions from metadata and creates appro
5454

5555
Each component in the chain implements version-specific logic while delegating unchanged concerns:
5656

57+
![Data Access Patterns](../../../resources/images/data_access_patterns_focus.svg)
58+
59+
*The diagram above shows how data access flows through the accessor chain, with each accessor handling its version-specific concerns and delegating unchanged operations to previous versions.*
60+
5761
**Package Accessors Example:**
5862
- **v1.2.1 Accessor**: Handles dual entry point metadata → delegates dependency access to v1.2.0
5963
- **v1.2.0 Accessor**: Handles unified dependency structure → delegates basic fields to v1.1.0

docs/articles/users/validation/PackageValidation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ The validation process follows these steps:
4141
4. **Validation Execution**: Execute validation through the chain with delegation
4242
5. **Result Aggregation**: Collect and return comprehensive validation results
4343

44+
The following diagram illustrates how the validation execution integrates both Chain of Responsibility (for delegation) and Strategy Pattern (for validation algorithms):
45+
46+
![Validation Execution Flow](../../../resources/images/validation_execution_focus.svg)
47+
48+
*The diagram above shows how validation requests flow through the validator chain, with validators using strategies for changed concerns and delegating unchanged concerns to previous versions.*
49+
4450
### Validation Categories
4551

4652
The validator performs comprehensive validation across multiple categories:
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@startuml Chain Delegation Focus
2+
!theme plain
3+
skinparam backgroundColor white
4+
skinparam participantBackgroundColor white
5+
skinparam participantBorderColor black
6+
skinparam arrowColor black
7+
8+
title Chain of Responsibility - Delegation Flow
9+
10+
participant "Client" as C
11+
participant "V1.2.1 Validator" as V121
12+
participant "V1.2.0 Validator" as V120
13+
participant "V1.1.0 Validator" as V110
14+
15+
== Validation Request ==
16+
C -> V121 : validate(v1.2.1_metadata)
17+
activate V121
18+
19+
note over V121 : **Can Handle Check**\nif schema_version == "1.2.1":\n return True
20+
21+
V121 -> V121 : validate_entry_points()\n[Strategy Pattern]
22+
V121 -> V121 : validate_tools()\n[Strategy Pattern]
23+
24+
note over V121 : **Delegation Decision**\nFor dependencies validation:\nDelegate to v1.2.0
25+
26+
V121 -> V120 : validate_dependencies(metadata)
27+
activate V120
28+
29+
note over V120 : **Can Handle Check**\nif schema_version in ["1.2.0", "1.2.1"]:\n return True
30+
31+
V120 -> V120 : validate_dependencies()\n[Strategy Pattern]
32+
33+
note over V120 : **Delegation Decision**\nFor schema validation:\nDelegate to v1.1.0
34+
35+
V120 -> V110 : validate_schema(metadata)
36+
activate V110
37+
38+
note over V110 : **Terminal Handler**\nImplements all base validation\nNo further delegation
39+
40+
V110 -> V110 : validate_schema()\n[Strategy Pattern]
41+
V110 --> V120 : schema_result
42+
deactivate V110
43+
44+
V120 --> V121 : dependency_result
45+
deactivate V120
46+
47+
V121 --> C : combined_result
48+
deactivate V121
49+
50+
== Alternative Flow: Direct Handling ==
51+
C -> V110 : validate(v1.1.0_metadata)
52+
activate V110
53+
54+
note over V110 : **Can Handle Check**\nif schema_version == "1.1.0":\n return True
55+
56+
V110 -> V110 : validate_all_concerns()\n[All Strategies]
57+
V110 --> C : complete_result
58+
deactivate V110
59+
60+
note over C, V110 : **Chain Benefits:**\n• **Automatic Routing**: Requests go to appropriate handler\n• **Code Reuse**: Unchanged logic is delegated\n• **Extensibility**: New versions extend without modification\n• **Fallback**: Older versions handle their specific cases
61+
62+
@enduml

0 commit comments

Comments
 (0)