# cmsgov/bluebutton-web-server architecture

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

- Interactive diagram: https://gitdiagram.com/cmsgov/bluebutton-web-server
- Repository: https://github.com/cmsgov/bluebutton-web-server

## Overview

Blue Button Web Server is a Django data provider that lets beneficiaries securely share Medicare claims data with third-party applications. The documented flow is beneficiary authentication through Medicare.gov, OAuth2 authorization and permission-grant validation, then versioned FHIR API access backed by an external FHIR server. The graph also preserves application registration/discovery, identity crosswalks, and operational logging. Internal edges are limited to relationships visible in excerpts or SOURCE INDEX references; several route-to-view and runtime configuration links are not shown.

Main entry points: [`apps/fhir/bluebutton/views/generic.py`](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/views/generic.py) (FHIR Resource Views), [`apps/dot_ext/views/authorization.py`](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/views/authorization.py) (OAuth Authorization), [`apps/dot_ext/forms.py`](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/forms.py) (OAuth Forms), [`apps/dot_ext/models.py`](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/models.py) (OAuth Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and Grants"]
  node_accounts[("Accounts and Profiles<br/>[models.py]")]
  node_medicare_auth["Medicare Callback<br/>[authorization.py]"]
  node_grants[("Access Grants<br/>[models.py]")]
  node_grant_permissions["Grant Permissions<br/>[permissions.py]"]
  node_crosswalk[("Beneficiary Crosswalk<br/>[models.py]")]
end

subgraph group_oauth["OAuth Applications"]
  node_oauth_views["OAuth Authorization<br/>[authorization.py]"]
  node_oauth_forms["OAuth Forms<br/>[forms.py]"]
  node_oauth_app_views["App Registration<br/>[application.py]"]
  node_oauth_models[("OAuth Models<br/>[models.py]")]
  node_scopes["Scopes<br/>[scopes.py]"]
  node_capabilities[("Capabilities<br/>[models.py]")]
  node_cap_permissions["Capability Permissions<br/>[permissions.py]"]
  node_token_flow["OAuth Token Flow<br/>[oauth2_server.py]"]
  node_app_discovery["Public App Discovery<br/>[application.py]"]
end

subgraph group_api["FHIR Data API"]
  node_fhir_views["FHIR Resource Views<br/>[generic.py]"]
  node_fhir_permissions["FHIR Permissions<br/>[permissions.py]"]
  node_fhir_search["FHIR Search<br/>[search.py]"]
  node_fhir_auth["FHIR Server Authentication<br/>[authentication.py]"]
  node_versions["API Versions<br/>[versions.py]"]
end

subgraph group_integrations["External Integrations"]
  node_medicare["Medicare.gov"]
  node_bfd["Backend FHIR"]
end

subgraph group_operations["Logging and Operations"]
  node_request_logging["Request Logging<br/>[request_logger.py]"]
  node_its_log["ITS Log Handler<br/>[its_log_handler.py]"]
end

node_beneficiary(("Beneficiary"))
node_developer_app["Third-Party App"]
node_django["Django Server"]

node_beneficiary -->|"signs in"| node_medicare_auth
node_medicare_auth -->|"authenticates with"| node_medicare
node_developer_app -->|"requests authorization"| node_oauth_views
node_oauth_views -.->|"validates grants"| node_grant_permissions
node_oauth_views -->|"uses forms"| node_oauth_forms
node_oauth_forms -->|"validates application"| node_oauth_models
node_oauth_forms -->|"uses scopes"| node_scopes
node_oauth_forms -->|"checks capabilities"| node_capabilities
node_oauth_app_views -->|"registers applications"| node_oauth_forms
node_oauth_app_views -.->|"manages applications"| node_oauth_models
node_oauth_models -->|"references capabilities"| node_capabilities
node_oauth_views -.->|"issues OAuth tokens"| node_token_flow
node_beneficiary -->|"requests claims data"| node_fhir_views
node_developer_app -->|"requests claims data"| node_fhir_views
node_fhir_views -.->|"checks access"| node_fhir_permissions
node_fhir_search -->|"delegates resource handling"| node_fhir_views
node_fhir_search -->|"checks grant access"| node_grant_permissions
node_fhir_search -->|"checks capabilities"| node_cap_permissions
node_fhir_permissions -->|"checks capability records"| node_capabilities
node_fhir_auth -->|"queries patient"| node_bfd
node_fhir_views -->|"fetches FHIR data"| node_bfd
node_fhir_views -.->|"resolves beneficiary IDs"| node_crosswalk
node_fhir_views -->|"supports API versions"| node_versions
node_app_discovery -->|"lists applications"| node_oauth_models
node_oauth_views -.->|"records requests"| node_request_logging
node_request_logging -.->|"formats and posts logs"| node_its_log

click node_accounts "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/accounts/models.py"
click node_medicare_auth "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/mymedicare_cb/authorization.py"
click node_grants "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/authorization/models.py"
click node_grant_permissions "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/authorization/permissions.py"
click node_crosswalk "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/models.py"
click node_oauth_views "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/views/authorization.py"
click node_oauth_forms "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/forms.py"
click node_oauth_app_views "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/views/application.py"
click node_oauth_models "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/models.py"
click node_scopes "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/scopes.py"
click node_capabilities "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/capabilities/models.py"
click node_cap_permissions "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/capabilities/permissions.py"
click node_token_flow "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/pkce/oauth2_server.py"
click node_fhir_views "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/views/generic.py"
click node_fhir_permissions "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/permissions.py"
click node_fhir_search "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/views/search.py"
click node_fhir_auth "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/server/authentication.py"
click node_versions "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/versions.py"
click node_app_discovery "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/wellknown/views/application.py"
click node_request_logging "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/logging/request_logger.py"
click node_its_log "https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/logging/its_log_handler.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_accounts,node_medicare_auth,node_grants,node_grant_permissions,node_crosswalk toneBlue
class node_oauth_views,node_oauth_forms,node_oauth_app_views,node_oauth_models,node_scopes,node_capabilities,node_cap_permissions,node_token_flow,node_app_discovery toneAmber
class node_fhir_views,node_fhir_permissions,node_fhir_search,node_fhir_auth,node_versions,node_django toneMint
class node_medicare,node_bfd toneRose
class node_request_logging,node_its_log,node_beneficiary,node_developer_app toneIndigo
```

## Components

### Identity and Grants

- [Accounts and Profiles](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/accounts/models.py): `apps/accounts/models.py`
- [Medicare Callback](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/mymedicare_cb/authorization.py): `apps/mymedicare_cb/authorization.py`
- [Access Grants](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/authorization/models.py): `apps/authorization/models.py`
- [Grant Permissions](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/authorization/permissions.py): `apps/authorization/permissions.py`
- [Beneficiary Crosswalk](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/models.py): `apps/fhir/bluebutton/models.py`

### OAuth Applications

- [OAuth Authorization](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/views/authorization.py): `apps/dot_ext/views/authorization.py`
- [OAuth Forms](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/forms.py): `apps/dot_ext/forms.py`
- [App Registration](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/views/application.py): `apps/dot_ext/views/application.py`
- [OAuth Models](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/models.py): `apps/dot_ext/models.py`
- [Scopes](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/dot_ext/scopes.py): `apps/dot_ext/scopes.py`
- [Capabilities](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/capabilities/models.py): `apps/capabilities/models.py`
- [Capability Permissions](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/capabilities/permissions.py): `apps/capabilities/permissions.py`
- [OAuth Token Flow](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/pkce/oauth2_server.py): `apps/pkce/oauth2_server.py`
- [Public App Discovery](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/wellknown/views/application.py): `apps/wellknown/views/application.py`

### FHIR Data API

- [FHIR Resource Views](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/views/generic.py): `apps/fhir/bluebutton/views/generic.py`
- [FHIR Permissions](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/permissions.py): `apps/fhir/bluebutton/permissions.py`
- [FHIR Search](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/bluebutton/views/search.py): `apps/fhir/bluebutton/views/search.py`
- [FHIR Server Authentication](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/fhir/server/authentication.py): `apps/fhir/server/authentication.py`
- [API Versions](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/versions.py): `apps/versions.py`

### External Integrations

- **Medicare.gov**
- **Backend FHIR**

### Logging and Operations

- [Request Logging](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/logging/request_logger.py): `apps/logging/request_logger.py`
- [ITS Log Handler](https://github.com/cmsgov/bluebutton-web-server/blob/master/apps/logging/its_log_handler.py): `apps/logging/its_log_handler.py`

### Other components

- **Beneficiary**
- **Third-Party App**
- **Django Server**

## Connections

- Beneficiary → Medicare Callback: signs in
- Medicare Callback → Medicare.gov: authenticates with
- Third-Party App → OAuth Authorization: requests authorization
- OAuth Authorization → Grant Permissions: validates grants
- OAuth Authorization → OAuth Forms: uses forms
- OAuth Forms → OAuth Models: validates application (evidence: `apps/dot_ext/forms.py`)
- OAuth Forms → Scopes: uses scopes (evidence: `apps/dot_ext/forms.py`)
- OAuth Forms → Capabilities: checks capabilities (evidence: `apps/dot_ext/forms.py`)
- App Registration → OAuth Forms: registers applications (evidence: `apps/dot_ext/views/application.py`)
- App Registration → OAuth Models: manages applications
- OAuth Models → Capabilities: references capabilities (evidence: `apps/dot_ext/models.py`)
- OAuth Authorization → OAuth Token Flow: issues OAuth tokens
- Beneficiary → FHIR Resource Views: requests claims data
- Third-Party App → FHIR Resource Views: requests claims data
- FHIR Resource Views → FHIR Permissions: checks access
- FHIR Search → FHIR Resource Views: delegates resource handling (evidence: `apps/fhir/bluebutton/views/search.py`)
- FHIR Search → Grant Permissions: checks grant access (evidence: `apps/fhir/bluebutton/views/search.py`)
- FHIR Search → Capability Permissions: checks capabilities (evidence: `apps/fhir/bluebutton/views/search.py`)
- FHIR Permissions → Capabilities: checks capability records (evidence: `apps/fhir/bluebutton/permissions.py`)
- FHIR Server Authentication → Backend FHIR: queries patient (evidence: `apps/fhir/server/authentication.py`)
- FHIR Resource Views → Backend FHIR: fetches FHIR data
- FHIR Resource Views → Beneficiary Crosswalk: resolves beneficiary IDs
- FHIR Resource Views → API Versions: supports API versions
- Public App Discovery → OAuth Models: lists applications (evidence: `apps/wellknown/views/application.py`)
- OAuth Authorization → Request Logging: records requests
- Request Logging → ITS Log Handler: formats and posts logs
