# cmsgov/ab2d architecture

> Architecture diagram of the GitHub repository cmsgov/ab2d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cmsgov/ab2d
- Repository: https://github.com/cmsgov/ab2d

## Overview

##### Main Components

a) API Layer (api module):
- REST Controllers (v1 and v2 endpoints)
- Security components (JWT authentication)
- Health check endpoints
- OpenAPI/Swagger configuration

b) Worker Service (worker module):
- Job processing components
- Coverage processing
- BFD (Beneficiary FHIR Data) health checks
- File service operations
- Quartz scheduler jobs

c) Common Services (common module):
- Database entities and repositories
- Shared DTOs
- Property management
- Health monitoring

d) External Integration Points:
- PostgreSQL database
- AWS services (indicated by LocalStack in testing)
- BFD (Beneficiary FHIR Data) service

##### Specific Component Relationships

**[Client Applications] → [API Service]**
- ↓
**[Database] ← → [Common Module] ← → [Worker Service]**
- ↓
- [External Services]
- BFD Service
- AWS Services

##### Key Elements to Highlight

a) Security Layer:
- JWT authentication
- Client authorization
- Security filters

b) Processing Pipeline:
- Job preprocessing
- Contract processing
- Claims processing
- Coverage verification

c) Data Management:
- Coverage snapshots
- Job status tracking
- File management

##### Technical Details

- Spring Boot applications
- Quartz scheduler jobs
- FHIR data handling
- PostgreSQL database
- AWS integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        C[Client Applications]:::client
    end

    subgraph API_Layer["API Layer"]
        REST["REST Controllers"]:::api
        SEC["Security Components"]:::security
        HC["Health Checks"]:::monitoring
        OAC["OpenAPI Config"]:::config
    end

    subgraph Worker_Service["Worker Service"]
        JP["Job Processing"]:::worker
        CP["Coverage Processing"]:::worker
        BHC["BFD Health Checks"]:::monitoring
        FS["File Service"]:::worker
        QS["Quartz Scheduler"]:::worker
    end

    subgraph Common_Services["Common Services"]
        DE["Database Entities"]:::common
        DTO["Shared DTOs"]:::common
        PM["Properties Management"]:::common
        HM["Health Monitoring"]:::common
    end

    subgraph Job_Management["Job Management"]
        JM["Job Models"]:::job
        JS["Job Services"]:::job
        JR["Job Repository"]:::job
    end

    subgraph Coverage_Management["Coverage Management"]
        CM["Coverage Models"]:::coverage
        CS["Coverage Services"]:::coverage
        CR["Coverage Repository"]:::coverage
    end

    subgraph External_Services["External Services"]
        DB[(PostgreSQL)]:::database
        AWS["AWS Services"]:::external
        BFD["BFD Service"]:::external
    end

    C --> REST
    REST --> SEC
    REST --> HC
    REST --> OAC

    JP --> BHC
    JP --> FS
    JP --> QS
    CP --> BHC

    DE --> DB
    DTO --> JP
    PM --> JP
    HM --> HC

    JM --> JP
    JS --> JP
    JR --> DB

    CM --> CP
    CS --> CP
    CR --> DB

    JP --> BFD
    JP --> AWS

    %% Click Events
    click REST "https://github.com/CMSgov/ab2d/tree/main/api/src/main/java/gov/cms/ab2d/api/controller/"
    click SEC "https://github.com/CMSgov/ab2d/tree/main/api/src/main/java/gov/cms/ab2d/api/security/"
    click HC "https://github.com/CMSgov/ab2d/blob/main/api/src/main/java/gov/cms/ab2d/api/controller/HealthAPI.java"
    click OAC "https://github.com/CMSgov/ab2d/blob/main/api/src/main/java/gov/cms/ab2d/api/config/OpenAPIConfig.java"
    click JP "https://github.com/CMSgov/ab2d/tree/main/worker/src/main/java/gov/cms/ab2d/worker/processor/"
    click CP "https://github.com/CMSgov/ab2d/tree/main/worker/src/main/java/gov/cms/ab2d/worker/processor/coverage/"
    click BHC "https://github.com/CMSgov/ab2d/tree/main/worker/src/main/java/gov/cms/ab2d/worker/bfdhealthcheck/"
    click FS "https://github.com/CMSgov/ab2d/blob/main/worker/src/main/java/gov/cms/ab2d/worker/service/FileServiceImpl.java"
    click QS "https://github.com/CMSgov/ab2d/tree/main/worker/src/main/java/gov/cms/ab2d/worker/quartz/"
    click DE "https://github.com/CMSgov/ab2d/tree/main/common/src/main/java/gov/cms/ab2d/common/model/"
    click DTO "https://github.com/CMSgov/ab2d/tree/main/common/src/main/java/gov/cms/ab2d/common/dto/"
    click PM "https://github.com/CMSgov/ab2d/tree/main/common/src/main/java/gov/cms/ab2d/common/properties/"
    click HM "https://github.com/CMSgov/ab2d/tree/main/common/src/main/java/gov/cms/ab2d/common/health/"
    click JM "https://github.com/CMSgov/ab2d/tree/main/job/src/main/java/gov/cms/ab2d/job/model/"
    click JS "https://github.com/CMSgov/ab2d/tree/main/job/src/main/java/gov/cms/ab2d/job/service/"
    click JR "https://github.com/CMSgov/ab2d/tree/main/job/src/main/java/gov/cms/ab2d/job/repository/"
    click CM "https://github.com/CMSgov/ab2d/tree/main/coverage/src/main/java/gov/cms/ab2d/coverage/model/"
    click CS "https://github.com/CMSgov/ab2d/tree/main/coverage/src/main/java/gov/cms/ab2d/coverage/service/"
    click CR "https://github.com/CMSgov/ab2d/tree/main/coverage/src/main/java/gov/cms/ab2d/coverage/repository/"
    click DB "https://github.com/CMSgov/ab2d/blob/main/common/src/main/resources/db/changelog/db.changelog-master.yaml"

    %% Styling
    classDef client fill:#E1F5FE,stroke:#01579B
    classDef api fill:#B3E5FC,stroke:#0288D1
    classDef security fill:#FFE0B2,stroke:#F57C00
    classDef monitoring fill:#C8E6C9,stroke:#388E3C
    classDef config fill:#E1BEE7,stroke:#7B1FA2
    classDef worker fill:#81C784,stroke:#2E7D32
    classDef common fill:#B39DDB,stroke:#512DA8
    classDef job fill:#90CAF9,stroke:#1976D2
    classDef coverage fill:#9FA8DA,stroke:#303F9F
    classDef database fill:#FFF59D,stroke:#FBC02D
    classDef external fill:#BDBDBD,stroke:#616161
```
