Building Zenis: A Masterclass in Human-AI Pairing
In the world of software development, new tools often promise to increase speed. But occasionally, a technology comes along that doesn't just make you faster—it changes how you think.
Over the past year, I’ve been engineering Zenis, an AI-driven Clinical Decision Support System (CDSS) and health analysis platform focused on Functional Medicine. What started as a single Python script aimed at automating lab and root-cause synthesis evolved into a full-stack Next.js and FastAPI platform powered by domain-grounded RAG pipelines.
But the real story isn't just about the code. It’s about the process. This R&D project served as my laboratory for testing a disciplined way of building software: Agentic Pairing.
The Evolution: From Monolithic Script to Decoupled Architecture
Every serious product starts by outgrowing its initial prototype:
- Phase 1 (Prototype): A Streamlit app—a single monolithic script (
main.py) handling PDF parsing, vector lookup, and UI rendering in one process. Quick to validate ideas, impossible to evolve cleanly. - Phase 2 (Zenis): A decoupled client-server architecture with a modular backend—Next.js (App Router) for the interactive clinical workspace, a modular FastAPI backend orchestrating clinical analysis and specialist pipelines, local FAISS vector indexing for low-latency protocol retrieval, and PostgreSQL (Supabase) for relational state.
Moving from Phase 1 to Phase 2 wasn't just a syntax port; it was a structural redesign, executed in tight architectural loops with an AI engineering partner.
The "Third Brain" in Architecture Decisions
As an engineer with ~20 years of experience in the enterprise .NET world, I carry strong instincts around structure and tooling. Entering the GenAI space, however, meant challenging reflexes that would have slowed down early validation.
1. Avoiding Premature Server-Side PDF Infrastructure in the MVP
In the earliest MVP phase, my enterprise reflex was to build a full server-side PDF typesetting pipeline before validating the clinical output itself.
My AI partner pushed back: "Compiling native binary dependencies like libcairo inside Docker containers before locking down the report schema adds unnecessary deployment friction. For the initial MVP, render structured Markdown in the UI first, validate the clinical layout, and introduce dedicated PDF export (pdf_service) only once the data contract stabilizes."
Result: We avoided premature container bloat during rapid iteration and only built dedicated PDF export once the clinical report schema was battle-tested.
2. The Cross-Lingual RAG Strategy
Initially, I considered translating all English functional medicine protocols into Turkish prior to indexing. Through architectural debate, we adopted Cross-Lingual RAG: "Keep the curated medical protocol knowledge base in its original clinical English to avoid pre-translation drift on medical terminology. Retrieve relevant protocol chunks semantically across languages, and enforce localized Turkish synthesis at the LLM generation layer." Result: We preserved clinical terminology fidelity in the source corpus while still delivering natural, localized Turkish insights at the presentation layer.
Technical Deep Dive: Multi-Layer Clinical Guardrails
In Functional Medicine, clinical context is everything. A naive RAG lookup might surface "Betaine HCl" for low stomach acid—without checking whether the patient's history indicates active gastritis.
Rather than trusting raw model weights alone, we implemented explicit System Instruction & Audit Guardrails:
- Strict constitutional rules inside the backend's
system_instructionsmodules define hard contraindication boundaries and evidence hierarchies. - A dedicated
audit_enginelayer evaluates generated syntheses for clinical consistency and grounding, ensuring that even if vector retrieval surfaces a broad protocol, safety constraints remain enforced at runtime.
Reflections on "Agentic" Development
Working with advanced coding agents like Antigravity isn't about copy-pasting boilerplate. It's about intent and boundary engineering:
- Level 1: Asking AI to write an isolated function.
- Level 2: Asking AI to refactor a module.
- Level 3 (Agentic): Debating architectural trade-offs, stress-testing retrieval thresholds (such as "What happens when the FAISS L2 distance exceeds
1.04and no protocol chunk is truly relevant?"), and designing deterministic guardrails around probabilistic models.
Zenis now runs live as an end-to-end R&D platform (zenis.kahraman.app), demonstrating how complex biomarker data and curated clinical protocols can be synthesized safely. Above all, it proved one core principle: the future of software engineering isn't doing less thinking—it's operating at higher architectural leverage.