# carekit-apple/carekit architecture

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

- Interactive diagram: https://gitdiagram.com/carekit-apple/carekit
- Repository: https://github.com/carekit-apple/carekit

## Overview

- CareKit – the core framework that ties the user interface and data store together using synchronized view controllers.
- CareKitUI – a package offering a rich set of customizable views (cards, charts, contacts, etc.) for building the app’s presentation layer.
- CareKitStore – the persistent layer built on Core Data (with versioning support, scheduling, and CRUD operations) that manages patients, tasks, contacts, outcomes, and associated entities.
- CareKitFHIR – a specialized package that extends CareKit for interoperability with FHIR standards (healthcare data exchange).

##### Main Components
– Represent each of the core packages (CareKit, CareKitUI, CareKitStore, CareKitFHIR) as distinct modules.
– Optionally include components like the sample apps (OCKCatalog and OCKSample) that demonstrate how the framework modules are used.
– Mark out support for workflows (e.g., build configuration, Swift Package Manager integration, automated CI in .github/workflows).

##### Relationships and Interactions
– Indicate that CareKitFHIR builds on top of CareKit’s models (for FHIR resource mapping) and may interact with the store and other modules.
– Where appropriate, show that the UI components (from CareKitUI) display data that is stored and versioned in CareKitStore.
– Highlight integration with system-level services (e.g., HealthKit) as part of CareKitStore’s functionality.

##### Architectural Patterns
– Note that the architecture employs a modular design, where each package can be imported independently using Swift Package Manager.
– Indicate the versioned, append-only data store design in CareKitStore (along with scheduled tasks and CRUD operations).
– Optionally include how custom view synchronizers or adapters can be injected, demonstrating extensibility.

##### Relevant Technologies and Frameworks
– Swift Package Manager as the package distribution mechanism.
– Xcode project management and scheme configuration (visible in the file tree).
– Core Data as the persistent storage solution within CareKitStore.
– Combine (used by CareKit for synchronization between the store and UI).
– HealthKit and FHIR integration components for specialized healthcare data.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "CI & Build Config"
        CI_GW("GitHub Workflows"):::ci
        CI_SP("SwiftPM Config (.swiftpm)"):::ci
        CI_PF("Package Files (Package.swift & Package.resolved)"):::ci
    end

    SA("Sample Apps"):::sample

    CK("CareKit (Core Framework)"):::core

    subgraph "CareKitUI"
        UI("CareKitUI (Presentation Layer)"):::ui
        UI1("Task Cards"):::ui
        UI2("Chart Cards"):::ui
        UI3("Contact Views"):::ui
    end

    subgraph "CareKitStore"
        Store("CareKitStore (Persistent Data Store)"):::store
        ST1("Core Data"):::store
        ST2("CRUD Operations & Scheduling"):::store
        ST3("HealthKit Integration"):::store
    end

    FHIR("CareKitFHIR (FHIR Extensions)"):::fhir

    CI_GW --> CK
    CI_SP --> CK
    CI_PF --> CK

    SA --> CK

    CK -->|"ties_to"| UI
    CK -->|"synchronizes_with"| Store

    Store -->|"updates"| UI

    FHIR -->|"extends"| CK
    FHIR -->|"maps_to"| Store

    UI --> UI1
    UI --> UI2
    UI --> UI3

    Store --> ST1
    Store --> ST2
    Store --> ST3

    classDef core fill:#ffcc99,stroke:#ff9900,stroke-width:2px;
    classDef ui fill:#ccffff,stroke:#3399ff,stroke-width:2px;
    classDef store fill:#ccffcc,stroke:#33cc33,stroke-width:2px;
    classDef fhir fill:#ffffcc,stroke:#ffcc00,stroke-width:2px;
    classDef ci fill:#e6e6e6,stroke:#999999,stroke-width:2px;
    classDef sample fill:#ffccff,stroke:#ff66ff,stroke-width:2px;

    click CK "https://github.com/carekit-apple/carekit/tree/main/CareKit/"
    click UI "https://github.com/carekit-apple/carekit/tree/main/CareKitUI/"
    click Store "https://github.com/carekit-apple/carekit/tree/main/CareKitStore/"
    click FHIR "https://github.com/carekit-apple/carekit/tree/main/CareKitFHIR/"
    click CI_GW "https://github.com/carekit-apple/carekit/tree/main/.github/workflows/"
    click CI_SP "https://github.com/carekit-apple/carekit/tree/main/.swiftpm/"
    click CI_PF "https://github.com/carekit-apple/carekit/blob/main/Package.swift"
```
