Skip to content

Architecture

crawlkit-core/ Core library: types, analyzers, storage, export, HTTP client
crawlkit/ CLI binary: clap-based argument parsing, progress display
crawlkit-api/ REST API: axum-based server with API key auth and rate limiting
URL Queue -> DNS Prefetch -> Fetcher -> Parser -> Analyzers -> Storage -> Export
^ |
+---- Link Discovery ---------+

Token-bucket per domain with a global bucket. Concurrency semaphore. Mutex guards are dropped before await points for async safety.

Three-state finite state machine: Closed -> Open -> HalfOpen. Configurable failure threshold, success threshold, and cooldown period. Per-domain fault isolation prevents cascading failures.

Bounded pipeline with configurable channel capacity. Semaphore-based concurrency control. Producers block when the bounded channel is full, preventing memory exhaustion under high concurrency.

28 analyzers dispatched in parallel. Each implements the Analyzer trait with analyze(&AnalysisContext, &CrawlConfig) -> Vec<Finding>.

Atomic metrics counters (AtomicU64) for pages crawled, bytes fetched, fetch time, analysis time, and throughput. Exported via --metrics-json.

Enforces configurable limits on memory (RSS), CPU, disk usage, and page count. Replaces ad-hoc RSS checking with structured threshold enforcement.

Per-domain fault isolation. Opens circuit after N consecutive failures, skips the domain until cooldown expires, then transitions to HalfOpen for a trial request.

Bounded mpsc channels with configurable capacity. Prevents memory explosion when producer rate exceeds consumer rate.

Seed-based reproducible crawls via --seed. Controls PRNG state for URL ordering, content hashing, and user-agent rotation. Identical seed + configuration yields identical output.

Runtime feature toggles via TOML [features] section. CLI flags (--enable-ai, --enable-wasm, --javascript) override configuration file values.

Heuristic SPA detection engine. Identifies React, Vue, Angular, Next.js, Nuxt, and SvelteKit pages by inspecting HTML markers and script patterns.

JavaScript rendering for pages identified by the JS render decision engine. Requires --javascript flag and a Playwright installation. Falls back to static HTML when unavailable.

Threshold-based monitoring. Evaluates crawl metrics against configured thresholds and triggers webhook notifications when exceeded.

AES-256-GCM encryption for stored crawl data. Key sourced from CRAWLKIT_ENCRYPTION_KEY environment variable, configuration file, or system keyring (priority order).

Component Synchronization Mechanism
RateLimiter DashMap (domain buckets), parking_lot::Mutex (global, dropped before await)
UrlQueue DashSet (dedup), parking_lot::Mutex (heap)
Storage rusqlite::Connection (single-writer, WAL mode)
Metrics AtomicU64 counters (lock-free)
AuditTrail parking_lot::RwLock<Vec<AuditEvent>>