Systems architecture for AI products and the infrastructure underneath them.
I build support and RAG platforms, construction-ops systems, and context-slim, a cache-aware controller that stops LLM agent loops from paying for context management they didn't need.
Selected work
Three systems, one belief
A cost model, a support platform, and a project operating system — each one exists because the honest answer to “can AI just do this?” is “yes, with a human confirming the parts that matter.”
context-slim
A cost-aware controller for LLM agent context — pure Python, zero VRAM, sub-5ms.
Python 3.9+Zero depsblake2b block dedupeOpenAI + Anthropic wire adapters- cache hit, unpruned
- 92.2%
- cost delta, naive pruning
- +33–59%
context-slim
A cost-aware controller for LLM agent context — pure Python, zero VRAM, sub-5ms.
- cache hit, unpruned
- 92.2%
- cost delta, naive pruning
- +33–59%
Problem
Prompt caches are prefix caches: an un-pruned agent loop is append-only, so the whole prompt stays reusable. Naive compaction breaks that prefix — and the re-write can cost more than the tokens it removes. Most context-management tools assume trimming is free. It isn't.
Solution
context-slim is a decision layer, not a summarizer. doctor() finds cache pathologies (lookback overruns, missing breakpoints) before they cost you silently. plan()/apply() compute whether a prune is even profitable — comparing the rewrite cost against the cache savings over a horizon — before touching a single message. "Don't prune" is a first-class, inspectable outcome, not a fallback.
Sole author — built in public over 14 days, benchmarked against a live API.
GitHubTelely
Docs-powered AI support for solo developers — chat widget, RAG, human escalation via Telegram.
NestJSPrismaFastAPIpgvector- services
- 4
- integration edges
- 3, one-directional
Telely
Docs-powered AI support for solo developers — chat widget, RAG, human escalation via Telegram.
- services
- 4
- integration edges
- 3, one-directional
Problem
Solo founders can't staff a support inbox, but a pure AI bot that hallucinates or stonewalls a frustrated visitor is worse than no bot at all. The gap is a system that answers confidently from the founder's own docs and knows exactly when to hand off to a human, on the founder's phone.
Solution
A four-service architecture with one integration rule (widget → core only, dashboard → core only, core → ai only): a Preact embed widget, a NestJS + Prisma core that's the system of record, a FastAPI service doing RAG ingest/retrieval over Postgres + pgvector, and a Next.js founder dashboard. Escalation triggers on low grounding confidence or an explicit request for a human, routed to Telegram so the founder can reply from anywhere.
Architecture, backend (core + ai), and the escalation/notification pipeline.
GitHubYeksaz
A localized project operating system for construction — from site reports to an AI employer assistant.
Localized UIVoice transcriptionRAG over project memoryWallet/ledger engine- human-in-the-loop gates
- every write
- assistant surfaces
- 2 (owner + team)
Yeksaz
A localized project operating system for construction — from site reports to an AI employer assistant.
- human-in-the-loop gates
- every write
- assistant surfaces
- 2 (owner + team)
Problem
Construction projects fail quietly: decisions live in phone calls, voice notes, and WhatsApp threads instead of one record. The project owner is paying for everything but learns about problems last, and Tuesday's decision gets silently overwritten by Thursday's group chat.
Solution
Yeksaz holds the whole project — team, tasks by phase/operation, meetings, daily site reports, warehouse and procurement, the money ledger, and plan uploads — as one searchable record. On top of that sits an Employer Assistant that orients, surfaces decision cards, and drafts actions in the team's own language, and an Agent Hub the wider team can talk to in natural language. Both are built around one non-negotiable: nothing sends, pays, or commits without an explicit human confirmation.
Product and systems architecture for the Employer Assistant and Agent Hub confirm-before-commit pattern.
Private — no public repoExperience
Where the systems thinking comes from
Founding Engineer · Raw
A health and nutrition tracking platform with intelligent personalization — a React Native (Expo) app on the front end, backed by a food-recommendation and dietary-insight system on the back end.
- —React Native + Expo app with real-time health-metric visualization and camera-based food analysis
- —Dynamic food recommendation system adapting to individual health profiles
- —RAG-based retrieval for personalized dietary insights, plus NLP for automated food analysis
- —Phone-verified auth and an adaptive learning system for surfacing health patterns
Dec 2024 – Aug 2025United StatesFrontend Developer · micro1
3.5 years at a fast-growing AI company, across five high-impact projects — React.js front-end work applying generative AI, AWS, and adaptive-learning technologies.
Jun 2021 – Jan 2025United StatesFull-Stack Developer · Megastudio
A full-stack yoga and Lagree app (Tailwind, Express, MongoDB, TypeScript) with a multi-role panel system for admins, users, and coaches, a secure payment module, and an internal gamification feature.
Apr 2024 – Aug 2024Frontend Developer · Maven: The Serendipity Network
Feb 2023 – Sep 2023United StatesReact Developer · Udefy
Aug 2022 – Mar 2023React / Django Developer · Stock Sniper Trading Corp
Nov 2021 – Dec 2021Canada
Open-source infrastructure · flagship
context-slim: is pruning even worth it?
Measured against a live API, n=5 arms per condition, bootstrap 95% confidence intervals. Prompt caches are prefix caches — an un-pruned agent loop is append-only, so the whole prompt stays reusable. Pruning breaks that prefix, and the re-write can cost more than the tokens it removes.
pip install git+https://github.com/Ramtin2000/context-slimfrom context_slim import doctor, plan, apply
# 1. Find cache pathologies that cost money silently.
for d in doctor(messages, model="openai/gpt-5.6-luna"):
print(d.code, d.message)
# 2. Decide what is worth pruning. Pure — no I/O, no mutation.
p = plan(messages, model="openai/gpt-5.6-luna", horizon=30)
for v in p.verdicts:
print(v.decision.value, v.reason)
# 3. Execute only the approved edits.
messages, report = apply(messages, p)
print(report)Zero runtime dependencies. No model, no GPU, no network. Python 3.9+. Not on PyPI yet — install from source.
| Strategy | Tokens sent | Cache hit | Cost / arm | vs. no pruning |
|---|---|---|---|---|
| don't prune | 928,400 | 92.2% | $0.007053 | — |
| prune oldest-first | 735,790 | 75.5% | $0.011239 | +59.4% |
| prune newest-first | 735,770 | 81% | $0.009376 | +32.9% |
Cache hit rate by turn
Why the dedupe is built the way it is
A byte-level rolling hash is one interpreter iteration per byte in pure Python. str.split + blake2b does the same job at block granularity with both halves running in C — measured on ~93 KB.
- rejected: 64-byte rolling hash (per-byte Python loop)25.26ms
- shipped: str.split + blake2b (per-block loop)0.24ms
- shipped: full dedupe_blocks pass0.54ms
- shipped: collapse_whitespace1.06ms
104× faster on the hashing step. The rejected implementation ships in the repo so the comparison is measured, not asserted.
The cost model is checkable
This predicts how much of a request the API will report as cached before the call, then diffs against usage.prompt_tokens_details. Measured over 24 live requests.
| Metric | Raw | Calibrated |
|---|---|---|
| prompt-token error (median) | 26.11% | 0.64% |
| cached-token error (median) | 25.80% | 0.84% |
No dollar figure in the repo comes from the estimator — those all read the provider's usage counters.
Caveat this properly
- 8k-token prefixes, 20-turn loops, synthetic conversations — one model (gpt-5.6-luna), one account.
- Larger contexts over longer horizons are untested and may behave differently.
- Three earlier revisions of this experiment produced confident numbers that turned out to be artifacts — see METHODS.md for what went wrong and how it was caught.
Field notes
What the benchmarking turned up
Written up in the repo itself, not a separate CMS — these link straight to the source.
Pruning your agent's context can cost more than leaving it alone
Prompt caches are prefix caches. An un-pruned loop is append-only and fully reusable — breaking that prefix to save tokens can cost 33–59% more than doing nothing, measured against a live API with bootstrapped confidence intervals.
README.mdA byte-level rolling hash doesn't fit a 5ms budget
The textbook dedupe approach is a per-byte rolling hash — one interpreter iteration per byte in pure Python. Swapping to str.split + blake2b at block granularity runs both halves in C: 104× faster on the hashing step alone.
README.mdThree confident benchmark revisions, all wrong
Trusting an estimator instead of the provider's own usage counters produced clean, believable numbers that were measurement artifacts — three times. What it took to catch that, and why no dollar figure in context-slim comes from the estimator anymore.
METHODS.md