Architecture
# Architecture Overview
spell_check is designed for high performance and strict safety.
# Core Components
# Engine
The Engine is responsible for orchestrating the scanning process.
- Walker: Uses the
ignorecrate to efficiently traverse the file system while respecting.gitignoreand.spellcheckignorefiles. - Concurrency: Leverages
tokio::task::JoinSetto parallelize file scanning. It maintains a pool of up to 20 concurrent tasks to balance speed and system resources. - Word Extraction: Uses a custom iterator to identify potential words, handling apostrophes (e.g., “don’t”) while ignoring alphanumeric strings that aren’t words.
# Dictionary
The Dictionary provides O(1) lookups using a HashSet.
- Pre-loading: The embedded dictionary is loaded into memory at startup.
- Case Insensitivity: All words are normalized to lowercase during loading and lookup.
# Configuration
Uses serde and toml for robust schema validation and easy extensibility.
# Memory Safety
- Zero Unsafe: The codebase contains no
unsafeblocks. - Safe Concurrency: Uses
Arcfor thread-safe sharing of dictionaries and configurations across tasks. - Error Handling: Uses
anyhowfor rich, context-aware error reporting instead of crashing.
# Concurrency Model
graph TD
CLI[CLI] -->|Start| Engine
Engine -->|Walk| FS[File System]
FS -->|File Path| TaskPool[JoinSet Task Pool]
TaskPool -->|Async Read| File[File Content]
File -->|Extract| Words[Words]
Words -->|Lookup| Dict[Dictionary]
Dict -->|Result| CLI