# ahmed-esso/pharma-supply-chain-intelligence architecture

> Architecture diagram of the GitHub repository ahmed-esso/pharma-supply-chain-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmed-esso/pharma-supply-chain-intelligence
- Repository: https://github.com/ahmed-esso/pharma-supply-chain-intelligence

## Overview

Pharma Supply Chain Intelligence ingests regulatory and drug-catalog data into a Bronze lakehouse, with documented Silver cleaning/quality and Gold analytics stages. Its document workflow inventories sources, extracts and normalizes text, chunks and indexes it, then answers questions with grounded citations and evaluates retrieval and guardrails. README documents an Airflow schedule, FastAPI backend, and Streamlit dashboard, but the API and app directories contain no implementation files in the supplied tree; their runtime wiring therefore cannot be verified. Edges follow shown calls or README-described stages.

Main entry points: [`ingestion/pharma_ingestion_runner.py`](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/ingestion/pharma_ingestion_runner.py) (Source ingestion), [`rag/retrieval/rag_pipeline.py`](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/retrieval/rag_pipeline.py) (Grounded retrieval), [`rag/extraction/extractor.py`](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/extraction/extractor.py) (Text extraction), [`lakehouse/bronze`](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/bronze) (Bronze raw data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_airflow["Airflow DAG"]
  node_ingestion_runner["Source ingestion"]
end

subgraph group_lakehouse["Lakehouse"]
  node_bronze[("Bronze raw data")]
  node_silver[("Silver quality")]
  node_gold[("Gold analytics")]
end

subgraph group_documents["Document preparation"]
  node_inventory["Source inventory"]
  node_extractor["Text extraction<br/>[extractor.py]"]
  node_chunker["Document chunking<br/>[chunker.py]"]
  node_embeddings[("Hybrid index<br/>[embeddings.py]")]
end

subgraph group_rag["RAG retrieval"]
  node_retrieval["Grounded retrieval<br/>[rag_pipeline.py]"]
  node_evaluation["RAG evaluation<br/>[evaluate_rag.py]"]
end

subgraph group_product["Product interfaces"]
  node_demo["Interactive demo"]
  node_api["FastAPI backend"]
  node_dashboard["Streamlit dashboard"]
end

node_operator(("Supply-chain user"))
node_openfda{{"openFDA APIs"}}
node_rxnav{{"NIH RxNav API"}}

node_operator -->|"asks"| node_demo
node_airflow -->|"invokes"| node_ingestion_runner
node_ingestion_runner -->|"fetches"| node_openfda
node_ingestion_runner -->|"fetches"| node_rxnav
node_ingestion_runner -->|"writes snapshots"| node_bronze
node_bronze -->|"clean and validate"| node_silver
node_silver -->|"produce analytics"| node_gold
node_inventory -.->|"registers sources"| node_extractor
node_extractor -->|"reads records"| node_bronze
node_extractor -->|"provides extracted units"| node_chunker
node_chunker -->|"provides chunks"| node_embeddings
node_embeddings -->|"loads index"| node_retrieval
node_demo -->|"asks questions"| node_retrieval
node_retrieval -->|"answers benchmark queries"| node_evaluation
node_api -.->|"integrates RAG"| node_retrieval
node_dashboard -.->|"presents analytics"| node_gold

click node_airflow "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/dags/airflow_pharma_pipeline_dag.py"
click node_ingestion_runner "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/ingestion/pharma_ingestion_runner.py"
click node_bronze "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/bronze"
click node_silver "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/silver"
click node_gold "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/gold"
click node_inventory "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/extraction/document_inventory.py"
click node_extractor "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/extraction/extractor.py"
click node_chunker "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/chunking/chunker.py"
click node_embeddings "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/chunking/embeddings.py"
click node_retrieval "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/retrieval/rag_pipeline.py"
click node_evaluation "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/evaluation/evaluate_rag.py"
click node_demo "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/interactive_demo.py"
click node_api "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/api"
click node_dashboard "https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/app"

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_airflow,node_ingestion_runner,node_operator toneBlue
class node_bronze,node_silver,node_gold toneAmber
class node_inventory,node_extractor,node_chunker,node_embeddings,node_openfda,node_rxnav toneMint
class node_retrieval,node_evaluation toneRose
class node_demo,node_api,node_dashboard toneIndigo
```

## Components

### Ingestion

- [Airflow DAG](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/dags/airflow_pharma_pipeline_dag.py): `dags/airflow_pharma_pipeline_dag.py`
- [Source ingestion](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/ingestion/pharma_ingestion_runner.py): `ingestion/pharma_ingestion_runner.py`

### Lakehouse

- [Bronze raw data](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/bronze): `lakehouse/bronze`
- [Silver quality](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/silver): `lakehouse/silver`
- [Gold analytics](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/lakehouse/gold): `lakehouse/gold`

### Document preparation

- [Source inventory](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/extraction/document_inventory.py): `rag/extraction/document_inventory.py`
- [Text extraction](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/extraction/extractor.py): `rag/extraction/extractor.py`
- [Document chunking](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/chunking/chunker.py): `rag/chunking/chunker.py`
- [Hybrid index](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/chunking/embeddings.py): `rag/chunking/embeddings.py`

### RAG retrieval

- [Grounded retrieval](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/retrieval/rag_pipeline.py): `rag/retrieval/rag_pipeline.py`
- [RAG evaluation](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/evaluation/evaluate_rag.py): `rag/evaluation/evaluate_rag.py`

### Product interfaces

- [Interactive demo](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/blob/main/rag/interactive_demo.py): `rag/interactive_demo.py`
- [FastAPI backend](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/api): `api`
- [Streamlit dashboard](https://github.com/ahmed-esso/pharma-supply-chain-intelligence/tree/main/app): `app`

### Other components

- **Supply-chain user**
- **openFDA APIs**
- **NIH RxNav API**

## Connections

- Supply-chain user → Interactive demo: asks (evidence: `rag/interactive_demo.py`)
- Airflow DAG → Source ingestion: invokes (evidence: `dags/airflow_pharma_pipeline_dag.py`)
- Source ingestion → openFDA APIs: fetches (evidence: `ingestion/pharma_ingestion_runner.py`)
- Source ingestion → NIH RxNav API: fetches (evidence: `ingestion/pharma_ingestion_runner.py`)
- Source ingestion → Bronze raw data: writes snapshots (evidence: `ingestion/pharma_ingestion_runner.py`)
- Bronze raw data → Silver quality: clean and validate (evidence: `README.md`)
- Silver quality → Gold analytics: produce analytics (evidence: `README.md`)
- Source inventory → Text extraction: registers sources (evidence: `rag/extraction/extractor.py`)
- Text extraction → Bronze raw data: reads records (evidence: `rag/extraction/extractor.py`)
- Text extraction → Document chunking: provides extracted units (evidence: `rag/chunking/chunker.py`)
- Document chunking → Hybrid index: provides chunks (evidence: `rag/chunking/embeddings.py`)
- Hybrid index → Grounded retrieval: loads index (evidence: `rag/retrieval/rag_pipeline.py`)
- Interactive demo → Grounded retrieval: asks questions (evidence: `rag/interactive_demo.py`)
- Grounded retrieval → RAG evaluation: answers benchmark queries (evidence: `rag/evaluation/evaluate_rag.py`)
- FastAPI backend → Grounded retrieval: integrates RAG
- Streamlit dashboard → Gold analytics: presents analytics
