# department-of-veterans-affairs/health-apis-smart-cards architecture

> Architecture diagram of the GitHub repository department-of-veterans-affairs/health-apis-smart-cards, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/department-of-veterans-affairs/health-apis-smart-cards
- Repository: https://github.com/department-of-veterans-affairs/health-apis-smart-cards

## Overview

##### Main Components

a. External Components:
- API Gateway/Kong (Authentication & Rate Limiting)
- Data Query API (FHIR-compliant health data)
- Datamart/Corporate Data Warehouse (Source data storage)

b. Internal Components:
- Smart Cards Core Service
- PEM to JWK Converter
- Mock Services (for development/testing)
- Integration Tests

**Client Layer**

**Gateway Layer (Kong)**

**Application Layer (Smart Cards)**

**Integration Layer (Data Query)**

**Data Layer (Datamart)**

##### Component Details to Highlight

a. Smart Cards Core Service:
- Controllers Package (MetadataController, PatientController, WellKnownController)
- Security Components (PayloadSigner, JwksProperties)
- Data Processing (ImmunizationMinimizer, PatientMinimizer)
- FHIR Client Integration (DataQueryFhirClient)

b. Supporting Services:
- PEM-to-JWK Converter utility
- Mock Services for testing
- Integration test suite

##### Flow Representation

- Incoming requests through Kong
- Authentication flow
- Data retrieval path from Datamart through Data Query
- Health card issuance flow

##### Additional Elements

Specific annotations for:
- SMART-on-FHIR OAuth scope enforcement points
- Verifiable credential generation points
- Data minimization processing
- Key conversion processes

##### Technical Details to Note

- Spring Boot application context
- FHIR compliance points
- JWT/JWK handling
- Health Cards Framework compliance

Key Considerations:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    Client(("Client")):::client

    %% Gateway Layer
    subgraph Gateway
        Kong["API Gateway (Kong)"]:::gateway
    end

    %% Application Layer
    subgraph SmartCards["Smart Cards Core Service"]
        Controllers["Controllers"]:::core
        Security["Security Components"]:::security
        DataProcessing["Data Processing"]:::core
        FHIRClient["FHIR Client Integration"]:::core

        %% Controllers Detail
        subgraph Controllers
            MetadataController["Metadata Controller"]:::controller
            PatientController["Patient Controller"]:::controller
            WellKnownController["Well Known Controller"]:::controller
        end

        %% Security Detail
        subgraph Security
            PayloadSigner["Payload Signer"]:::security
            JwksProperties["JWKS Properties"]:::security
        end

        %% Data Processing Detail
        subgraph DataProcessing
            ImmunizationMinimizer["Immunization Minimizer"]:::processor
            PatientMinimizer["Patient Minimizer"]:::processor
        end
    end

    %% Supporting Services
    subgraph Support["Supporting Services"]
        PemJwkConverter["PEM to JWK Converter"]:::utility
        MockServices["Mock Services"]:::testing
        IntegrationTests["Integration Tests"]:::testing
    end

    %% Integration Layer
    DataQueryAPI["Data Query API"]:::external

    %% Data Layer
    Datamart[(Corporate Data Warehouse)]:::database

    %% Relationships
    Client --> Kong
    Kong --> Controllers
    Controllers --> Security
    Controllers --> DataProcessing
    DataProcessing --> FHIRClient
    FHIRClient --> DataQueryAPI
    DataQueryAPI --> Datamart
    Security --> PemJwkConverter
    MockServices --> IntegrationTests

    %% Click Events
    click Controllers "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/tree/master//smart-cards/src/main/java/gov/va/api/health/smartcards/"
    click MetadataController "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/MetadataR4Controller.java"
    click PatientController "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/PatientController.java"
    click WellKnownController "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/WellKnownController.java"
    click PayloadSigner "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/PayloadSigner.java"
    click JwksProperties "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/JwksProperties.java"
    click ImmunizationMinimizer "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/ImmunizationMinimizer.java"
    click PatientMinimizer "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/PatientMinimizer.java"
    click FHIRClient "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/blob/master//smart-cards/src/main/java/gov/va/api/health/smartcards/DataQueryFhirClient.java"
    click PemJwkConverter "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/tree/master//pem-to-jwk/"
    click MockServices "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/tree/master//smart-cards-mock-services/"
    click IntegrationTests "https://github.com/department-of-veterans-affairs/health-apis-smart-cards/tree/master//smart-cards-tests/"

    %% Styles
    classDef client fill:#E1F5FE,stroke:#01579B
    classDef gateway fill:#B2DFDB,stroke:#004D40
    classDef core fill:#90CAF9,stroke:#1565C0
    classDef security fill:#FFE0B2,stroke:#E65100
    classDef controller fill:#90CAF9,stroke:#1565C0
    classDef processor fill:#81D4FA,stroke:#01579B
    classDef utility fill:#B2EBF2,stroke:#006064
    classDef testing fill:#FFCCBC,stroke:#BF360C
    classDef external fill:#C8E6C9,stroke:#1B5E20
    classDef database fill:#E0E0E0,stroke:#212121
```
