← Work

2023 - August 2024 · Co-founder · Healthcare AI · Past project

HEKADES

Hekim Karar Destek - AI-powered clinical decision support

Under the hood
HEKADESWatch the demonstration on YouTube

HEKADES started with a conversation with professors from the University of Health Sciences (SBÜ). They told us that newly graduated doctors were increasingly turning to ChatGPT for clinical questions.

This was back when ChatGPT couldn’t even browse the internet. It could produce convincing answers, but there was often no reliable way to verify where the information came from, and hallucinations were a serious concern. That’s a particularly dangerous combination in healthcare.

We wanted to bring structure and verifiability to AI-generated medical answers.

HEKADES was designed to research trusted medical literature based on a patient’s clinical situation, retrieve relevant information, and provide doctors with answers grounded in identifiable sources.

HEKADES diagram showing a question, guideline and literature databases, a retrieval model, and sourced answer and summary outputs.
HEKADES system architecture. Original diagram in Turkish. Open full-size diagram

Building HEKADES

We were working at a time when retrieval-augmented generation (RAG) was rapidly evolving. A considerable part of our work involved following new research papers, experimenting with retrieval algorithms, and figuring out how to apply those ideas to clinical literature.

The challenge wasn’t simply getting an LLM to produce a plausible answer. It was making the underlying research process more structured, traceable, and useful to medical professionals.

We developed HEKADES with input from medical professionals through KWORKS, Koç University’s entrepreneurship center, and presented it to healthcare organizations and potential investors.

Ultimately, licensing restrictions around medical guidelines prevented us from bringing the product to market.

HEKADES was my first experience working so closely with emerging AI research while confronting the practical constraints of a high-stakes domain.

Inside the HEKADES demo

These screenshots show how HEKADES handled general and patient-specific questions, made its sources available, and flagged when a case needed more context.

Turkish-language demo

HEKADES was designed for deployment only in Turkey, so the demo is in Turkish. Sorry to non-Turkish speakers - an English version of the demo isn't available.

General medical questions

HEKADES let clinicians ask general medical questions, such as how basal insulin is planned for type 1 diabetes. In this example, it returned a written answer with numbered citations beside its claims, so readers could inspect the material behind the response.

HEKADES demo showing a general question about type 1 diabetes and an answer with numbered source citations.
A general question and its cited answer in the Turkish demo. Open full-size screenshot

Inspect the sources

Selecting a citation opened the referenced guideline in a document viewer, where the relevant page could be read directly. For the same question, HEKADES also presented a PubMed summary with links to the research it drew on.

A page from a Turkish diabetes guideline opened in HEKADES's document viewer.
The cited guideline opened from the answer. Open full-size screenshot
HEKADES PubMed summary with structured findings and links to research papers.
A separate research summary with linked PubMed results. Open full-size screenshot

Questions about a patient

HEKADES also supported questions about a particular patient. In the example shown here, a question about an older person with type 2 diabetes and several other conditions produced a structured assessment. It gathered the stated conditions and noted which clinical details were missing before discussing treatment principles.

HEKADES patient-specific question followed by a structured assessment of diagnoses, comorbidities, and missing clinical details.
A patient-specific question and its structured assessment. Open full-size screenshot

Confidence index

The patient-specific response also included a confidence index. It reads 26% in this example because the question leaves out relevant patient information. The low value was a cue to supply more context and review the answer carefully; it did not represent the probability that the answer was medically correct.

HEKADES interface showing a 26 percent confidence index beneath a case response.
The low confidence index shown for an incomplete case question. Open full-size screenshot

Under the hood

Backend & AI architecture · Python, FastAPI, AWS EC2, Weaviate Cloud

I was responsible for HEKADES’s entire backend: the API and application logic, infrastructure, document-processing pipeline, retrieval architecture, and LLM orchestration. The interesting part wasn’t just getting a language model to answer medical questions. It was figuring out how to find the right source material and make the steps between a question and an answer understandable.

Architecture at a glance

HEKADES ran as a Python monolith on an AWS EC2 instance. FastAPI served the application over HTTP and WebSockets, while the same backend coordinated retrieval, model calls, and conversation state. DynamoDB stored application records, S3 held source resources, and Weaviate Cloud handled vector search. Embedding inference ran on separate GPU servers; language-model calls used OpenAI and AWS Bedrock integrations.

This was a deliberate choice. HEKADES was intended for a comparatively narrow audience - family physicians in Türkiye - and we didn’t expect enough traffic to justify maintaining independently deployed backend services. Keeping the core application together simplified deployment and operations. The GPU embedding service was separated because its compute requirements were fundamentally different.

01 One backend, separate dependencies

On a narrow screen, scroll the diagram horizontally.

One backend, separate dependencies The client connects over HTTP and WebSocket to a Python monolith on AWS EC2. The backend uses external Weaviate Cloud, DynamoDB, S3, separate GPU embedding servers, and OpenAI API / AWS Bedrock. Client applicationHTTP + WebSocket AWS EC2 · Docker One Python backend deployment FastAPI + Uvicorn Application logicRetrieval + LLM orchestration External dependencies Weaviate CloudManaged vector databaseHybrid search + metadata Amazon DynamoDBApplication recordsUsers, patients, conversations Amazon S3Source resourcesDocument files + display assets Separate GPU serversEmbedding inferenceIndexing + query vectors OpenAI API + AWS BedrockHosted language modelsLLM requests

The client connects over HTTP and WebSocket to a Python monolith on AWS EC2. The backend uses external Weaviate Cloud, DynamoDB, S3, separate GPU embedding servers, and OpenAI API / AWS Bedrock.

Stack, by responsibility

Stack, by responsibility
ResponsibilityTechnologyHow it was used
Backend runtimePython 3.12; FastAPI; UvicornApplication endpoints, validation and WebSocket connections
API modelsPydanticTyped incoming and outgoing packets
Application deploymentAWS EC2; DockerSingle deployable backend, containerized runtime
RetrievalWeaviate CloudSource chunks, metadata filtering, hybrid search and named vectors
EmbeddingsSeparate GPU inference serversProducing vectors during indexing and retrieval
Application dataAmazon DynamoDBUsers, patients, conversations and messages
Source resourcesAmazon S3Stored document resources and display assets
LLM callsOpenAI API; AWS BedrockTranslation, classification, retrieval planning and answer generation
Document processingLlamaIndex componentsPage-aware node/chunk processing
Literature discoveryNCBI Entrez / BiopythonPubMed search and abstract retrieval
ConcurrencyPython asyncioParallel stages in the case analysis workflow

The table describes technologies in the checked-in architecture, not independently verified production uptime or usage of every configured model.

Engineering the knowledge base

The information we wanted the system to retrieve wasn’t a collection of short FAQ entries. It was longer medical literature, where the location and context of a passage matter.

For the annotated-text ingestion path, we prepared source documents with table-of-contents and page metadata, divided them into page-aware passages, and generated translated text and summaries where needed. Each indexed passage retained metadata connecting it to its original source. We stored vectors for both the detailed content and a generated summary.

The distinction between those representations was intentional. A detailed passage preserves nuance, but it can also contain terminology and supporting material that add noise to similarity search. A summary provides a broader view of the same passage and can match a more general clinical question. In the audited hybrid search path, the summary vector is the named vector targeted for ranking; the original passage is retained for the answer context and source reference.

This added work to ingestion, additional embedding/storage cost and dependence on summary quality. If a summary misses something important, retrieval can miss the passage even though the underlying text contains it.

Retrieval guided by document structure

Our first approach - sending the doctor’s question straight to a vector database - wasn’t specific enough. A semantically close passage wasn’t necessarily the information the doctor needed.

I built a two-stage retrieval process that made use of the structure of the indexed documents. The system selected relevant topic tags, matched those against table-of-contents metadata, and identified candidate source documents. It then performed hybrid passage retrieval within that selected source set, instead of searching the whole corpus indiscriminately.

In the general-information route, the query could also be reformulated and expanded before retrieval. The implementation combined results from multiple queries to select passages for generation. The important design decision was making document selection explicit before passage ranking.

The limitation is equally important: if the earlier tag selection excludes a relevant document, the later similarity search won’t recover it. This was a way of guiding retrieval, not proof of superior clinical accuracy; we didn’t preserve evaluation results that would justify a quantitative claim.

02 From source documents to selected passages

On a narrow screen, scroll the diagram horizontally.

From source documents to selected passages Indexing retains page and table-of-contents metadata and stores content and summary vectors. General-information retrieval selects tags and TOC entries, restricts hybrid search to candidate source IDs, targets the summary vector, and combines query results. Original passages and source references go to the answer context. Preparation / indexing General-information retrieval Annotated medical source TOC tags + page-aware passagesSource and page metadata retained Translation where neededGenerated summaries Content + summary embeddings Weaviate CloudPassages, vectors + metadata Original text stays available for answer context and citations Doctor’s question Reformulate query + select tags Match table-of-contents entriesSelect candidate source IDs Source-filtered hybrid searchTargets the summary vector Custom multi-query result fusion Passages + source/page mappingReady for answer generation

Indexing retains page and table-of-contents metadata and stores content and summary vectors. General-information retrieval selects tags and TOC entries, restricts hybrid search to candidate source IDs, targets the summary vector, and combines query results. Original passages and source references go to the answer context.

A different workflow for clinical cases

Relatively straightforward medical questions and complex clinical cases posed different problems. A case often needed to be broken into several more specific research questions, rather than handled as one broad prompt.

We developed the case workflow with input from practicing doctors. HEKADES prepared a case presentation, selected relevant areas to investigate, and dispatched smaller research tasks. Those tasks could run concurrently, gathering information for their particular part of the case. The system then brought the findings together in a final response and takeaway.

This was research-question decomposition, not a collection of artificial specialists debating one another. It provided a way to make retrieval and analysis more targeted. In the audited code revision, an apparent argument mismatch meant generated retrieval-expansion queries could not be assumed to reach search reliably.

03 Focused questions, concurrent research

On a narrow screen, scroll the diagram horizontally.

Focused questions, concurrent research A clinical case becomes a presentation, then focused research questions. Concurrent tasks retrieve and analyze material before findings and citations are combined. Three lanes illustrate parallelism, not a fixed task count. Clinical case Prepare case presentation Identify focused research questions Research task ARetrieve + analyze Research task BRetrieve + analyze Research task CRetrieve + analyze Integrate findings + takeawaySource-referenced response Three lanes illustrate parallelism, not a fixed task count.

A clinical case becomes a presentation, then focused research questions. Concurrent tasks retrieve and analyze material before findings and citations are combined. Three lanes illustrate parallelism, not a fixed task count.

From API request to streamed answer

The backend exposed ordinary HTTP routes for account, patient, conversation and administrative operations. For answer generation, the inspected application used a WebSocket conversation flow rather than a conventional synchronous question-answer endpoint.

A client sent a typed packet with its message, preferred language and optional patient reference. The handler authenticated the session, created conversation records, and sent progress information as the request moved through translation, question classification, retrieval and generation. Response packets could carry intermediate stages, retrieved source references and generated answer tokens. The assembled phases and source mapping were then saved in DynamoDB.

Keeping intermediate steps visible helped the client respond to a multi-stage process instead of presenting a blank screen until the final answer. The code also saves partial output on a disconnect path; this isn’t the same as a guaranteed resumable stream.

04 A question through the WebSocket flow

On a narrow screen, scroll the diagram horizontally.

A question through the WebSocket flow The client sends an authenticated packet to FastAPI. Conversation and message records go to DynamoDB. Translation, classification and filtered Weaviate retrieval produce progress, sources and streamed tokens for the client. Answer phases and sources are persisted. Disconnects can change persistence behavior; resumability is not guaranteed. Client FastAPI DynamoDB AI / retrieval Weaviate Cloud Question packet Save conversation + message Conversation / stage Translate + classify Progress stages Progress packets Filtered retrieval Passages + metadata Sources + answer tokens Stream to client Save answer + sources Simplified flow; disconnects can change persistence. Resumability is not guaranteed.

The client sends an authenticated packet to FastAPI. Conversation and message records go to DynamoDB. Translation, classification and filtered Weaviate retrieval produce progress, sources and streamed tokens for the client. Answer phases and sources are persisted. Disconnects can change persistence behavior; resumability is not guaranteed.

Making sources traceable

Retrieved passages were assigned source numbers when included in model prompts. The API could return the corresponding document identifiers and page references alongside the generated text. For case workflows, citations from separate research branches also needed to be mapped into a combined response.

This was source traceability, not independent verification of medical advice. The repository shows citation mapping, but not a deterministic check that every generated claim is supported by its cited passage. That distinction mattered in a system built around medical information.

A separate path for medical literature

Alongside the indexed knowledge base, HEKADES had a PubMed workflow. It generated Boolean search terms, queried NCBI, retrieved article metadata and abstracts, reranked abstracts by embedding similarity, and produced a summary of selected results.

That path addressed a different need from retrieving passages in our own indexed source collection. It was abstract-based literature discovery, not a comprehensive systematic review or a guarantee of medically validated conclusions.

Tradeoffs, boundaries, and what I’d revisit

The monolith was a good fit for the audience and stage of the project; separate GPU embedding inference kept specialized compute apart from the application server. Document structure and summary embeddings gave us a more intentional retrieval pipeline, but introduced preprocessing effort and additional opportunities for relevant information to be excluded.

The project had limitations: asynchronous endpoints included some blocking operations, source storage updates weren’t transactional across systems, and citations were not independently checked against generated assertions. Sensitive-data handling and access controls would also need further work before any renewed clinical deployment.

HEKADES never launched as a clinical product. The difficulty of licensing medical guidelines was a decisive obstacle. I still value the engineering work: it forced me to think about retrieval, system boundaries, source traceability and reliability in a domain where a plausible-sounding answer is not enough.

Explore the archived backend

I’ve published the archived backend source so the engineering work described here can be inspected directly: the retrieval algorithms, model orchestration, asynchronous request handling and infrastructure integrations.

The work dates to 2024, when AI coding agents were still early and limited. By my retrospective estimate, roughly 80% of the code was written manually; this is a personal estimate, not a measured figure. The archive also includes work by other contributors. It preserves the implementation and experiments for reading and study, including their limitations. It is not a runnable or maintained application; the historical services, datasets and infrastructure are not supplied as a working system.

Architecture reflects the project’s historical implementation, not a claim of current production operation or verified clinical performance.

dil meselesi

Küçük bir itiraf.

Türkçe devam edebilirsin ama kendimi İngilizcede daha iyi anlattığımı düşünüyorum. İngilizcesini okumanı öneririm 😅

İngilizce oku Türkçe devam et