ka2
An autonomous AI agent that maps the Quebec web into a living knowledge graph.
ka2 is the light edition of Groupe KA's twin-bot engine — a scraper + AI search bot whose real-time dashboard and structured directory run live at www.ka2.bot.
800
Pages crawled per day
6
Pages scraped concurrently
120
Max pages per run
3
Directory views (cards, table, graph)
0.6 s
Delay between requests
98.1%
Python codebase
Overview
ka2 is a scraper and AI-driven search bot that charts the Quebec web as a knowledge graph: entities — companies, organizations, people, creators/influencers, agencies, brands — with their attributes and typed relations such as WORKS_AT, FOUNDER_OF, REPRESENTED_BY, COLLABORATES_WITH, and SPONSORED_BY, each carrying a role and provenance. It is the light, economical edition of Groupe KA, which operates three twin bots sharing the same engine: ka2 at 800 pages per day, ka4 at 3,000, and ka6 at 9,000. This repository is ka2, in its signature lime-green theme.
A Claude Haiku 4.5 agent plans missions from the dashboard and drives the pipeline through tools — search_web, map_site, scrape_page, deep_dive, and crawl_queue. Pages are fetched by Firecrawl with Scrapfly as an anti-bot fallback, at 6 concurrent pages with a 0.6-second delay, robots.txt respected, fail-fast timeouts, per-URL retries with a dead-letter queue, and a per-domain circuit breaker after 4 failures. A Haiku extractor then turns page markdown into entities and typed relations, deduplicated by normalized name, domain, and canonical Quebec region before landing in SQLite (WAL) with full provenance.
The codebase is 98.1% Python, served by a FastAPI application: a real-time SSE dashboard with KPIs, activity feed, live settings, and mission controls, plus a structured directory offering three views — cards, sortable table, and a force-directed global graph with pan/zoom — behind type/sector/region facets, search, and CSV/JSON export. A one-command deploy script targets MacLustr cluster node M4M36, creating three resilient launchd services (com.ka2.web, com.ka2.bot, com.ka2.ngrok) that expose the app on port 8799 through an ngrok tunnel at www.ka2.bot. Public data only, aligned with Quebec's Law 25 and PIPEDA.
Key Features
Typed knowledge graph
Normalized entities linked by typed relations — WORKS_AT, FOUNDER_OF, SPONSORED_BY, PARTNER_OF and more — each with a role, source, and confidence score.
Rigorous agent loop
Claude Haiku 4.5 plans, discovers, collects, and verifies through dedicated tools, with automatic context compaction for long-running missions.
Resilient crawling
Firecrawl as primary fetcher with Scrapfly anti-bot fallback, fail-fast timeouts, dead-letter retries per URL, and a per-domain circuit breaker after 4 failures.
Structured directory
Three explorer views — cards, sortable table, and a force-directed global graph with pan/zoom — with type/sector/region facets, search, and CSV/JSON export.
Real-time dashboard
SSE-driven KPIs, live activity feed, on-the-fly settings, and mission controls to prioritize, stop, or delete crawls — all in the lime-green ka2 theme.
Compliance by design
Public data only, robots.txt respected, rate limiting enforced, and usage framed by Quebec's Law 25 and PIPEDA — no private-person profiling.
How It Works
Mission planning
Missions are queued from the dashboard; the Claude Haiku 4.5 agent plans, searches, and deep-dives, driving the whole pipeline through its tool set.
Crawling
Firecrawl fetches pages — Scrapfly steps in against anti-bot walls — at 6 concurrent pages with robots.txt compliance, rate limiting, retries, and a per-domain circuit breaker, returning clean markdown.
Extraction
The Haiku extractor converts each page's markdown into a graph fragment of entities and typed relations, complete with roles, attributes, and confidence.
Entity resolution
Entities are deduplicated by normalized name, domain, and canonical Quebec region, then persisted with provenance to SQLite in WAL mode alongside social links, sources, and mentions.
Live delivery
FastAPI streams stats and events over SSE to the real-time dashboard and serves the structured directory — cards, sortable table, and global force-directed graph — with filtered CSV/JSON export.
Tech Stack
AI & Scraping
Backend & Data
Deployment
Highlights
- Light edition of Groupe KA's three twin bots sharing one engine: ka2 at 800 pages/day, ka4 at 3,000, and ka6 at 9,000.
- Claude Haiku 4.5 powers both the mission-planning agent and the graph extractor.
- Crawls 6 pages in parallel with an aggressive frontier that auto-queues 12-16 discovered links per page.
- A per-domain circuit breaker trips after 4 failures, and each URL gets 2 attempts before landing in the dead-letter queue.
- The creator/influencer model captures handle, platform, per-platform follower counts, niche, and languages.
- One-command deploy to MacLustr node M4M36 creates three resilient launchd services behind an ngrok tunnel at www.ka2.bot.
Explore ka2
Mapping the Quebec web as a knowledge graph — the full source is on GitHub.