~/sajid.dev/work/tenure
back to work
case study · 2026

Tenure

AI Knowledge Engine

year
2026
role
solo
duration
9+ months
status
in-progress
stack
15 tech
modules
4
Tenure
The Brief

A vague mandate — "make our internal corpus feel like sitting with an expert" — turned into a working AI knowledge engine in production, built end-to-end by a single engineer. Hand the system any document corpus (12+ formats, plus IMAP / Gmail / Outlook / Dropbox sync) and it serves back persona-controlled answers grounded in that material.

The architectural bet that paid off: relevance logic lives in one isolated pod, so the orchestration layer has zero knowledge of scoring. Swapping ranking strategies doesn't touch the API. The result is a ~330K-LOC codebase that has stayed shippable across nine cycles of scope expansion — with hybrid BM25 + vector + reciprocal rank fusion behind a clean external API, voice interaction (STT + TTS), pluggable personas with per-conversation locking, and audit logging on every domain event.

Engagement is private. Sole engineer. Architecture, implementation, infrastructure, ops — alone.

Stack
TypeScriptPythonNestJSNext.jsReactTailwindPrismaPostgreSQLOpenSearchAWS LambdaAWS Step FunctionsAWS S3AWS FargateDockerTurborepo
Sub-modules

The pieces that make the whole.

API Orchestrator (NestJS)

The single brain. 12 modules (auth, ingestion, conversation, persona, course, email, cloud-storage, voice, audit, api-key, inspect, v1). Owns Step Functions invocation, S3 lifecycle, pod HTTP clients, and the public v1 API. Knows nothing about how relevance is scored — that's a pod's job.

Retrieval Pod (Hybrid BM25 + kNN + RRF)

OpenSearch behind a thin Python service. BM25 for lexical, kNN for semantic, Reciprocal Rank Fusion to combine them, neighbor expansion for surrounding chunks. Deterministic dedup via sha256(courseId:content). All ranking strategy lives here, so the rest of the system stays stupid about scoring.

Ingestion Pipeline (Step Functions + Lambdas)

5 esbuild-bundled task handlers chained by AWS Step Functions: parse → chunk → embed → index → finalize. Format validation at the boundary, before anything hits the database. PyMuPDF + Tesseract OCR for the formats most pipelines pretend don't exist (scanned PDFs, mixed layouts, multi-column docs).

Email & Cloud Ingestion

IMAP, Gmail, Outlook, Dropbox. Recursive folder walking, MIME negotiation with HTML-first preference, dedup, full-sweep deletion that keeps S3 + OpenSearch + Postgres in sync. The unglamorous half of any real RAG product, built once, correctly.