# fastenhealth/fasten-onprem architecture

> Architecture diagram of the GitHub repository fastenhealth/fasten-onprem, 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/fastenhealth/fasten-onprem
- Repository: https://github.com/fastenhealth/fasten-onprem

## Overview

Fasten OnPrem is a self-hosted personal health record for viewing and managing health information, not a direct provider-import service. The main user journey is to sign in, enter records or upload an exported FHIR bundle, then explore records and dashboards. The frontend talks to a Go API whose documented routes cover authentication, FHIR resources, summaries, jobs, and settings; backend repositories provide persistence. The graph follows documented capabilities and indexed references. Several handlers and service implementations were not sampled, so uncertain internal call links are omitted.

Main entry points: [`backend/pkg/web/server.go`](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/server.go) (HTTP server and routes), [`frontend/src/app/services/fasten-api.service.ts`](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/fasten-api.service.ts) (Fasten API client), [`frontend/src/app/app-routing.module.ts`](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/app-routing.module.ts) (Page routing), [`frontend/src/app/pages/medical-sources/medical-sources.component.ts`](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/medical-sources/medical-sources.component.ts) (Medical sources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Frontend experience"]
  node_app["Angular application<br/>[app.module.ts]"]
  node_routes["Page routing"]
  node_signin["Sign-in page"]
  node_signup["Signup wizard"]
  node_authsvc["Authentication service<br/>[auth.service.ts]"]
  node_sources["Medical sources"]
  node_dashboard["Health dashboard"]
  node_history["Medical history views"]
  node_cards["FHIR record cards"]
  node_tables["FHIR record tables"]
  node_api["Fasten API client"]
  node_lighthouse["Lighthouse client"]
end

subgraph group_api["Backend API"]
  node_server["HTTP server and routes<br/>[server.go]"]
  node_authhandler["Auth handlers<br/>[auth.go]"]
  node_resourcehandler["FHIR resource handlers<br/>[resource_fhir.go]"]
  node_summaryhandler["Summary handlers<br/>[summary.go]"]
  node_encryption["Encryption key handler"]
end

subgraph group_domain["Health record domain"]
  node_query["FHIR query engine"]
  node_graph["Resource graph"]
  node_summary["Record summaries"]
  node_fhirmodels["FHIR resource models"]
end

subgraph group_infra["Persistence and security"]
  node_repository["Database repository<br/>[interface.go]"]
  node_gorm["GORM persistence<br/>[gorm_common.go]"]
  node_postgres[("PostgreSQL store")]
  node_sqlite[("SQLite store")]
  node_eventbus["Event bus<br/>[interface.go]"]
end

subgraph group_integrations["External services"]
  node_nlm["NLM terminology service"]
  node_nlmremote(("NLM LOINC forms"))
end

node_person(("Health record user"))

node_person -->|"uses"| node_app
node_app -->|"loads routes"| node_routes
node_routes -->|"routes to"| node_signin
node_routes -->|"routes to"| node_signup
node_signin -->|"signs in via"| node_authsvc
node_signup -->|"registers via"| node_authsvc
node_authsvc -->|"posts auth requests"| node_server
node_server -->|"routes auth"| node_authhandler
node_person -->|"uploads FHIR bundle"| node_sources
node_sources -->|"uses API client"| node_api
node_sources -->|"requests source authorization"| node_lighthouse
node_person -->|"views records"| node_dashboard
node_dashboard -->|"loads dashboard data"| node_api
node_dashboard -->|"loads source data"| node_lighthouse
node_history -->|"uses API client"| node_api
node_api -.->|"calls API"| node_server
node_server -->|"routes FHIR requests"| node_resourcehandler
node_server -.->|"routes summary requests"| node_summaryhandler
node_server -->|"routes key requests"| node_encryption
node_resourcehandler -.->|"uses repository"| node_repository
node_summaryhandler -.->|"retrieves summaries"| node_summary
node_query -->|"validates resource types"| node_fhirmodels
node_graph -->|"reads resource models"| node_fhirmodels
node_summary -->|"reads resource models"| node_fhirmodels
node_repository -.->|"implemented with"| node_gorm
node_gorm -.->|"persists to"| node_postgres
node_gorm -.->|"persists to"| node_sqlite
node_server -->|"configures middleware"| node_eventbus
node_nlm -->|"fetches LOINC forms"| node_nlmremote

click node_app "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/app.module.ts"
click node_routes "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/app-routing.module.ts"
click node_signin "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/auth-signin/auth-signin.component.ts"
click node_signup "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/auth-signup-wizard/auth-signup-wizard.component.ts"
click node_authsvc "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/auth.service.ts"
click node_sources "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/medical-sources/medical-sources.component.ts"
click node_dashboard "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/dashboard/dashboard.component.ts"
click node_history "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/medical-history/medical-history.component.ts"
click node_cards "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/components/fhir-card/fhir-card/fhir-card.component.ts"
click node_tables "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts"
click node_api "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/fasten-api.service.ts"
click node_lighthouse "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/lighthouse.service.ts"
click node_server "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/server.go"
click node_authhandler "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/auth.go"
click node_resourcehandler "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/resource_fhir.go"
click node_summaryhandler "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/summary.go"
click node_encryption "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/encryption_key_handler.go"
click node_query "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_query.go"
click node_graph "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_graph.go"
click node_summary "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_summary.go"
click node_fhirmodels "https://github.com/fastenhealth/fasten-onprem/tree/main/backend/pkg/models/database"
click node_repository "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/interface.go"
click node_gorm "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_common.go"
click node_postgres "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/postgres_repository.go"
click node_sqlite "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/sqlite_repository.go"
click node_eventbus "https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/event_bus/interface.go"
click node_nlm "https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/nlm-clinical-table-search.service.ts"

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_routes,node_signin,node_signup,node_authsvc,node_sources,node_dashboard,node_history,node_cards,node_tables,node_api,node_lighthouse,node_person toneBlue
class node_server,node_authhandler,node_resourcehandler,node_summaryhandler,node_encryption toneAmber
class node_query,node_graph,node_summary,node_fhirmodels toneMint
class node_repository,node_gorm,node_postgres,node_sqlite,node_eventbus toneRose
class node_nlm,node_nlmremote toneIndigo
```

## Components

### Frontend experience

- [Angular application](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/app.module.ts): `frontend/src/app/app.module.ts`
- [Page routing](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/app-routing.module.ts): `frontend/src/app/app-routing.module.ts`
- [Sign-in page](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/auth-signin/auth-signin.component.ts): `frontend/src/app/pages/auth-signin/auth-signin.component.ts`
- [Signup wizard](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/auth-signup-wizard/auth-signup-wizard.component.ts): `frontend/src/app/pages/auth-signup-wizard/auth-signup-wizard.component.ts`
- [Authentication service](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/auth.service.ts): `frontend/src/app/services/auth.service.ts`
- [Medical sources](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/medical-sources/medical-sources.component.ts): `frontend/src/app/pages/medical-sources/medical-sources.component.ts`
- [Health dashboard](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/dashboard/dashboard.component.ts): `frontend/src/app/pages/dashboard/dashboard.component.ts`
- [Medical history views](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/pages/medical-history/medical-history.component.ts): `frontend/src/app/pages/medical-history/medical-history.component.ts`
- [FHIR record cards](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/components/fhir-card/fhir-card/fhir-card.component.ts): `frontend/src/app/components/fhir-card/fhir-card/fhir-card.component.ts`
- [FHIR record tables](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts): `frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts`
- [Fasten API client](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/fasten-api.service.ts): `frontend/src/app/services/fasten-api.service.ts`
- [Lighthouse client](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/lighthouse.service.ts): `frontend/src/app/services/lighthouse.service.ts`

### Backend API

- [HTTP server and routes](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/server.go): `backend/pkg/web/server.go`
- [Auth handlers](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/auth.go): `backend/pkg/web/handler/auth.go`
- [FHIR resource handlers](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/resource_fhir.go): `backend/pkg/web/handler/resource_fhir.go`
- [Summary handlers](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/summary.go): `backend/pkg/web/handler/summary.go`
- [Encryption key handler](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/web/handler/encryption_key_handler.go): `backend/pkg/web/handler/encryption_key_handler.go`

### Health record domain

- [FHIR query engine](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_query.go): `backend/pkg/database/gorm_repository_query.go`
- [Resource graph](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_graph.go): `backend/pkg/database/gorm_repository_graph.go`
- [Record summaries](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_repository_summary.go): `backend/pkg/database/gorm_repository_summary.go`
- [FHIR resource models](https://github.com/fastenhealth/fasten-onprem/tree/main/backend/pkg/models/database): `backend/pkg/models/database`

### Persistence and security

- [Database repository](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/interface.go): `backend/pkg/database/interface.go`
- [GORM persistence](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/gorm_common.go): `backend/pkg/database/gorm_common.go`
- [PostgreSQL store](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/postgres_repository.go): `backend/pkg/database/postgres_repository.go`
- [SQLite store](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/database/sqlite_repository.go): `backend/pkg/database/sqlite_repository.go`
- [Event bus](https://github.com/fastenhealth/fasten-onprem/blob/main/backend/pkg/event_bus/interface.go): `backend/pkg/event_bus/interface.go`

### External services

- [NLM terminology service](https://github.com/fastenhealth/fasten-onprem/blob/main/frontend/src/app/services/nlm-clinical-table-search.service.ts): `frontend/src/app/services/nlm-clinical-table-search.service.ts`
- **NLM LOINC forms**

### Other components

- **Health record user**

## Connections

- Health record user → Angular application: uses
- Angular application → Page routing: loads routes (evidence: `frontend/src/app/app.module.ts`)
- Page routing → Sign-in page: routes to (evidence: `frontend/src/app/app-routing.module.ts`)
- Page routing → Signup wizard: routes to (evidence: `frontend/src/app/app-routing.module.ts`)
- Sign-in page → Authentication service: signs in via (evidence: `frontend/src/app/pages/auth-signin/auth-signin.component.ts`)
- Signup wizard → Authentication service: registers via (evidence: `frontend/src/app/pages/auth-signup-wizard/auth-signup-wizard.component.ts`)
- Authentication service → HTTP server and routes: posts auth requests (evidence: `frontend/src/app/services/auth.service.ts`)
- HTTP server and routes → Auth handlers: routes auth (evidence: `backend/pkg/web/server.go`)
- Health record user → Medical sources: uploads FHIR bundle
- Medical sources → Fasten API client: uses API client (evidence: `frontend/src/app/pages/medical-sources/medical-sources.component.ts`)
- Medical sources → Lighthouse client: requests source authorization (evidence: `frontend/src/app/pages/medical-sources/medical-sources.component.ts`)
- Health record user → Health dashboard: views records
- Health dashboard → Fasten API client: loads dashboard data (evidence: `frontend/src/app/pages/dashboard/dashboard.component.ts`)
- Health dashboard → Lighthouse client: loads source data (evidence: `frontend/src/app/pages/dashboard/dashboard.component.ts`)
- Medical history views → Fasten API client: uses API client (evidence: `frontend/src/app/pages/medical-history/medical-history.component.ts`)
- Fasten API client → HTTP server and routes: calls API
- HTTP server and routes → FHIR resource handlers: routes FHIR requests (evidence: `backend/pkg/web/server.go`)
- HTTP server and routes → Summary handlers: routes summary requests
- HTTP server and routes → Encryption key handler: routes key requests (evidence: `backend/pkg/web/server.go`)
- FHIR resource handlers → Database repository: uses repository
- Summary handlers → Record summaries: retrieves summaries
- FHIR query engine → FHIR resource models: validates resource types (evidence: `backend/pkg/database/gorm_repository_query.go`)
- Resource graph → FHIR resource models: reads resource models (evidence: `backend/pkg/database/gorm_repository_graph.go`)
- Record summaries → FHIR resource models: reads resource models (evidence: `backend/pkg/database/gorm_repository_summary.go`)
- Database repository → GORM persistence: implemented with
- GORM persistence → PostgreSQL store: persists to
- GORM persistence → SQLite store: persists to
- HTTP server and routes → Event bus: configures middleware (evidence: `backend/pkg/web/server.go`)
- NLM terminology service → NLM LOINC forms: fetches LOINC forms (evidence: `frontend/src/app/services/nlm-clinical-table-search.service.ts`)
