Hey there, I'm—

Ayush Gurung.

AI Engineer. I design systems that make LLMs reliable, fast, and cheap to operate — not just functional.

FastAPI · LangChain · pgvector · Sentence-Transformers · Groq · Cloudflare Workers AI · Next.js 19 · Supabase · Docker

⚡ AI Engineer at Draft n Craft

What I Actually Build

The following isn't a list of technologies I've touched. It's a description of the production systems I've designed, the tradeoffs I weighed, and the engineering decisions behind each one.

🗃️

RAG Systems & Vector Search

I design end-to-end Retrieval-Augmented Generation pipelines — document ingestion with PyMuPDF, recursive overlap chunking, batch embedding via Sentence-Transformers, and ANN retrieval with pgvector. Every retrieval call is user-scoped at the DB layer, not just in application logic.

Multi-Layer Semantic Caching

Purpose-built three-tier caching: a Cloudflare Workers AI edge layer that intercepts queries before they reach the origin, a PostgreSQL PL/pgSQL cosine-similarity cache for semantically equivalent questions (≥ 0.85 threshold), and a POSIX-atomic flat-file cache on persistent volume to eliminate cold-start Supabase latency.

🔗

LLM Orchestration

LangChain chains wired to Groq (LLaMA 3.3 70B, Qwen 32B) for sub-second cloud inference and local Ollama for fully offline deployments. History-aware retrievers rephrase ambiguous follow-ups before similarity search — keeping coherence across long conversations without hallucinating context.

🌐

Edge-First Architecture

TypeScript Cloudflare Workers intercept every POST, generate 384-dim query embeddings with @cf/baai/bge-small-en-v1.5, and stream cached answers as ReadableStreams — identical to a live LLM response. Cache HIT responses never reach the FastAPI origin. Cloudflare KV holds session-list state with programmatic invalidation.

🔐

Auth & Data Isolation

Supabase HS256 JWTs verified per-request via a FastAPI HTTPBearer dependency. Both real and anonymous users receive a stable UUID sub claim — enforcing per-user data isolation uniformly at the vector-DB filter level and the session ownership check level.

🧱

Full-Stack AI Applications

Next.js 19 (React 19) frontends with GSAP scroll-driven animations and HTML5 Canvas AI-state indicators (Idle / Thinking / Streaming). Token-streaming via Fetch API reader.read() loops — a cache HIT and a live LLM response are transparent to the UI.

The Question I Always Ask First

Most engineers building with LLMs ask: "which model gives the best answer?" That's a valid question — but it's rarely the expensive one in production. The expensive questions are: how many API calls am I making that I didn't need to? How much latency is my architecture adding before a user sees a single token? What happens when the inference provider goes down?

That thinking is what led me to build a three-tier caching system where a semantically equivalent question — even rephrased — never hits an LLM twice. The edge layer intercepts the request, generates an embedding locally using Cloudflare Workers AI, performs a cosine-similarity lookup against a PostgreSQL semantic cache (pgvector, <=> operator, 0.85 threshold), and streams the cached answer back to the client — formatted identically to a live LLM stream so the frontend never has to know the difference.

That's not premature optimisation. That's the difference between a system that scales and one that runs up API bills doing redundant work.

I care equally about the parts users don't see: atomic file writes that can't corrupt mid-crash, JWT verification that scopes every DB query to the right UUID, retrieval filters that enforce data isolation at the pgvector layer rather than relying on application-level guards. The reliability of the system underneath determines the quality of the AI on top.

⚡ About Me

I'm Ayush Gurung — an AI Engineer who cares about the engineering underneath the model. The question that drives most of my work isn't "which LLM is smartest?" — it's "how do I make this reliable, fast, and cheap to operate at scale?"

My flagship project, bbygrl / thotqen , is a production-grade RAG system that lets users upload any PDF and have a context-aware, history-grounded conversation with it. It is not a demo — it ships with a three-tier caching strategy designed to eliminate redundant LLM calls entirely.

The first cache tier lives at the Cloudflare edge — a TypeScript Worker that intercepts every chat request, generates a 384-dimensional query embedding with Cloudflare Workers AI ( @cf/baai/bge-small-en-v1.5), and checks a PL/pgSQL cosine-similarity function in PostgreSQL for any semantically equivalent previous answer. A cache hit never reaches FastAPI — the cached answer is streamed back directly from the edge as a ReadableStream, indistinguishable to the client from a live LLM response.

The second tier is a flat-file read cache on HuggingFace Space's persistent /data volume. Every session's message list is serialised as a single JSON file using POSIX-atomic writes ( NamedTemporaryFile + os.replace). Chat-switch reads cost zero Supabase round-trips.

Inside the FastAPI backend, the LangChain RAG chain uses create_history_aware_retriever to rephrase ambiguous follow-up questions into standalone queries before retrieval — meaning the bot stays coherent across a long conversation without leaking one user's document context into another's (per-user pgvector filter enforced at the DB layer). The LLM itself is selectable at runtime — Groq's LLaMA 3.3 70B or Qwen 32B for low-latency cloud inference, or a local Ollama model for completely offline use.

Auth is handled by verifying Supabase HS256 JWTs on every request — both authenticated and anonymous users receive a stable UUID sub claim, so the data isolation model is uniform. Uploaded PDFs are streamed directly to Cloudflare R2 before text extraction, meaning the origin file is always retrievable from the edge.

I build the frontend with the same level of care — the landing page uses GSAP and HTML5 Canvas Canvas animations that reflect the AI's real-time state (Idle / Thinking / Streaming). The application workspace streams LLM tokens character-by-character using the Fetch API reader.read() loop, making a cached response and a live response indistinguishable from the user's perspective.

Ayush Gurung — AI Engineer

Technical Depth

AI / RAGLangChain · pgvector · Sentence-Transformers · Groq API · Ollama · PyMuPDF
BackendFastAPI · Uvicorn · psycopg3 · Python · Pydantic v2 · python-jose
Edge / InfraCloudflare Workers · Workers AI · Cloudflare KV · Cloudflare R2 · Docker · HuggingFace Spaces
DataPostgreSQL · Supabase · pgvector ANN · Semantic Cache · POSIX flat-file cache
FrontendNext.js 19 · React 19 · TypeScript · GSAP · Canvas API · Tailwind CSS

Production Systems.

High-performance RAG pipelines, edge-cached AI gateways, and full-stack orchestration. Here is what I have built.

Explore all systems →
 

Engineering Notes

View all notes →

Keep in Touch

Currently building and scaling Production AI Systems & MLOps.

Feel free to get in touch to talk about edge gateways, RAG pipelines, or full-stack engineering.