# gunsu12/hosim-go architecture

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

- Interactive diagram: https://gitdiagram.com/gunsu12/hosim-go
- Repository: https://github.com/gunsu12/hosim-go

## Overview

HOSIM-GO is a hospital information system and electronic health record with a Svelte client and Go API. The user-facing path runs from browser login and navigation through clinical or master-data screens to the backend; the README also describes emergency, outpatient, inpatient, interoperability, and audit capabilities. The graph preserves these documented areas, but several are represented by their existing module directories because their implementation was not sampled. Edges are limited to relationships visible in the excerpts or stated in the README.

Main entry points: [`cmd/api/main.go`](https://github.com/gunsu12/hosim-go/blob/main/cmd/api/main.go) (Go API server), [`internal/clinical`](https://github.com/gunsu12/hosim-go/tree/main/internal/clinical) (EHR and orders), [`web/src/App.svelte`](https://github.com/gunsu12/hosim-go/blob/main/web/src/App.svelte) (Svelte application), [`web/src/lib/pages/master`](https://github.com/gunsu12/hosim-go/tree/main/web/src/lib/pages/master) (Master screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Svelte application<br/>[App.svelte]"]
  node_auth_ui["Session store<br/>[auth.svelte.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_clinical_views["Clinical screens"]
  node_master_views["Master screens"]
end

subgraph group_backend["API and security"]
  node_api_server["Go API server<br/>[main.go]"]
  node_auth["Authentication"]
  node_auth_middleware["JWT middleware<br/>[auth.go]"]
  node_database[("PostgreSQL database<br/>[database.go]")]
  node_audit["Activity audit"]
end

subgraph group_records["Hospital records"]
  node_patient["Patient records"]
  node_practitioner["Practitioner records"]
  node_organization["Organization masters"]
  node_finance["Payers and tariffs"]
end

subgraph group_clinical["Clinical care"]
  node_clinical_domain["EHR and orders"]
  node_care_settings["Care settings"]
  node_outpatient["Outpatient care"]
  node_inpatient["Inpatient care"]
end

subgraph group_operations["Hospital operations"]
  node_catalog["Item catalog"]
  node_pharmacy["Pharmacy"]
  node_inventory["Inventory"]
  node_integrations["Health integrations"]
end

node_user(("Hospital user"))

node_user -->|"uses"| node_app
node_app -->|"checks session"| node_auth_ui
node_auth_ui -->|"logs in through"| node_api_client
node_app -->|"renders"| node_clinical_views
node_app -->|"renders"| node_master_views
node_app -.->|"uses backend"| node_api_server
node_api_server -->|"registers routes"| node_auth
node_api_server -->|"protects routes"| node_auth_middleware
node_api_server -->|"wires handlers"| node_catalog
node_api_server -->|"wires handlers"| node_organization
node_api_server -.->|"initializes"| node_database
node_api_server -.->|"serves master data"| node_patient
node_api_server -.->|"serves master data"| node_practitioner
node_api_server -.->|"serves master data"| node_finance
node_clinical_views -->|"presents"| node_clinical_domain
node_clinical_domain -.->|"supports"| node_care_settings
node_clinical_domain -.->|"supports"| node_outpatient
node_clinical_domain -.->|"supports"| node_inpatient
node_clinical_domain -.->|"orders prescriptions"| node_pharmacy
node_clinical_domain -.->|"interoperates"| node_integrations
node_clinical_domain -.->|"records activity"| node_audit
node_catalog -.->|"supports supplies"| node_inventory
node_master_views -.->|"manages"| node_patient
node_master_views -.->|"manages"| node_practitioner
node_master_views -.->|"manages"| node_organization
node_master_views -.->|"manages"| node_finance

click node_app "https://github.com/gunsu12/hosim-go/blob/main/web/src/App.svelte"
click node_auth_ui "https://github.com/gunsu12/hosim-go/blob/main/web/src/lib/stores/auth.svelte.ts"
click node_api_client "https://github.com/gunsu12/hosim-go/blob/main/web/src/lib/api.ts"
click node_clinical_views "https://github.com/gunsu12/hosim-go/tree/main/web/src/lib/pages/clinical"
click node_master_views "https://github.com/gunsu12/hosim-go/tree/main/web/src/lib/pages/master"
click node_api_server "https://github.com/gunsu12/hosim-go/blob/main/cmd/api/main.go"
click node_auth "https://github.com/gunsu12/hosim-go/tree/main/internal/auth"
click node_auth_middleware "https://github.com/gunsu12/hosim-go/blob/main/internal/middleware/auth.go"
click node_patient "https://github.com/gunsu12/hosim-go/tree/main/internal/patient"
click node_practitioner "https://github.com/gunsu12/hosim-go/tree/main/internal/practitioner"
click node_organization "https://github.com/gunsu12/hosim-go/tree/main/internal/organization"
click node_finance "https://github.com/gunsu12/hosim-go/tree/main/internal/finance"
click node_catalog "https://github.com/gunsu12/hosim-go/tree/main/internal/catalog/item"
click node_database "https://github.com/gunsu12/hosim-go/blob/main/internal/database/database.go"
click node_clinical_domain "https://github.com/gunsu12/hosim-go/tree/main/internal/clinical"
click node_care_settings "https://github.com/gunsu12/hosim-go/tree/main/internal/emergency"
click node_outpatient "https://github.com/gunsu12/hosim-go/tree/main/internal/outpatient"
click node_inpatient "https://github.com/gunsu12/hosim-go/tree/main/internal/inpatient"
click node_pharmacy "https://github.com/gunsu12/hosim-go/tree/main/internal/pharmacy"
click node_inventory "https://github.com/gunsu12/hosim-go/tree/main/internal/inventory"
click node_integrations "https://github.com/gunsu12/hosim-go/tree/main/internal/integration"
click node_audit "https://github.com/gunsu12/hosim-go/tree/main/internal/audit"

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_auth_ui,node_api_client,node_clinical_views,node_master_views,node_user toneBlue
class node_api_server,node_auth,node_auth_middleware,node_database,node_audit toneAmber
class node_patient,node_practitioner,node_organization,node_finance toneMint
class node_clinical_domain,node_care_settings,node_outpatient,node_inpatient toneRose
class node_catalog,node_pharmacy,node_inventory,node_integrations toneIndigo
```

## Components

### Web client

- [Svelte application](https://github.com/gunsu12/hosim-go/blob/main/web/src/App.svelte): `web/src/App.svelte`
- [Session store](https://github.com/gunsu12/hosim-go/blob/main/web/src/lib/stores/auth.svelte.ts): `web/src/lib/stores/auth.svelte.ts`
- [API client](https://github.com/gunsu12/hosim-go/blob/main/web/src/lib/api.ts): `web/src/lib/api.ts`
- [Clinical screens](https://github.com/gunsu12/hosim-go/tree/main/web/src/lib/pages/clinical): `web/src/lib/pages/clinical`
- [Master screens](https://github.com/gunsu12/hosim-go/tree/main/web/src/lib/pages/master): `web/src/lib/pages/master`

### API and security

- [Go API server](https://github.com/gunsu12/hosim-go/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [Authentication](https://github.com/gunsu12/hosim-go/tree/main/internal/auth): `internal/auth`
- [JWT middleware](https://github.com/gunsu12/hosim-go/blob/main/internal/middleware/auth.go): `internal/middleware/auth.go`
- [PostgreSQL database](https://github.com/gunsu12/hosim-go/blob/main/internal/database/database.go): `internal/database/database.go`
- [Activity audit](https://github.com/gunsu12/hosim-go/tree/main/internal/audit): `internal/audit`

### Hospital records

- [Patient records](https://github.com/gunsu12/hosim-go/tree/main/internal/patient): `internal/patient`
- [Practitioner records](https://github.com/gunsu12/hosim-go/tree/main/internal/practitioner): `internal/practitioner`
- [Organization masters](https://github.com/gunsu12/hosim-go/tree/main/internal/organization): `internal/organization`
- [Payers and tariffs](https://github.com/gunsu12/hosim-go/tree/main/internal/finance): `internal/finance`

### Clinical care

- [EHR and orders](https://github.com/gunsu12/hosim-go/tree/main/internal/clinical): `internal/clinical`
- [Care settings](https://github.com/gunsu12/hosim-go/tree/main/internal/emergency): `internal/emergency`
- [Outpatient care](https://github.com/gunsu12/hosim-go/tree/main/internal/outpatient): `internal/outpatient`
- [Inpatient care](https://github.com/gunsu12/hosim-go/tree/main/internal/inpatient): `internal/inpatient`

### Hospital operations

- [Item catalog](https://github.com/gunsu12/hosim-go/tree/main/internal/catalog/item): `internal/catalog/item`
- [Pharmacy](https://github.com/gunsu12/hosim-go/tree/main/internal/pharmacy): `internal/pharmacy`
- [Inventory](https://github.com/gunsu12/hosim-go/tree/main/internal/inventory): `internal/inventory`
- [Health integrations](https://github.com/gunsu12/hosim-go/tree/main/internal/integration): `internal/integration`

### Other components

- **Hospital user**

## Connections

- Hospital user → Svelte application: uses
- Svelte application → Session store: checks session (evidence: `web/src/App.svelte`)
- Session store → API client: logs in through (evidence: `web/src/lib/stores/auth.svelte.ts`)
- Svelte application → Clinical screens: renders (evidence: `web/src/App.svelte`)
- Svelte application → Master screens: renders (evidence: `web/src/App.svelte`)
- Svelte application → Go API server: uses backend
- Go API server → Authentication: registers routes (evidence: `cmd/api/main.go`)
- Go API server → JWT middleware: protects routes (evidence: `cmd/api/main.go`)
- Go API server → Item catalog: wires handlers (evidence: `cmd/api/main.go`)
- Go API server → Organization masters: wires handlers (evidence: `cmd/api/main.go`)
- Go API server → PostgreSQL database: initializes
- Go API server → Patient records: serves master data
- Go API server → Practitioner records: serves master data
- Go API server → Payers and tariffs: serves master data
- Clinical screens → EHR and orders: presents
- EHR and orders → Care settings: supports
- EHR and orders → Outpatient care: supports
- EHR and orders → Inpatient care: supports
- EHR and orders → Pharmacy: orders prescriptions
- EHR and orders → Health integrations: interoperates
- EHR and orders → Activity audit: records activity
- Item catalog → Inventory: supports supplies
- Master screens → Patient records: manages
- Master screens → Practitioner records: manages
- Master screens → Organization masters: manages
- Master screens → Payers and tariffs: manages
