Notes & writing

Technical notes, lessons learned and ideas from my projects.

Why Persian and Arabic text breaks in PDFs — and how to shape it correctly in Python

Disconnected letters, reversed sentences, Latin words in the wrong place: generating Persian or Arabic PDFs from Python fails in predictable ways. This is the shaping pipeline that fixes it.

Read Note →

Building a Persian-first desktop translator for PDF and EPUB books — chunking, rolling context, and a per-book structure template

Translating a 300-page book in a chat window fails in predictable ways: the model summarizes instead of translating, terminology drifts between chapters, running headers become translated garbage, and one crash loses an hour of work. This is a Windows desktop app that fixes each of those with local, readable code — paragraph-aware chunking, a rolling context tail, per-book structure templates, a DPAPI-encrypted key, and a job store that saves every finished page.

Read Note →

Shipping a counseling bot on Bale: GHQ-28 screening, self-learning matching and 12 conversation states

How a messenger bot can run a full clinical intake end to end — a 12-state conversation handler, the GHQ-28 wellbeing screen, a matching engine that re-weights itself from panel feedback, an availability crawler and a full admin panel inside the chat itself. Built on the Telegram-compatible Bale API.

Read Note →

Building an AI counseling widget that matches visitors to the right counselor — without a hosted LLM

A drop-in Persian RTL chat widget that runs a structured intake, administers the GHQ-28 wellbeing screen, extracts clinical concepts from free text and ranks counselors — with every clinic's own API key, admin panel and intake flow. No hosted model, no per-message cost, nothing leaving the server.

Read Note →

Why is my LLM stream empty? A field guide to broken SSE responses

Reasoning-only replies, missing finish_reason, malformed SSE frames — the four most common reasons a streaming LLM call returns nothing, and how to diagnose each one.

Read Note →