qoyyid
Cloud OCR and transcription pipeline for classical Arabic books, turning scanned PDFs or audio into styled Word documents with real footnotes.
- Status
- Live
- Platform
- Web · Cloudflare Workers
- Built with
- TypeScript · Hono · SvelteKit
- OCR / ASR
- Mistral batch API
- Interface
- Arabic only, right-to-left
- Gate
- pnpm gate · quality-kit CI
- Harness
- Claude · Cursor · Antigravity CLI
- Started
- Jul 2026

Overview
Classical Arabic books layer main text (matn), commentary (sharh), marginal notes (hashiya), and footnotes. Qoyyid runs Mistral batch OCR, maps pages into typed blocks, and exports styled .docx files with native Word footnotes.
Audio transcription shares the same Cloudflare pipeline: Hono Worker, D1 for jobs and quotas, R2 for files, and a cron trigger polling batch status.
Stack
Backend
- Hono on Cloudflare Workers
- API, Google sign-in, admin tools, and cron polling for Mistral batch jobs.
- D1 + R2
- Jobs and quotas in D1; uploads, raw OCR, JSON, and .docx in R2 per job.
- Presigned R2 URLs
- Direct browser uploads for large PDFs without streaming through the Worker.
- docx
- Generates RTL Word files with native footnotes and per-layer styles.
Frontend
- SvelteKit + Skeleton
- Arabic-only RTL UI following a dedicated Arabic UX-writing guide.
- Turnstile + FCM
- Bot protection on sign-in and push alerts when batch jobs complete.
Quality
- quality-kit (js-ts)
- Biome, strict TypeScript, import-graph checks, and complexity ratchets.
- Vitest
- Unit and integration tests for mapping, .docx export, and Worker routes.
Engineering highlights
Separating main text from commentary by print density
Qoyyid maps Mistral's bounding boxes into headings, footnotes, and marginalia, then measures character density per box area across the book to distinguish larger-print matn from denser sharh.
Read the code:mistral-mapping.ts
Native Word footnotes without silent drops
Footnotes become native Word footnotes only when referenced on the same page (stripping per-page markers like (١)(٢) since Word renumbers globally); unreferenced notes fall back to end-of-page text so nothing disappears.
Read the code:docx-export.ts
Store raw OCR to rebuild without paying twice
Mistral's raw response is saved to R2 before mapping, letting admins re-run mapping and
.docxexport in place after parser fixes with zero extra API cost.Read the code:ADR 0001: reproduce in place
Deduplicate before charging quota
Uploads are SHA-256 hashed before quota checks, so re-uploading a previously processed book returns the existing job even at zero remaining quota.
Read the code:jobs.ts
Architecture
A job's life
- UploadPresigned upload to R2; SHA-256 deduplicate before quota check.
- SubmitSend to Mistral's batch OCR or transcription API.
- PollCron trigger advances batch jobs without webhooks.
- Store & mapPersist raw OCR in R2, then map into typed document blocks.
- ExportBuild styled .docx with footnotes and send a push alert.