MB
← All case studies
02Reliability engineering

A scraper that survives crashes, bans and 3 AM failures

Unattended lead-intelligence pipeline: per-source circuit breakers, a durable state machine with an audit trail, and hard daily budgets on every resource it touches.

PythonPlaywright (CDP)SQLite (WAL)PydanticpytestRich
Private – available on request for verified hiring partners

56

tests across 7 suites

13 · 28

states · guarded transitions

8

resource budgets, hard-capped daily

30 min

leases → automatic crash recovery

The problem

Job boards and data sources rate-limit and block scrapers within minutes, and a crashed run historically loses everything it discovered. Most pipelines are written as happy-path scripts: they work once, then die quietly at 3 AM with no record of what happened.

The brief was the opposite: something that runs unattended for hours, bends when a source fights back, never loses progress, and never surprises anyone with an API bill.

The approach

Every source gets its own circuit breaker

Each source runs behind a DB-persisted breaker with CLOSED / HALF_OPEN / OPEN states. Five consecutive failures trip it open with a source-specific cooldown (LinkedIn 8h, Wellfound 4h, WeWorkRemotely 2h, RSS 1h); after the cooldown a single half-open probe decides whether to resume.

A tripped source is skipped cleanly and the run continues — one banned platform can't take the pipeline down with it. If Chrome isn't available at all, discovery falls back to RSS-only rather than failing.

Progress is durable, auditable and recoverable

Every job lives in a SQLite state machine: 13 states, 28 allowed transitions, and invalid transitions rejected outright. Each transition writes an audit row (from → to, actor, error payload), so any lead's full history can be reconstructed after the fact.

Work is leased, not owned: entering PROCESSING stamps a 30-minute lease, a sweeper reclaims expired leases back to PENDING, retries back off at 1/5/15 minutes with jitter, and after three failures the job lands in a dead-letter queue with its error trace instead of vanishing.

  • WAL-mode SQLite with foreign keys on; thread-local connections
  • SHA-256 fingerprinting of domain+title so no listing is ever visited twice
  • Deterministic lead scoring: visa signal 40% · tech stack 35% · region 15%, with hard skip-signals that zero agency and internship leads

Spend sits behind hard caps

Eight resource types — LLM calls, SERP queries, browser sessions, HTTP requests and more — each have a daily budget enforced by atomic SQLite counters. Unknown resources are blocked by default. A live burn-down table shows exactly what's left today.

Anti-detection that borrows a real identity

Instead of launching a fresh headless browser (trivially detectable), the pipeline attaches to your real Chrome session over CDP — same cookies, same fingerprint, same history. On top of that, actions are paced with Gaussian human delays (µ=1.5s, σ=0.6, clamped 0.3–5.0s), slow-scroll simulation with randomized scroll amounts, DOM-settle waits and per-character typing.

Architecture

  RSS / LinkedIn / Wellfound / Indeed / WWR
        |
        v  discovery (Playwright via CDP) + per-source circuit breaker
        |
        v  scoring 40/35/15 + skip signals
        |
        v  budget guard (8 daily caps)
        |
        v  SQLite state machine (13 states · 28 edges · audit log · leases · retry 1/5/15 + DLQ)
        |
        v  Rich dashboard / JSON export

Discovery, scoring, durability and cost control are separate failure domains.

Outcomes

  • ✓Runs unattended for hours: a banned source is skipped, a dead browser degrades to RSS, a crash resumes from the last lease
  • ✓Zero-progress-loss recovery — everything is reconstructable from the audit log and dead-letter queue
  • ✓Predictable cost: hard daily ceilings replace surprise invoices
  • ✓Ranked, deduplicated, enriched leads instead of a raw dump: qualified leads flow to CV/CL stages with an approval gate
  • ✓56 tests across breakers, budgets, state machine, scoring and migrations — the reliability claims are executable

What I learned

  • →State machines with explicit transitions prevent data corruption and enable crash-resume — critical for long-running scrapers.
  • →Per-source circuit breakers, budgets, and retry backoff are essential for hostile targets; design for failure from day one.
  • →Evidence-driven correctness (tests + verifiable outputs) matters more than raw extraction speed.

Scope, honestly

The part most portfolios leave out. Here is exactly what is shipped today, and what is designed but not yet wired — read the repo and check me on it.

Shipped & verified

  • ·Circuit breakers, budget guards, durable state machine, leases, dead-letter queue — all tested
  • ·CDP attach with human-timing simulation and graceful RSS fallback
  • ·5 source scrapers, weighted scoring, SHA-256 dedup, Rich live dashboard
  • ·CI running the full pytest suite on Python 3.11; mypy strict + ruff configured

Designed · next

  • ·Viewport/user-agent rotation helpers exist in the anti-bot module but aren't wired into the current CDP flow
  • ·Adzuna is cataloged (budgets, cooldowns) but has no scraper connected yet
  • ·Export connectors (Sheets/Notion/webhooks) are roadmap, not shipped

Next case study

An audit platform built to sell engagements

03 →

Start a project

Have a system that should run itself?

Tell me what breaks today — the manual loop, the API bill, the scraper that dies overnight — and I'll tell you what I'd build, what it costs, and what I wouldn't bother automating.