Skip to content

Commit 2b2ed3a

Browse files
committed
arch md
1 parent 7a2b6e8 commit 2b2ed3a

1 file changed

Lines changed: 246 additions & 0 deletions

File tree

ARCHITECTURE.md

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,94 @@ rails_accessibility_testing/
7474
└── Doc Site # Static documentation site
7575
```
7676

77+
#### Visual Architecture Diagram
78+
79+
```mermaid
80+
graph TB
81+
subgraph "Rails Application"
82+
App[Your Rails App]
83+
Tests[System Tests/Specs]
84+
Views[Views & Partials]
85+
Routes[Routes & Controllers]
86+
end
87+
88+
subgraph "Rails Accessibility Testing Gem"
89+
Entry[Gem Entry Point]
90+
Railtie[Rails Integration Layer]
91+
92+
subgraph "Test Integration"
93+
RSpec[RSpec Integration]
94+
Minitest[Minitest Integration]
95+
AutoHook[Automatic Test Hooks]
96+
end
97+
98+
subgraph "Core Engine"
99+
RuleEngine[Rule Engine]
100+
Checks[11+ Accessibility Checks]
101+
Collector[Violation Collector]
102+
end
103+
104+
subgraph "Intelligence Layer"
105+
ViewDetector[View File Detector]
106+
PartialDetector[Partial Detection]
107+
ChangeDetector[Change Detector]
108+
Cache[Page Scanning Cache]
109+
end
110+
111+
subgraph "Configuration"
112+
YAMLConfig[YAML Config Loader]
113+
Profiles[Profile Manager]
114+
RubyConfig[Ruby Configuration]
115+
end
116+
117+
subgraph "Output & Reporting"
118+
ErrorBuilder[Error Message Builder]
119+
CLI[CLI Tool]
120+
Reports[Reports & Logs]
121+
end
122+
end
123+
124+
subgraph "Testing Tools"
125+
Capybara[Capybara]
126+
Selenium[Selenium WebDriver]
127+
AxeCore[axe-core Engine]
128+
end
129+
130+
Tests --> RSpec
131+
Tests --> Minitest
132+
RSpec --> AutoHook
133+
Minitest --> AutoHook
134+
App --> Railtie
135+
Entry --> Railtie
136+
137+
AutoHook --> Cache
138+
Cache --> ViewDetector
139+
ViewDetector --> ChangeDetector
140+
ChangeDetector --> RuleEngine
141+
RuleEngine --> YAMLConfig
142+
YAMLConfig --> Profiles
143+
RuleEngine --> Checks
144+
Checks --> Capybara
145+
Capybara --> Selenium
146+
Checks --> AxeCore
147+
Checks --> ViewDetector
148+
ViewDetector --> PartialDetector
149+
PartialDetector --> Views
150+
Checks --> Collector
151+
Collector --> ErrorBuilder
152+
ErrorBuilder --> Reports
153+
154+
CLI --> RuleEngine
155+
Routes --> ViewDetector
156+
157+
style Entry fill:#ff6b6b
158+
style RuleEngine fill:#4ecdc4
159+
style Checks fill:#45b7d1
160+
style ViewDetector fill:#96ceb4
161+
style ErrorBuilder fill:#ffeaa7
162+
style Cache fill:#a29bfe
163+
```
164+
77165
### Data Flow
78166

79167
```
@@ -99,6 +187,80 @@ Error Message Builder (with file paths)
99187
Test Failure / CLI Report
100188
```
101189

190+
#### Request Flow Sequence Diagram
191+
192+
```mermaid
193+
sequenceDiagram
194+
participant Dev as Developer
195+
participant Test as Test Suite
196+
participant Hook as Auto Hooks
197+
participant Cache as Scan Cache
198+
participant Detector as View Detector
199+
participant Change as Change Detector
200+
participant Engine as Rule Engine
201+
participant Checks as 11 Check Modules
202+
participant Capybara as Capybara/Browser
203+
participant Collector as Violation Collector
204+
participant Builder as Error Builder
205+
participant Report as Test Report
206+
207+
Dev->>Test: Run test suite
208+
Test->>Hook: Execute system test
209+
Hook->>Test: visit('/some/path')
210+
Test->>Capybara: Load page
211+
Capybara->>Test: Page loaded
212+
213+
rect rgb(200, 220, 250)
214+
Note over Hook,Cache: Performance Optimization
215+
Hook->>Cache: Check if page scanned
216+
alt Page already scanned
217+
Cache->>Hook: Skip (cached)
218+
else Not in cache
219+
Cache->>Detector: Continue with scan
220+
end
221+
end
222+
223+
rect rgb(220, 250, 220)
224+
Note over Detector,Change: Smart Detection
225+
Detector->>Change: Check for file changes
226+
Change->>Change: Analyze views/partials/assets
227+
alt No changes detected
228+
Change->>Hook: Skip scan (no changes)
229+
else Changes detected
230+
Change->>Engine: Proceed with checks
231+
end
232+
end
233+
234+
rect rgb(250, 220, 220)
235+
Note over Engine,Checks: Accessibility Checks
236+
Engine->>Checks: Run enabled checks
237+
loop For each check (11 total)
238+
Checks->>Capybara: Query DOM elements
239+
Capybara->>Checks: Return elements
240+
Checks->>Checks: Validate WCAG rules
241+
Checks->>Collector: Report violations
242+
end
243+
end
244+
245+
rect rgb(250, 240, 200)
246+
Note over Collector,Report: Error Reporting
247+
Collector->>Detector: Map violations to files
248+
Detector->>Detector: Find view files
249+
Detector->>Detector: Detect partials
250+
Detector->>Builder: Pass file locations
251+
Builder->>Builder: Format error messages
252+
Builder->>Report: Generate detailed report
253+
end
254+
255+
alt Violations found
256+
Report->>Test: Fail with detailed errors
257+
Test->>Dev: Show actionable errors
258+
else No violations
259+
Report->>Test: Pass
260+
Test->>Dev: ✓ Accessibility checks passed
261+
end
262+
```
263+
102264
### Rule Engine Design
103265

104266
The rule engine is the heart of the gem. It:
@@ -109,6 +271,43 @@ The rule engine is the heart of the gem. It:
109271
4. **Collects Violations**: Aggregates all violations before reporting
110272
5. **Formats Output**: Creates actionable error messages with precise file locations
111273

274+
#### Rule Engine Flow Diagram
275+
276+
```mermaid
277+
graph TB
278+
A[Rule Engine] --> B[Load Configuration]
279+
B --> C[Apply Profiles]
280+
C --> D[Filter Enabled Checks]
281+
D --> E[Execute Checks in Order]
282+
283+
E --> F1[Form Labels]
284+
E --> F2[Image Alt Text]
285+
E --> F3[Interactive Elements]
286+
E --> F4[Heading Hierarchy]
287+
E --> F5[Keyboard Access]
288+
E --> F6[ARIA Landmarks]
289+
E --> F7[Form Errors]
290+
E --> F8[Table Structure]
291+
E --> F9[Duplicate IDs]
292+
E --> F10[Skip Links]
293+
E --> F11[Color Contrast]
294+
295+
F1 --> G[Collect Violations]
296+
F2 --> G
297+
F3 --> G
298+
F4 --> G
299+
F5 --> G
300+
F6 --> G
301+
F7 --> G
302+
F8 --> G
303+
F9 --> G
304+
F10 --> G
305+
F11 --> G
306+
307+
style A fill:#4ecdc4
308+
style G fill:#ffeaa7
309+
```
310+
112311
### Check Definition Structure
113312

114313
Each check is a self-contained class that:
@@ -157,6 +356,24 @@ module AccessibilityHelper
157356
end
158357
```
159358

359+
#### View Detection Flow Diagram
360+
361+
```mermaid
362+
graph TB
363+
subgraph "View Detection System"
364+
A[Page URL] --> B[Route Recognition]
365+
B --> C{Exact Match?}
366+
C -->|Yes| D[Found View File]
367+
C -->|No| E[Fuzzy Matching]
368+
E --> F[Scan Controller Dir]
369+
F --> D
370+
D --> G[Scan for Partials]
371+
G --> H[Map Elements to Partials]
372+
end
373+
374+
style B fill:#96ceb4
375+
```
376+
160377
### Performance System (NEW in 1.5.0)
161378

162379
#### Page Scanning Cache
@@ -185,6 +402,35 @@ end
185402
- **Subsequent Runs**: Only tests changed files
186403
- **Force Option**: `TEST_ALL_PAGES=true` environment variable
187404

405+
#### Performance Optimization Flow
406+
407+
```mermaid
408+
graph TB
409+
A[Page Visit] --> B{In Page Cache?}
410+
B -->|Yes| C[Skip Scan]
411+
B -->|No| D{First Run?}
412+
D -->|Yes| E[Scan All Pages]
413+
D -->|No| F{Files Changed?}
414+
F -->|No| G[Skip Scan]
415+
F -->|Yes| H[Smart Scan]
416+
417+
H --> I{Which Files?}
418+
I -->|View| J[Scan This Page]
419+
I -->|Partial| K[Scan Pages Using Partial]
420+
I -->|Helper| L[Scan All Pages]
421+
I -->|Asset| M[Scan All Pages]
422+
423+
E --> N[Add to Cache]
424+
J --> N
425+
K --> N
426+
L --> N
427+
M --> N
428+
429+
style B fill:#a29bfe
430+
style F fill:#fdcb6e
431+
style N fill:#55efc4
432+
```
433+
188434
---
189435

190436
## Key Design Decisions

0 commit comments

Comments
 (0)