Skip to main content
SS. M. Siam
work / lekhani
v0.3.0 · updated Oct 2026Production Grade

Lekhani

A cross-platform input engine in Rust, with native apps for Linux, Windows and Android.

ROLELead Systems DeveloperTIMELINE2025 – PresentTEAMSolo CreatorPLATFORMSLinux · Windows · AndroidSTACKRust · Slint · Kotlin · IBus
01/CORE PROBLEM & CONSTRAINTS

Bengali phonetics shouldn't drop frames or freeze UI threads

Bengali orthography consists of 50 letters, 11 vowel diacritics, and over 250 conjunct consonant ligatures (*যুক্তবর্ণ*). Most software keyboards run on heavy Electron/V8 runtimes or legacy C++ runtimes that allocate dynamic memory on every keystroke, introducing 8.6ms latency spikes and misparsing vowel-consonant order during fast typing.

Sub-1ms Hard Budget

Suggestions must render in under 1ms on the main UI thread before the user strikes the next key.

Deterministic Core

Identical romanized key sequences produce 100% byte-for-byte identical output across Linux, Windows, and Android.

Zero Allocations

Stack-allocated circular slice buffers eliminate hot-path allocator pressure and garbage collection jitter.

CHALLENGE:“Pick any function in the repository. I will explain why it exists and what breaks if one line changes.”
Audit GitHub
02 · TRY THE ENGINE

Interactive WebAssembly Transliteration Sandbox

WASM · LATENCY OPTIMIZED
PRESETS:
NATIVE SCRIPT OUTPUT
Unicode UTF-8
আমি বাংলায় গান গাই
N-GRAM RANKED CANDIDATESclick to select
processed in 0.38 ms · in your browser via WASM · desktop and Android run natively
03/SYSTEM ARCHITECTURE

Architecture

Shared logic lives in pure Rust crates with zero platform UI dependencies. Each client only implements a thin native interface layer.

Interactive Dataflow Architecture

Lekhani Zero-Allocation Pipeline

Follow raw hardware keystrokes through pure Rust crates to sub-millisecond IME commit

Pipeline Flow (Tap to inspect)Swipe →
STAGE 03 TELEMETRYBudget: 0.12 msHeap: Pre-allocated Node pool

AST Syllable Parser — Phonetic Conjunct Segmenter

Structures phoneme tokens into linguistic syllables, automatically applying Hasanta viramas (হসন্ত), vowel matras (া, ি, ী), and conjunct ligatures (ক্ষ, জ্ঞ, ঙ্গ).

Runtime Invariant:Enforces Unicode Bengali conjunct ligature order rules.
Deconstructs Bengali morphology into Onset-Nucleus-Coda phonological trees.
Automatic Virama placement rule engine conforming to Unicode 15.1 specifications.
Guarantees no invalid byte sequence can induce a Rust panic (verified via proptest).
Simulated Byte State0.12 ms P99
input_stream"khorgosh"
data_typeSyllableTree { onset, nucleus, coda }
stage_output
SyllableTree: [Onset: "খ", Core: "র", Coda: "গোশ"]
04/DESIGN TRADEOFFS

Key decisions & Trade-offs

Word-level vs Syllable-level Modeling

Trie-based full words vs context-free syllable parsing.
Approach:Chose syllable-level AST parsing with n-gram candidate ranking.
Trade-off Accepted:Slightly higher AST complexity, but handles rare names and dialectal compounds without bloating dictionary memory.

Deterministic Dictionary vs Probabilistic Intent

Autocorrect replacement vs ranked candidate suggestions.
Approach:Strictly separate: parser outputs exact phonetic transliteration as candidate #1; AI ranker offers contextual variations.
Trade-off Accepted:Never silently replaces a valid spelling variant with what a dictionary assumes.

Single Pure Rust Core vs Platform Native Rewrites

Rewrite in Kotlin (Android) and C++ (Linux) vs unified Rust engine.
Approach:Unified Rust core with thin FFI (C-ABI) and JNI bindings.
Trade-off Accepted:Requires cross-compiling with cargo-ndk, but delivers 100% bug and behavior parity across every device.
05/PERFORMANCE & BENCHMARKS

Testing and benchmarks

Same text corpus (100,000 sentences from Prothom Alo and Wikipedia), same machine (Fedora Linux, Intel Core i7).

METRICLEKHANI (RUST)AVRO PHONETICDELTA
Average Keystroke Latency0.42 ms8.60 ms20.5x faster
Correction Rate per 100 Words3.2 words18.5 words-79% corrections
Peak Memory Footprint14.8 MB62.1 MB76% leaner

Hot-Path Telemetry & Micro-Profiler

CPU call stack & sub-millisecond execution budget (0.42 ms total)

CPU STACK DEPTH (HOT PATH)Total Budget: 0.42 ms (100%)
Inspecting:engine::process_keystroke(core/engine.rs)
CPU Time: 86%Duration: ~0.36 ms
Reproduce:cargo bench --bench phonetic_comparison
06/ROADMAP & TRANSPARENCY

Status, honestly

Production Ready
  • Core phonetic parsing AST
  • IBus & Fcitx5 Linux daemons
  • Android Compose IME
  • Standalone crates on crates.io
Active Research
  • ~Neural next-word prediction
  • ~Local quantized ONNX inference
  • ~Slint Windows TSF IME provider
Architecture Roadmap
  • •macOS InputMethodKit backend
  • •Cloud-free personal dictionary sync
  • •Wayland text-input-v3 native bridge
NEXT PROJECT
Amader Batch: University Operating System →
→