# yuan7code/meddra-coding-ai architecture

> Architecture diagram of the GitHub repository yuan7code/meddra-coding-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yuan7code/meddra-coding-ai
- Repository: https://github.com/yuan7code/meddra-coding-ai

## Overview

MedDRA-Coding-AI is a pharmacovigilance coding assistant. Its main workflow accepts a medical term in the Streamlit UI, retrieves and ranks MedDRA candidates, selects a code with LLM reasoning, and presents the result with hierarchy context. A separate documented workflow parses MedDRA ASCII dictionaries and builds language/version-specific indexes. The graph includes both FAISS and optional Chroma paths; edges are limited to relationships shown in excerpts or stated in the README, so some internal details of the orchestration remain unexpanded.

Main entry points: [`meddra_rag_assistant/modules/rag_agent.py`](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/rag_agent.py) (RAG orchestrator), [`meddra_rag_assistant/build_index.py`](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/build_index.py) (Index build CLI), [`meddra_rag_assistant/modules/parser.py`](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/parser.py) (ASCII parser), [`meddra_rag_assistant/main.py`](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/main.py) (Streamlit UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Coding interface"]
  node_ui["Streamlit UI<br/>[main.py]"]
end

subgraph group_pipeline["RAG workflow"]
  node_agent["RAG orchestrator<br/>[rag_agent.py]"]
  node_retrieval["Candidate retrieval<br/>[retriever.py]"]
  node_chroma_retrieval["Chroma retrieval"]
  node_hierarchy["Hierarchy resolver<br/>[hierarchy.py]"]
  node_llm["LLM client<br/>[llm_client.py]"]
end

subgraph group_indexing["Index construction"]
  node_index_cli["Index build CLI<br/>[build_index.py]"]
  node_parser["ASCII parser<br/>[parser.py]"]
  node_faiss_builder["FAISS builder<br/>[vectorizer.py]"]
  node_chroma_builder["Chroma builder"]
end

subgraph group_persistence["Vector stores"]
  node_faiss_index[("FAISS index files")]
  node_chroma_store[("Persistent Chroma store")]
end

node_coder(("Medical coder"))
node_llm_services{{"LLM backends"}}

node_coder -->|"enters term"| node_ui
node_ui -->|"submits query"| node_agent
node_agent -->|"searches candidates"| node_retrieval
node_agent -->|"selects backend"| node_chroma_retrieval
node_agent -->|"resolves hierarchy"| node_hierarchy
node_agent -->|"requests reasoning"| node_llm
node_llm -->|"calls provider"| node_llm_services
node_agent -->|"returns response"| node_ui
node_index_cli -->|"parses dictionaries"| node_parser
node_index_cli -->|"builds FAISS"| node_faiss_builder
node_index_cli -->|"builds Chroma"| node_chroma_builder
node_parser -->|"provides documents"| node_faiss_builder
node_parser -->|"provides documents"| node_chroma_builder
node_faiss_builder -->|"writes index files"| node_faiss_index
node_chroma_builder -->|"persists collection"| node_chroma_store

click node_ui "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/main.py"
click node_agent "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/rag_agent.py"
click node_retrieval "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/retriever.py"
click node_chroma_retrieval "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorstore_chroma.py"
click node_hierarchy "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/hierarchy.py"
click node_llm "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/llm_client.py"
click node_index_cli "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/build_index.py"
click node_parser "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/parser.py"
click node_faiss_builder "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorizer.py"
click node_chroma_builder "https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorstore_chroma.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui toneBlue
class node_agent,node_retrieval,node_chroma_retrieval,node_hierarchy,node_llm toneAmber
class node_index_cli,node_parser,node_faiss_builder,node_chroma_builder toneMint
class node_faiss_index,node_chroma_store toneRose
class node_coder,node_llm_services toneIndigo
```

## Components

### Coding interface

- [Streamlit UI](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/main.py): `meddra_rag_assistant/main.py`

### RAG workflow

- [RAG orchestrator](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/rag_agent.py): `meddra_rag_assistant/modules/rag_agent.py`
- [Candidate retrieval](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/retriever.py): `meddra_rag_assistant/modules/retriever.py`
- [Chroma retrieval](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorstore_chroma.py): `meddra_rag_assistant/modules/vectorstore_chroma.py`
- [Hierarchy resolver](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/hierarchy.py): `meddra_rag_assistant/modules/hierarchy.py`
- [LLM client](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/llm_client.py): `meddra_rag_assistant/modules/llm_client.py`

### Index construction

- [Index build CLI](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/build_index.py): `meddra_rag_assistant/build_index.py`
- [ASCII parser](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/parser.py): `meddra_rag_assistant/modules/parser.py`
- [FAISS builder](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorizer.py): `meddra_rag_assistant/modules/vectorizer.py`
- [Chroma builder](https://github.com/yuan7code/meddra-coding-ai/blob/main/meddra_rag_assistant/modules/vectorstore_chroma.py): `meddra_rag_assistant/modules/vectorstore_chroma.py`

### Vector stores

- **FAISS index files**
- **Persistent Chroma store**

### Other components

- **Medical coder**
- **LLM backends**

## Connections

- Medical coder → Streamlit UI: enters term (evidence: `README.md`)
- Streamlit UI → RAG orchestrator: submits query (evidence: `meddra_rag_assistant/main.py`)
- RAG orchestrator → Candidate retrieval: searches candidates (evidence: `meddra_rag_assistant/modules/rag_agent.py`)
- RAG orchestrator → Chroma retrieval: selects backend (evidence: `meddra_rag_assistant/modules/rag_agent.py`)
- RAG orchestrator → Hierarchy resolver: resolves hierarchy (evidence: `meddra_rag_assistant/modules/rag_agent.py`)
- RAG orchestrator → LLM client: requests reasoning (evidence: `meddra_rag_assistant/modules/rag_agent.py`)
- LLM client → LLM backends: calls provider (evidence: `meddra_rag_assistant/modules/llm_client.py`)
- RAG orchestrator → Streamlit UI: returns response (evidence: `meddra_rag_assistant/main.py`)
- Index build CLI → ASCII parser: parses dictionaries (evidence: `meddra_rag_assistant/build_index.py`)
- Index build CLI → FAISS builder: builds FAISS (evidence: `meddra_rag_assistant/build_index.py`)
- Index build CLI → Chroma builder: builds Chroma (evidence: `meddra_rag_assistant/build_index.py`)
- ASCII parser → FAISS builder: provides documents (evidence: `README.md`)
- ASCII parser → Chroma builder: provides documents (evidence: `README.md`)
- FAISS builder → FAISS index files: writes index files (evidence: `meddra_rag_assistant/modules/vectorizer.py`)
- Chroma builder → Persistent Chroma store: persists collection (evidence: `meddra_rag_assistant/modules/vectorstore_chroma.py`)
