# eldasoky1/eco-pharma architecture

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

- Interactive diagram: https://gitdiagram.com/eldasoky1/eco-pharma
- Repository: https://github.com/eldasoky1/eco-pharma

## Overview

Smart Eco-Pharma Hub is a pharmacy operations platform: staff use its dashboard to manage medicines and stock, monitor cold-chain conditions, and assess drug risks; AI agents can query selected information through MCP. The React frontend is served by a FastAPI backend, with domain services and repositories accessing Supabase, while pharmacovigilance uses an external model provider. The README documents the broader capabilities, but several routers and services were not sampled, so their internal call paths are not expanded here.

Main entry points: [`frontend/src/App.tsx`](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/App.tsx) (Dashboard app), [`frontend/src/api.ts`](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/api.ts) (Frontend API client), [`smart_eco_pharma/database.py`](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/database.py) (Supabase clients), [`smart_eco_pharma/services/pv_service.py`](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/pv_service.py) (Pharmacovigilance service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Pharmacy dashboard"]
  node_app["Dashboard app<br/>[App.tsx]"]
  node_appstate["App state<br/>[AppContext.tsx]"]
  node_authview["Authentication UI<br/>[AuthView.tsx]"]
  node_brand["Brand identity<br/>[BrandLogo.tsx]"]
  node_dashboard["Operations dashboard<br/>[DashboardView.tsx]"]
  node_inventoryui["Inventory views"]
  node_interactionui["Interaction tools"]
  node_pvui["Pharmacovigilance UI"]
  node_sensorsui["Sensor monitoring"]
  node_api["Frontend API client<br/>[api.ts]"]
end

subgraph group_api["API and services"]
  node_server["FastAPI application<br/>[main.py]"]
  node_authrouter["Authentication routes<br/>[auth.py]"]
  node_iotrouter["IoT ingestion routes<br/>[iot_ingestion.py]"]
  node_inventoryservice["Inventory service"]
  node_iotservice["IoT service<br/>[iot_service.py]"]
  node_authservice["Authentication service<br/>[auth_service.py]"]
end

subgraph group_data["Data access"]
  node_invrepo["Inventory repository"]
  node_iotrepo["Sensor repository<br/>[iot_repository.py]"]
  node_drugrepo["Drug repository<br/>[drug_repository.py]"]
  node_interactionrepo["Interaction repository"]
  node_database["Supabase clients<br/>[database.py]"]
end

subgraph group_ai["Risk analysis and agents"]
  node_pvservice["Pharmacovigilance service<br/>[pv_service.py]"]
  node_mcp["MCP server<br/>[server.py]"]
end

node_staff(("Pharmacy staff"))
node_agents(("AI agents"))
node_sensors(("IoT sensors"))
node_supabase[("Supabase database")]
node_openrouter["OpenRouter model API"]

node_staff -->|"uses"| node_app
node_app -->|"provides state"| node_appstate
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_inventoryui
node_app -->|"renders"| node_interactionui
node_app -->|"renders"| node_pvui
node_app -->|"renders"| node_sensorsui
node_app -->|"renders"| node_authview
node_authview -->|"requests auth"| node_api
node_appstate -->|"calls"| node_api
node_api -.->|"calls API"| node_server
node_server -.->|"registers"| node_authrouter
node_server -->|"registers"| node_iotrouter
node_sensors -->|"sends readings"| node_iotrouter
node_iotrouter -->|"invokes"| node_iotservice
node_iotservice -->|"uses"| node_iotrepo
node_iotservice -->|"updates stock"| node_invrepo
node_inventoryservice -->|"uses"| node_invrepo
node_invrepo -->|"uses clients"| node_database
node_iotrepo -->|"uses clients"| node_database
node_drugrepo -->|"uses clients"| node_database
node_interactionrepo -->|"uses clients"| node_database
node_database -->|"connects"| node_supabase
node_authrouter -->|"uses"| node_authservice
node_authservice -->|"manages accounts"| node_supabase
node_pvui -.->|"submits analysis"| node_api
node_api -.->|"requests assessment"| node_pvservice
node_pvservice -->|"reads drug data"| node_drugrepo
node_pvservice -->|"reads interactions"| node_interactionrepo
node_pvservice -.->|"requests analysis"| node_openrouter
node_agents -->|"queries tools"| node_mcp
node_mcp -.->|"queries interactions"| node_interactionrepo
node_mcp -.->|"queries inventory"| node_invrepo

click node_app "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/App.tsx"
click node_appstate "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/context/AppContext.tsx"
click node_authview "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/AuthView.tsx"
click node_brand "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/components/BrandLogo.tsx"
click node_dashboard "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/DashboardView.tsx"
click node_inventoryui "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/InventoryCatalogueView.tsx"
click node_interactionui "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/InteractionCheckerView.tsx"
click node_pvui "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/AIPharmacovigilanceView.tsx"
click node_sensorsui "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/LiveSensorsView.tsx"
click node_api "https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/api.ts"
click node_server "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/main.py"
click node_authrouter "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/routers/auth.py"
click node_iotrouter "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/routers/iot_ingestion.py"
click node_inventoryservice "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/inventory_service.py"
click node_iotservice "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/iot_service.py"
click node_authservice "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/auth_service.py"
click node_pvservice "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/pv_service.py"
click node_mcp "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/mcp_server/server.py"
click node_invrepo "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/inventory_repository.py"
click node_iotrepo "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/iot_repository.py"
click node_drugrepo "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/drug_repository.py"
click node_interactionrepo "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/interaction_repository.py"
click node_database "https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/database.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_app,node_appstate,node_authview,node_brand,node_dashboard,node_inventoryui,node_interactionui,node_pvui,node_sensorsui,node_api toneBlue
class node_server,node_authrouter,node_iotrouter,node_inventoryservice,node_iotservice,node_authservice,node_supabase toneAmber
class node_invrepo,node_iotrepo,node_drugrepo,node_interactionrepo,node_database,node_openrouter toneMint
class node_pvservice,node_mcp toneRose
class node_staff,node_agents,node_sensors toneIndigo
```

## Components

### Pharmacy dashboard

- [Dashboard app](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [App state](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/context/AppContext.tsx): `frontend/src/context/AppContext.tsx`
- [Authentication UI](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/AuthView.tsx): `frontend/src/views/AuthView.tsx`
- [Brand identity](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/components/BrandLogo.tsx): `frontend/src/components/BrandLogo.tsx`
- [Operations dashboard](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/DashboardView.tsx): `frontend/src/views/DashboardView.tsx`
- [Inventory views](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/InventoryCatalogueView.tsx): `frontend/src/views/InventoryCatalogueView.tsx`
- [Interaction tools](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/InteractionCheckerView.tsx): `frontend/src/views/InteractionCheckerView.tsx`
- [Pharmacovigilance UI](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/AIPharmacovigilanceView.tsx): `frontend/src/views/AIPharmacovigilanceView.tsx`
- [Sensor monitoring](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/views/LiveSensorsView.tsx): `frontend/src/views/LiveSensorsView.tsx`
- [Frontend API client](https://github.com/eldasoky1/eco-pharma/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### API and services

- [FastAPI application](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/main.py): `smart_eco_pharma/main.py`
- [Authentication routes](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/routers/auth.py): `smart_eco_pharma/routers/auth.py`
- [IoT ingestion routes](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/routers/iot_ingestion.py): `smart_eco_pharma/routers/iot_ingestion.py`
- [Inventory service](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/inventory_service.py): `smart_eco_pharma/services/inventory_service.py`
- [IoT service](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/iot_service.py): `smart_eco_pharma/services/iot_service.py`
- [Authentication service](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/auth_service.py): `smart_eco_pharma/services/auth_service.py`

### Data access

- [Inventory repository](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/inventory_repository.py): `smart_eco_pharma/repositories/inventory_repository.py`
- [Sensor repository](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/iot_repository.py): `smart_eco_pharma/repositories/iot_repository.py`
- [Drug repository](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/drug_repository.py): `smart_eco_pharma/repositories/drug_repository.py`
- [Interaction repository](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/repositories/interaction_repository.py): `smart_eco_pharma/repositories/interaction_repository.py`
- [Supabase clients](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/database.py): `smart_eco_pharma/database.py`

### Risk analysis and agents

- [Pharmacovigilance service](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/services/pv_service.py): `smart_eco_pharma/services/pv_service.py`
- [MCP server](https://github.com/eldasoky1/eco-pharma/blob/main/smart_eco_pharma/mcp_server/server.py): `smart_eco_pharma/mcp_server/server.py`

### Other components

- **Pharmacy staff**
- **AI agents**
- **IoT sensors**
- **Supabase database**
- **OpenRouter model API**

## Connections

- Pharmacy staff → Dashboard app: uses (evidence: `README.md`)
- Dashboard app → App state: provides state (evidence: `frontend/src/App.tsx`)
- Dashboard app → Operations dashboard: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Inventory views: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Interaction tools: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Pharmacovigilance UI: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Sensor monitoring: renders (evidence: `frontend/src/App.tsx`)
- Dashboard app → Authentication UI: renders (evidence: `frontend/src/App.tsx`)
- Authentication UI → Frontend API client: requests auth (evidence: `frontend/src/views/AuthView.tsx`)
- App state → Frontend API client: calls (evidence: `frontend/src/context/AppContext.tsx`)
- Frontend API client → FastAPI application: calls API (evidence: `README.md`)
- FastAPI application → Authentication routes: registers (evidence: `smart_eco_pharma/main.py`)
- FastAPI application → IoT ingestion routes: registers (evidence: `smart_eco_pharma/main.py`)
- IoT sensors → IoT ingestion routes: sends readings (evidence: `README.md`)
- IoT ingestion routes → IoT service: invokes (evidence: `smart_eco_pharma/routers/iot_ingestion.py`)
- IoT service → Sensor repository: uses (evidence: `smart_eco_pharma/services/iot_service.py`)
- IoT service → Inventory repository: updates stock (evidence: `smart_eco_pharma/services/iot_service.py`)
- Inventory service → Inventory repository: uses (evidence: `smart_eco_pharma/services/inventory_service.py`)
- Inventory repository → Supabase clients: uses clients (evidence: `smart_eco_pharma/repositories/inventory_repository.py`)
- Sensor repository → Supabase clients: uses clients (evidence: `smart_eco_pharma/repositories/iot_repository.py`)
- Drug repository → Supabase clients: uses clients (evidence: `smart_eco_pharma/repositories/drug_repository.py`)
- Interaction repository → Supabase clients: uses clients (evidence: `smart_eco_pharma/repositories/interaction_repository.py`)
- Supabase clients → Supabase database: connects (evidence: `smart_eco_pharma/database.py`)
- Authentication routes → Authentication service: uses (evidence: `smart_eco_pharma/routers/auth.py`)
- Authentication service → Supabase database: manages accounts (evidence: `smart_eco_pharma/services/auth_service.py`)
- Pharmacovigilance UI → Frontend API client: submits analysis (evidence: `README.md`)
- Frontend API client → Pharmacovigilance service: requests assessment (evidence: `README.md`)
- Pharmacovigilance service → Drug repository: reads drug data (evidence: `smart_eco_pharma/services/pv_service.py`)
- Pharmacovigilance service → Interaction repository: reads interactions (evidence: `smart_eco_pharma/services/pv_service.py`)
- Pharmacovigilance service → OpenRouter model API: requests analysis (evidence: `README.md`)
- AI agents → MCP server: queries tools (evidence: `README.md`)
- MCP server → Interaction repository: queries interactions
- MCP server → Inventory repository: queries inventory
