# jmunoz1992/medguard architecture

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

- Interactive diagram: https://gitdiagram.com/jmunoz1992/medguard
- Repository: https://github.com/jmunoz1992/medguard

## Overview

MedGuard is a small demo API for checking a newly prescribed drug against a patient’s current medications. The main flow validates a request, asks Claude to use a lookup tool, retrieves matching records from a local JSON dataset, and returns a plain-language assessment. A separate health route provides liveness status. The graph reflects the documented API flow and sampled source; the README describes the tool-use behavior, while unsampled modules are not inferred beyond documented capabilities.

Main entry points: [`src/app.ts`](https://github.com/jmunoz1992/medguard/blob/main/src/app.ts) (Express App), [`src/services/claudeAgent.ts`](https://github.com/jmunoz1992/medguard/blob/main/src/services/claudeAgent.ts) (Claude Agent), [`src/routes/checkInteraction.ts`](https://github.com/jmunoz1992/medguard/blob/main/src/routes/checkInteraction.ts) (Check Route), [`src/services/retriever.ts`](https://github.com/jmunoz1992/medguard/blob/main/src/services/retriever.ts) (Interaction Retriever)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_entry["Server Entry<br/>[index.ts]"]
  node_app["Express App<br/>[app.ts]"]
  node_check["Check Route"]
  node_health["Health Route<br/>[health.ts]"]
end

subgraph group_assessment["Risk Assessment"]
  node_agent["Claude Agent<br/>[claudeAgent.ts]"]
  node_claude["Anthropic Claude"]
end

subgraph group_knowledge["Interaction Knowledge"]
  node_retriever["Interaction Retriever<br/>[retriever.ts]"]
  node_dataset[("Interaction Records<br/>[interactions.json]")]
end

node_caller(("Pharmacist / Caller"))

node_entry -->|"serves"| node_app
node_caller -->|"sends requests"| node_app
node_app -->|"registers"| node_check
node_app -->|"registers"| node_health
node_caller -->|"checks status"| node_health
node_check -->|"requests assessment"| node_agent
node_agent -->|"requests tool use"| node_claude
node_agent -->|"looks up records"| node_retriever
node_retriever -->|"filters records"| node_dataset
node_claude -->|"returns response"| node_agent
node_check -->|"returns assessment"| node_caller

click node_entry "https://github.com/jmunoz1992/medguard/blob/main/src/index.ts"
click node_app "https://github.com/jmunoz1992/medguard/blob/main/src/app.ts"
click node_check "https://github.com/jmunoz1992/medguard/blob/main/src/routes/checkInteraction.ts"
click node_health "https://github.com/jmunoz1992/medguard/blob/main/src/routes/health.ts"
click node_agent "https://github.com/jmunoz1992/medguard/blob/main/src/services/claudeAgent.ts"
click node_retriever "https://github.com/jmunoz1992/medguard/blob/main/src/services/retriever.ts"
click node_dataset "https://github.com/jmunoz1992/medguard/blob/main/src/data/interactions.json"

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_entry,node_app,node_check,node_health toneBlue
class node_agent,node_claude toneAmber
class node_retriever,node_dataset toneMint
class node_caller toneIndigo
```

## Components

### HTTP API

- [Server Entry](https://github.com/jmunoz1992/medguard/blob/main/src/index.ts): `src/index.ts`
- [Express App](https://github.com/jmunoz1992/medguard/blob/main/src/app.ts): `src/app.ts`
- [Check Route](https://github.com/jmunoz1992/medguard/blob/main/src/routes/checkInteraction.ts): `src/routes/checkInteraction.ts`
- [Health Route](https://github.com/jmunoz1992/medguard/blob/main/src/routes/health.ts): `src/routes/health.ts`

### Risk Assessment

- [Claude Agent](https://github.com/jmunoz1992/medguard/blob/main/src/services/claudeAgent.ts): `src/services/claudeAgent.ts`
- **Anthropic Claude**

### Interaction Knowledge

- [Interaction Retriever](https://github.com/jmunoz1992/medguard/blob/main/src/services/retriever.ts): `src/services/retriever.ts`
- [Interaction Records](https://github.com/jmunoz1992/medguard/blob/main/src/data/interactions.json): `src/data/interactions.json`

### Other components

- **Pharmacist / Caller**

## Connections

- Server Entry → Express App: serves (evidence: `src/index.ts`)
- Pharmacist / Caller → Express App: sends requests (evidence: `README.md`)
- Express App → Check Route: registers (evidence: `src/app.ts`)
- Express App → Health Route: registers (evidence: `src/app.ts`)
- Pharmacist / Caller → Health Route: checks status (evidence: `README.md`)
- Check Route → Claude Agent: requests assessment (evidence: `src/routes/checkInteraction.ts`)
- Claude Agent → Anthropic Claude: requests tool use (evidence: `src/services/claudeAgent.ts`)
- Claude Agent → Interaction Retriever: looks up records (evidence: `src/services/claudeAgent.ts`)
- Interaction Retriever → Interaction Records: filters records (evidence: `src/services/retriever.ts`)
- Anthropic Claude → Claude Agent: returns response (evidence: `src/services/claudeAgent.ts`)
- Check Route → Pharmacist / Caller: returns assessment (evidence: `README.md`)
