cd /news/artificial-intelligence/building-ask-leya-lessons-learned-fr… · home topics artificial-intelligence article
[ARTICLE · art-123109] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

Building Ask Leya: Lessons Learned from Local ONNX Embeddings, Prisma Migrations, and Express Async Handlers

A developer detailed the architecture of Ask Leya, a chatbot that answers from a business's own content and hands off to a human when needed. The project uses local ONNX embeddings to avoid per-query costs and keep data on the server, but faces challenges such as cold starts and a 90-second production hang from a macOS binary. Other hurdles include managing a shared database with unreleased modules via Prisma and handling Express 4's lack of async rejection forwarding, which caused /chat to hang for 90 seconds per request.

read1 min views2 publishedSep 8, 2026

Why build another chat widget? Because every widget I tried either followed a rigid script or confidently made things up. Ask Leya answers from a business's own content and hands off to a human when it can't.

Here are three core architectural hurdles I ran into and how I solved them:

No translation step, no API call, no per-query embedding cost, and nothing leaves the server to be embedded. The chat model then only has to phrase the answer back in Arabic, which is the easy half.

The trade: A cold start while the model loads, and it pulls in sharp, which cost me a 90-second production hang when a macOS binary got rsynced onto a Linux box.

Managing a database shared with unreleased modules

The database is shared with the rest of my broader app under development — 67 tables total right now, many of which belong to unreleased modules. Since Prisma migrate tries to treat unreleased tables as drift, every migration currently requires hand-filtering additive statements via prisma migrate diff until the full suite ships.

Express 4 doesn't forward async rejections

An unguarded async handler that throws gives you no response at all — the caller just hangs until it times out. That took /chat down for 90 seconds a request before I tracked it down.

The Stack

Frontend: Next.js App Router, React (with a dependency-free vanilla JS iframe widget so it can't collide with customer CSS).

Backend: Node.js, Express.

Database: Postgres (Neon) + pgvector. Real-time & AI: Socket.IO for live human handoff, gpt-4o-mini via OpenRouter for replies.

Free tier, no credit card required. Features like WhatsApp, Instagram, and Messenger integrations are built out but kept behind the scenes until fully polished for self-serve.

── more in #artificial-intelligence 4 stories · sorted by recency
github.com · · #artificial-intelligence
BoardUI
── more on @ask leya 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-ask-leya-le…] indexed:0 read:1min 2026-09-08 ·