# vibe12341/hospital-osv2 architecture

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

- Interactive diagram: https://gitdiagram.com/vibe12341/hospital-osv2
- Repository: https://github.com/vibe12341/hospital-osv2

## Overview

HospitalOS is a demo hospital-operations web app with a staff dashboard and domain workspaces, REST-backed data access, and a Gemini assistant that uses MCP tools. Staff workflows span patient and vital review, beds, appointments, laboratory diagnostics, pharmacy, billing, and audited, role-restricted writes. The graph preserves the README’s external FHIR/openFDA wrappers and settings/audit capabilities; sampled evidence is partial, so unsampled subsystem links are omitted where callers cannot be verified.

Main entry points: [`src/App.tsx`](https://github.com/vibe12341/hospital-osv2/blob/main/src/App.tsx) (Route application), [`server/agent/agent.ts`](https://github.com/vibe12341/hospital-osv2/blob/main/server/agent/agent.ts) (Gemini agent), [`server/api/routes.ts`](https://github.com/vibe12341/hospital-osv2/blob/main/server/api/routes.ts) (REST routes), [`server/data/repo.ts`](https://github.com/vibe12341/hospital-osv2/blob/main/server/data/repo.ts) (Repository interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Staff web app"]
  node_app["Route application<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_workspaces["Operations workspaces"]
  node_landing["Public landing<br/>[LandingPage.tsx]"]
  node_chatui["Chat and confirmations<br/>[ChatPanel.tsx]"]
  node_settingsaudit["Settings and audit<br/>[SettingsPage.tsx]"]
  node_clientapi["API client<br/>[api.ts]"]
end

subgraph group_api["REST and assistant"]
  node_server["HTTP application<br/>[index.ts]"]
  node_routes["REST routes<br/>[routes.ts]"]
  node_agent["Gemini agent<br/>[agent.ts]"]
  node_permissions["Role permissions<br/>[permissions.ts]"]
  node_gemini["Google Gemini"]
end

subgraph group_data["Hospital data"]
  node_repository["Repository interface<br/>[repo.ts]"]
  node_memory[("Memory repository<br/>[memoryRepo.ts]")]
  node_firestore[("Firestore repository<br/>[firestoreRepo.ts]")]
  node_seed["Demo data seed<br/>[seed.ts]"]
end

subgraph group_mcp["MCP tools"]
  node_registry["MCP registry<br/>[registry.ts]"]
  node_hospitaltools["Hospital tool servers"]
end

subgraph group_integrations["External integrations"]
  node_externaltools["FHIR and FDA wrappers"]
  node_fhir["HAPI FHIR API"]
  node_openfda["openFDA API"]
end

node_staff(("Hospital staff"))

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_workspaces
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_settingsaudit
node_dashboard -->|"fetches data"| node_clientapi
node_landing -->|"fetches status"| node_clientapi
node_chatui -->|"sends chat"| node_clientapi
node_clientapi -->|"calls REST"| node_routes
node_server -->|"mounts"| node_routes
node_server -->|"mounts tools"| node_registry
node_routes -->|"reads and writes"| node_repository
node_routes -->|"probes status"| node_registry
node_routes -->|"serves chat"| node_agent
node_agent -.->|"generates responses"| node_gemini
node_agent -->|"connects tools"| node_registry
node_agent -->|"checks roles"| node_permissions
node_agent -->|"appends audit"| node_repository
node_registry -.->|"mounts servers"| node_hospitaltools
node_hospitaltools -->|"reads and writes"| node_repository
node_repository -.->|"selects backend"| node_memory
node_repository -.->|"selects backend"| node_firestore
node_memory -->|"loads seed"| node_seed
node_firestore -->|"uses seed"| node_seed
node_registry -.->|"registers wrappers"| node_externaltools
node_externaltools -.->|"queries"| node_fhir
node_externaltools -.->|"queries"| node_openfda

click node_app "https://github.com/vibe12341/hospital-osv2/blob/main/src/App.tsx"
click node_dashboard "https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/DashboardPage.tsx"
click node_workspaces "https://github.com/vibe12341/hospital-osv2/tree/main/src/pages"
click node_landing "https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/LandingPage.tsx"
click node_chatui "https://github.com/vibe12341/hospital-osv2/blob/main/src/components/ChatPanel.tsx"
click node_settingsaudit "https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/SettingsPage.tsx"
click node_clientapi "https://github.com/vibe12341/hospital-osv2/blob/main/src/lib/api.ts"
click node_server "https://github.com/vibe12341/hospital-osv2/blob/main/server/index.ts"
click node_routes "https://github.com/vibe12341/hospital-osv2/blob/main/server/api/routes.ts"
click node_agent "https://github.com/vibe12341/hospital-osv2/blob/main/server/agent/agent.ts"
click node_permissions "https://github.com/vibe12341/hospital-osv2/blob/main/server/agent/permissions.ts"
click node_repository "https://github.com/vibe12341/hospital-osv2/blob/main/server/data/repo.ts"
click node_memory "https://github.com/vibe12341/hospital-osv2/blob/main/server/data/memoryRepo.ts"
click node_firestore "https://github.com/vibe12341/hospital-osv2/blob/main/server/data/firestoreRepo.ts"
click node_seed "https://github.com/vibe12341/hospital-osv2/blob/main/server/data/seed.ts"
click node_registry "https://github.com/vibe12341/hospital-osv2/blob/main/server/mcp/registry.ts"
click node_hospitaltools "https://github.com/vibe12341/hospital-osv2/tree/main/server/mcp"
click node_externaltools "https://github.com/vibe12341/hospital-osv2/tree/main/server/mcp/external"

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_dashboard,node_workspaces,node_landing,node_chatui,node_settingsaudit,node_clientapi toneBlue
class node_server,node_routes,node_agent,node_permissions,node_gemini toneAmber
class node_repository,node_memory,node_firestore,node_seed toneMint
class node_registry,node_hospitaltools toneRose
class node_externaltools,node_fhir,node_openfda,node_staff toneIndigo
```

## Components

### Staff web app

- [Route application](https://github.com/vibe12341/hospital-osv2/blob/main/src/App.tsx): `src/App.tsx`
- [Dashboard](https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Operations workspaces](https://github.com/vibe12341/hospital-osv2/tree/main/src/pages): `src/pages`
- [Public landing](https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/LandingPage.tsx): `src/pages/LandingPage.tsx`
- [Chat and confirmations](https://github.com/vibe12341/hospital-osv2/blob/main/src/components/ChatPanel.tsx): `src/components/ChatPanel.tsx`
- [Settings and audit](https://github.com/vibe12341/hospital-osv2/blob/main/src/pages/SettingsPage.tsx): `src/pages/SettingsPage.tsx`
- [API client](https://github.com/vibe12341/hospital-osv2/blob/main/src/lib/api.ts): `src/lib/api.ts`

### REST and assistant

- [HTTP application](https://github.com/vibe12341/hospital-osv2/blob/main/server/index.ts): `server/index.ts`
- [REST routes](https://github.com/vibe12341/hospital-osv2/blob/main/server/api/routes.ts): `server/api/routes.ts`
- [Gemini agent](https://github.com/vibe12341/hospital-osv2/blob/main/server/agent/agent.ts): `server/agent/agent.ts`
- [Role permissions](https://github.com/vibe12341/hospital-osv2/blob/main/server/agent/permissions.ts): `server/agent/permissions.ts`
- **Google Gemini**

### Hospital data

- [Repository interface](https://github.com/vibe12341/hospital-osv2/blob/main/server/data/repo.ts): `server/data/repo.ts`
- [Memory repository](https://github.com/vibe12341/hospital-osv2/blob/main/server/data/memoryRepo.ts): `server/data/memoryRepo.ts`
- [Firestore repository](https://github.com/vibe12341/hospital-osv2/blob/main/server/data/firestoreRepo.ts): `server/data/firestoreRepo.ts`
- [Demo data seed](https://github.com/vibe12341/hospital-osv2/blob/main/server/data/seed.ts): `server/data/seed.ts`

### MCP tools

- [MCP registry](https://github.com/vibe12341/hospital-osv2/blob/main/server/mcp/registry.ts): `server/mcp/registry.ts`
- [Hospital tool servers](https://github.com/vibe12341/hospital-osv2/tree/main/server/mcp): `server/mcp`

### External integrations

- [FHIR and FDA wrappers](https://github.com/vibe12341/hospital-osv2/tree/main/server/mcp/external): `server/mcp/external`
- **HAPI FHIR API**
- **openFDA API**

### Other components

- **Hospital staff**

## Connections

- Hospital staff → Route application: uses (evidence: `src/App.tsx`)
- Route application → Dashboard: routes to (evidence: `src/App.tsx`)
- Route application → Operations workspaces: routes to (evidence: `src/App.tsx`)
- Route application → Public landing: routes to (evidence: `src/App.tsx`)
- Route application → Settings and audit: routes to (evidence: `src/App.tsx`)
- Dashboard → API client: fetches data (evidence: `src/pages/DashboardPage.tsx`)
- Public landing → API client: fetches status (evidence: `src/pages/LandingPage.tsx`)
- Chat and confirmations → API client: sends chat (evidence: `src/components/ChatPanel.tsx`)
- API client → REST routes: calls REST (evidence: `src/lib/api.ts`)
- HTTP application → REST routes: mounts (evidence: `server/index.ts`)
- HTTP application → MCP registry: mounts tools (evidence: `server/index.ts`)
- REST routes → Repository interface: reads and writes (evidence: `server/api/routes.ts`)
- REST routes → MCP registry: probes status (evidence: `server/api/routes.ts`)
- REST routes → Gemini agent: serves chat (evidence: `server/api/routes.ts`)
- Gemini agent → Google Gemini: generates responses
- Gemini agent → MCP registry: connects tools (evidence: `server/agent/agent.ts`)
- Gemini agent → Role permissions: checks roles (evidence: `server/agent/agent.ts`)
- Gemini agent → Repository interface: appends audit (evidence: `server/agent/agent.ts`)
- MCP registry → Hospital tool servers: mounts servers
- Hospital tool servers → Repository interface: reads and writes (evidence: `server/mcp/appointments/server.ts`)
- Repository interface → Memory repository: selects backend (evidence: `server/data/memoryRepo.ts`)
- Repository interface → Firestore repository: selects backend (evidence: `server/data/firestoreRepo.ts`)
- Memory repository → Demo data seed: loads seed (evidence: `server/data/memoryRepo.ts`)
- Firestore repository → Demo data seed: uses seed (evidence: `server/data/firestoreRepo.ts`)
- MCP registry → FHIR and FDA wrappers: registers wrappers
- FHIR and FDA wrappers → HAPI FHIR API: queries
- FHIR and FDA wrappers → openFDA API: queries
