M1: scrape spine — renderer, extractor, orchestrator /scrape, compose, health, render cache

- renderer: Node/Playwright, single browser + pooled contexts with concurrency
  cap and FIFO queue, Redis render cache (graceful no-op without Redis)
- extractor: FastAPI + Trafilatura, HTML -> {title, text, metadata}
- orchestrator: /scrape (render -> extract) with per-stage trace, aggregated
  /health, structured JSON logging on all services
- docker-compose for orchestrator/renderer/extractor/redis with healthchecks

Verified locally: end-to-end scrape of example.com and Wikipedia; error paths
for unreachable hosts and bad schemes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
User 2026-07-05 22:02:38 -07:00
parent 55317f3f75
commit e2b329b2bb
20 changed files with 1534 additions and 0 deletions

51
docker-compose.yml Normal file
View file

@ -0,0 +1,51 @@
services:
orchestrator:
build: services/orchestrator
ports:
- "${ORCHESTRATOR_PORT:-8000}:8000"
environment:
RENDERER_URL: http://renderer:8002
EXTRACTOR_URL: http://extractor:8003
SEARCHER_URL: http://searcher:8001
depends_on:
- renderer
- extractor
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
interval: 30s
timeout: 5s
retries: 3
renderer:
build: services/renderer
environment:
REDIS_URL: redis://redis:6379
RENDER_CACHE_TTL: ${RENDER_CACHE_TTL:-3600}
RENDER_CONCURRENCY: ${RENDER_CONCURRENCY:-4}
RENDER_TIMEOUT_MS: ${RENDER_TIMEOUT_MS:-30000}
RENDER_WAIT_POLICY: ${RENDER_WAIT_POLICY:-networkidle}
depends_on:
- redis
init: true
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:8002/health').then(r=>{if(!r.ok)process.exit(1)})"]
interval: 30s
timeout: 5s
retries: 3
extractor:
build: services/extractor
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8003/health')"]
interval: 30s
timeout: 5s
retries: 3
redis:
image: redis:7-alpine
command: redis-server --maxmemory 512mb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 5s
retries: 3