# adrian-1bos/infomed architecture

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

- Interactive diagram: https://gitdiagram.com/adrian-1bos/infomed
- Repository: https://github.com/adrian-1bos/infomed

## Overview

Infomed accepts a patient’s medication list from Bubble, normalizes and matches medicines against a local ANVISA-derived catalog, enriches missing pharmacological data, and checks for interactions before returning a structured patient record. The product also documents inventory, schedules, medication history, and caregiver linking in Bubble, plus n8n/Telegram notifications. The graph shows relationships supported by excerpts or README statements; unsampled implementation details are omitted.

Main entry points: [`core/ui_tratamento.py`](https://github.com/adrian-1bos/infomed/blob/main/core/ui_tratamento.py) (Medication matching), [`core/ia/ai_handler.py`](https://github.com/adrian-1bos/infomed/blob/main/core/ia/ai_handler.py) (AI provider routing), [`app.py`](https://github.com/adrian-1bos/infomed/blob/main/app.py) (REST API), [`data/solidificados.json`](https://github.com/adrian-1bos/infomed/blob/main/data/solidificados.json) (Medication catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Patient experience"]
  node_bubble(("Bubble patient and caregiver UI"))
end

subgraph group_api["API orchestration"]
  node_api["REST API<br/>[app.py]"]
end

subgraph group_clinical["Clinical processing"]
  node_normalize["Medication matching<br/>[ui_tratamento.py]"]
  node_enrichment["Clinical data enrichment<br/>[complementos.py]"]
  node_interactions["Interaction screening<br/>[incompativeis.py]"]
  node_ai["AI provider routing<br/>[ai_handler.py]"]
end

subgraph group_catalog["Medication catalog"]
  node_catalog[("Medication catalog<br/>[solidificados.json]")]
  node_csv_import["ANVISA catalog conversion"]
end

subgraph group_notifications["Notifications"]
  node_n8n["n8n automation"]
end

node_gemini["Google Gemini"]
node_groq["Groq"]
node_anvisa_csv["ANVISA CSV<br/>[medicamentos.csv]"]
node_telegram["Telegram"]

node_bubble -->|"submits medications"| node_api
node_api -->|"processes payload"| node_normalize
node_normalize -->|"matches medicines"| node_catalog
node_normalize -->|"resolves weak matches"| node_ai
node_normalize -->|"requests enrichment"| node_enrichment
node_normalize -->|"requests screening"| node_interactions
node_enrichment -->|"reads and updates"| node_catalog
node_enrichment -->|"requests missing data"| node_ai
node_interactions -->|"checks local data"| node_catalog
node_interactions -->|"audits interactions"| node_ai
node_ai -->|"requests generation"| node_gemini
node_ai -->|"falls back to"| node_groq
node_api -->|"returns patient record"| node_bubble
node_api -->|"dispatches alerts"| node_n8n
node_n8n -->|"sends messages"| node_telegram
node_anvisa_csv -->|"provides source data"| node_csv_import
node_csv_import -->|"builds catalog"| node_catalog

click node_api "https://github.com/adrian-1bos/infomed/blob/main/app.py"
click node_normalize "https://github.com/adrian-1bos/infomed/blob/main/core/ui_tratamento.py"
click node_enrichment "https://github.com/adrian-1bos/infomed/blob/main/core/complementos.py"
click node_interactions "https://github.com/adrian-1bos/infomed/blob/main/core/incompativeis.py"
click node_ai "https://github.com/adrian-1bos/infomed/blob/main/core/ia/ai_handler.py"
click node_catalog "https://github.com/adrian-1bos/infomed/blob/main/data/solidificados.json"
click node_csv_import "https://github.com/adrian-1bos/infomed/blob/main/core/tratamento_csv_json.py"
click node_anvisa_csv "https://github.com/adrian-1bos/infomed/blob/main/data/medicamentos.csv"

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_bubble toneBlue
class node_api toneAmber
class node_normalize,node_enrichment,node_interactions,node_ai toneMint
class node_catalog,node_csv_import toneRose
class node_n8n,node_gemini,node_groq,node_telegram toneIndigo
class node_anvisa_csv toneTeal
```

## Components

### Patient experience

- **Bubble patient and caregiver UI**

### API orchestration

- [REST API](https://github.com/adrian-1bos/infomed/blob/main/app.py): `app.py`

### Clinical processing

- [Medication matching](https://github.com/adrian-1bos/infomed/blob/main/core/ui_tratamento.py): `core/ui_tratamento.py`
- [Clinical data enrichment](https://github.com/adrian-1bos/infomed/blob/main/core/complementos.py): `core/complementos.py`
- [Interaction screening](https://github.com/adrian-1bos/infomed/blob/main/core/incompativeis.py): `core/incompativeis.py`
- [AI provider routing](https://github.com/adrian-1bos/infomed/blob/main/core/ia/ai_handler.py): `core/ia/ai_handler.py`

### Medication catalog

- [Medication catalog](https://github.com/adrian-1bos/infomed/blob/main/data/solidificados.json): `data/solidificados.json`
- [ANVISA catalog conversion](https://github.com/adrian-1bos/infomed/blob/main/core/tratamento_csv_json.py): `core/tratamento_csv_json.py`

### Notifications

- **n8n automation**

### Other components

- **Google Gemini**
- **Groq**
- [ANVISA CSV](https://github.com/adrian-1bos/infomed/blob/main/data/medicamentos.csv): `data/medicamentos.csv`
- **Telegram**

## Connections

- Bubble patient and caregiver UI → REST API: submits medications (evidence: `README.md`)
- REST API → Medication matching: processes payload (evidence: `README.md`)
- Medication matching → Medication catalog: matches medicines (evidence: `README.md`)
- Medication matching → AI provider routing: resolves weak matches (evidence: `core/ui_tratamento.py`)
- Medication matching → Clinical data enrichment: requests enrichment (evidence: `README.md`)
- Medication matching → Interaction screening: requests screening (evidence: `README.md`)
- Clinical data enrichment → Medication catalog: reads and updates (evidence: `README.md`)
- Clinical data enrichment → AI provider routing: requests missing data (evidence: `core/complementos.py`)
- Interaction screening → Medication catalog: checks local data (evidence: `README.md`)
- Interaction screening → AI provider routing: audits interactions (evidence: `core/incompativeis.py`)
- AI provider routing → Google Gemini: requests generation (evidence: `core/ia/ai_handler.py`)
- AI provider routing → Groq: falls back to (evidence: `core/ia/ai_handler.py`)
- REST API → Bubble patient and caregiver UI: returns patient record (evidence: `README.md`)
- REST API → n8n automation: dispatches alerts (evidence: `app.py`)
- n8n automation → Telegram: sends messages (evidence: `README.md`)
- ANVISA CSV → ANVISA catalog conversion: provides source data (evidence: `README.md`)
- ANVISA catalog conversion → Medication catalog: builds catalog (evidence: `core/tratamento_csv_json.py`)
