YCMJason's Diary πβ¨
This web app is inspired by Tom Riddle's Diary. I've literally enchanted this website with a piece of my soul πͺπ€. So go ahead, talk to it, and learn more about me!
π YCMJason's Diary πβ¨
π GitHub Repo
Here are some quick write up on some of the challenges I faced in this project.
This project had two major challenges:
- Recognizing handwriting βοΈ
- Running an LLM for free πΈ
Recognizing Handwriting βοΈ
A Tom Riddle Diary wannabe that only accepts keyboard input? Absolutely unacceptable! π€ So I set out to implement handwriting recognition on a canvas.
The Journey:
-
Tesseract.js π€
- Great for printed text β
- Absolute trash for handwriting β
-
Transformers.js by π€ Hugging Face
- Looked promising...
- Required users to download huge models (~30s load time π)
- Recognition results? Not even close! β
-
The Breakthrough: Handwriting.js π
- BOOM! Found this hidden gem: handwriting.js π
-
How does it work? π€― It reverse-engineers Google's IME by sending stroke data to Google's API:
π
https://www.google.com/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8
- Results are blazingly fast β‘ and super accurate π―!
π¨βπ§ But the project was 5 years old and looked like it was built in 2003... π¬ So I stole borrowed the core logic and rewrote it in modern JavaScript! Might publish it on JSR later if thereβs demand! π Let me know if you're interested! π¬
Running an LLM for Free πΈ
For the LLM, I remembered this awesome project: mlc-webllm, which runs models directly on your device! π₯
The Journey:
-
MLC-WebLLM β
- Model download time: π¦ 30+ seconds (Users will leave after 5 seconds, let's be real π )
- Inference speed:
- M1 Max MacBook: 5 seconds β³
- Pixel 9 Pro Fold: 30+ seconds π¨
- Turns out, my system prompt was the culprit! π± Longer prompts slow down inference a lot.
-
Transformers.js β
- Even slower than MLC-WebLLM π
- Downloads the model in a single request without batching (or so it seems π€)
-
The Breakthrough: OpenRouter + Vercel AI SDK π―
- Found a GitHub list of free LLM APIs π
- Settled on OpenRouter and paired it with Vercelβs AI SDK
- Final result? Super smooth UX & fast responses! π
π The dev experience? Absolute chef's kiss π¨βπ³π. Huge thanks to Vercel & OpenRouter! π
Final Thoughts π§
If this app doesnβt go viral, Iβll be sad. π’ So please, go have fun with it! π
Top comments (0)