This article discusses the architectural and design decisions behind building an automated accessibility checker, specifically for validating alt text quality. It highlights the challenges of automating qualitative checks, the trade-offs between false positives and reliability, and how to integrate AI models while managing privacy, cost, and consistency. The discussion on deterministic rules versus AI-driven heuristics, and the handling of data flow, is particularly relevant to system design.
Read original on GitHub EngineeringAutomating the quality assessment of something subjective, like alt text, presents a significant system design challenge. While simply checking for the *presence* of an `alt` attribute is trivial, determining if the text is *useful* or *accurate* requires more sophisticated logic. The core design philosophy here is to distinguish between what can be proven deterministically and what can only be suspected or inferred, often requiring human-like judgment or contextual understanding.
The checker employs a two-tiered approach to alt text validation. The first tier consists of deterministic rules that run by default, are cheap, predictable, and don't require external calls. These rules target objective flaws in alt text strings themselves, without needing image content or page context. Examples include checking for absent/whitespace-only alt text, raw filenames, placeholders (e.g., "TODO"), generic words ("image", "logo"), or repeated alt text on adjacent images.
Design Principle: Reliability over Completeness
A key design decision was to prioritize reliability and low false positives over catching every possible issue. A checker that frequently flags correct content will be disabled by users. This means deliberately missing some bad alt text to ensure the rules that *are* enabled provide high-confidence findings. This trade-off is crucial in any automated quality gate.
For subjective quality checks that require understanding the image content and surrounding page context, an opt-in AI vision model is utilized. This model receives the image, its alt text, and relevant page context (headings, page title, captions, nearby prose, link status). The system design for integrating this model addresses several critical aspects:
A notable architectural choice was realizing that detecting repeated alt text isn't a DOM traversal problem but a layout problem. Simply checking `img` tags in document order can lead to false positives if images are far apart visually but close in the markup. The solution involves checking the bounding boxes of images on the screen and only flagging repetitions where images are visually close (gap between bounding boxes is small relative to image dimensions), demonstrating a design focus on user experience over raw data representation.