# iantrich/config-template-card architecture

> Architecture diagram of the GitHub repository iantrich/config-template-card, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iantrich/config-template-card
- Repository: https://github.com/iantrich/config-template-card

## Overview

##### Main Components
a. Source Code Module: Represent the core business logic implemented as TypeScript files (e.g., config-template-card.ts, const.ts, types.ts) inside the src/ directory.
b. Build and Packaging Pipeline: Include the build configuration (package.json scripts, Rollup config files) which compile the TS source into a bundled JavaScript module.
c. Development Environment: Note the presence of development containers (.devcontainer), VS Code settings (.vscode), and code style files (ESLint, Prettier). These ensure a standardized and clean development process.
d. Integration & Distribution: Highlight that this card is packaged and distributed (via HACS, GitHub releases, and installation instructions in the README) to be loaded as a module resource in Home Assistant’s front end.
e. GitHub and CI/CD: Indicate the GitHub-specific configurations (workflows for build and release, issue templates, and licensing) that support the project lifecycle.

##### Relationships and Interactions
- That the source code is developed in TypeScript, then passed through the Rollup build process to create the final JavaScript module.
- How Home Assistant (the external system) integrates this card by loading the generated JS file as a resource (via the configuration “custom:config-template-card”) and then interacting with the Home Assistant state and entity objects.

##### Architectural Patterns & Design Principles
- Modularity: The logic is split into multiple files (constants, types, main implementation), emphasizing separation of concerns.
- Build Pipeline & Automation: The project makes use of automated CI/CD workflows (GitHub workflows) to ensure continuous integration and releases.
- Client-Side Integration: Clearly, the card is a front-end UI component that integrates with a larger Home Assistant architecture, designed for dynamic behavior based on Home Assistant state.

##### Technologies, Frameworks, or Libraries
- Home Assistant Lovelace: The card integrates directly with Home Assistant’s front-end.
- TypeScript: Source code written in TypeScript with its associated tsconfig.json.
- Rollup: The module bundler is used to produce the final build files.
- HACS: The integration is designed to work with the Home Assistant Community Store.
- Development tools: ESLint, Prettier, and editor-specific configurations ensure code quality.

##### Specific Elements
- Use clear labels for:
- Source Code (src/) with its components: config-template-card.ts, const.ts, types.ts.
- Build System / Pipeline (Rollup configurations, package.json scripts).
- Development Tools/Environment (.devcontainer, .vscode, configuration files for ESLint and Prettier).
- Distribution/Integration (HACS JSON, usage instructions in README, and the deployment of the built JS file that Home Assistant consumes).
- CI/CD and Version Control (GitHub workflows, issue templates, licensing).
- From code commit → build process → bundled artifact → integration into Home Assistant.
- From Home Assistant state (hass, states, etc.) flowing into the template processing logic of the custom card.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Environment
    subgraph "Development Environment"
        DevContainer[".devcontainer/"]:::dev
        VSCode[".vscode/"]:::dev
        ESLint[".eslintrc.js"]:::dev
        Prettier[".prettierrc.js"]:::dev
    end

    %% Source Code Module (TypeScript)
    subgraph "Source Code Module (TS)"
        SourceCode["src/"]:::code
        ConfigCard["config-template-card.ts"]:::code
        ConstFile["const.ts"]:::code
        TypesFile["types.ts"]:::code
    end

    %% Build & Packaging Pipeline
    subgraph "Build & Packaging Pipeline"
        PackageJSON["package.json scripts"]:::build
        Rollup["rollup.config.js"]:::build
        RollupDev["rollup.config.dev.js"]:::build
    end

    %% GitHub & CI/CD
    subgraph "GitHub & CI/CD"
        GitHub[".github/"]:::ci
        BuildWorkflow["workflows/build.yml"]:::ci
        ReleaseWorkflow["workflows/release.yml"]:::ci
        IssueTemplate["ISSUE_TEMPLATE"]:::ci
    end

    %% Integration & Distribution
    subgraph "Integration & Distribution"
        Hacs["hacs.json"]:::dist
        Readme["README.md"]:::dist
        BuiltArtifact["Built JavaScript Module"]:::dist
    end

    %% External System
    subgraph "External System"
        HomeAssistant["Home Assistant"]:::external
    end

    %% Connections from Development Environment to Source Code
    DevContainer -->|"supports"| SourceCode
    VSCode -->|"supports"| SourceCode
    ESLint -->|"ensures quality for"| SourceCode
    Prettier -->|"formats"| SourceCode

    %% Source Code internal structure
    SourceCode -->|"contains"| ConfigCard
    SourceCode -->|"contains"| ConstFile
    SourceCode -->|"contains"| TypesFile

    %% Build Pipeline: Source Code is processed by package scripts and Rollup configs
    SourceCode -->|"processedBy"| PackageJSON
    PackageJSON -->|"triggers"| Rollup
    PackageJSON -->|"triggers"| RollupDev
    Rollup -->|"outputs"| BuiltArtifact
    RollupDev -->|"outputs"| BuiltArtifact

    %% GitHub & CI/CD influence the Build Process
    GitHub -->|"executes"| BuildWorkflow
    GitHub -->|"executes"| ReleaseWorkflow
    GitHub -->|"manages"| IssueTemplate
    BuildWorkflow -->|"invokes"| PackageJSON
    ReleaseWorkflow -->|"invokes"| PackageJSON

    %% Distribution: Built Artifact is packaged and paired with integration files
    BuiltArtifact -->|"packaged with"| Hacs
    BuiltArtifact -->|"packaged with"| Readme

    %% Home Assistant Integration
    Hacs -->|"loads card via"| HomeAssistant
    Readme -->|"provides instructions to"| HomeAssistant
    BuiltArtifact -->|"integrated into"| HomeAssistant

    %% Click Events (paths not shown in diagram)
    click SourceCode "https://github.com/iantrich/config-template-card/tree/master/src/"
    click ConfigCard "https://github.com/iantrich/config-template-card/blob/master/src/config-template-card.ts"
    click ConstFile "https://github.com/iantrich/config-template-card/blob/master/src/const.ts"
    click TypesFile "https://github.com/iantrich/config-template-card/blob/master/src/types.ts"
    
    click Rollup "https://github.com/iantrich/config-template-card/blob/master/rollup.config.js"
    click RollupDev "https://github.com/iantrich/config-template-card/blob/master/rollup.config.dev.js"
    click PackageJSON "https://github.com/iantrich/config-template-card/blob/master/package.json"
    
    click DevContainer "https://github.com/iantrich/config-template-card/tree/master/.devcontainer/"
    click VSCode "https://github.com/iantrich/config-template-card/tree/master/.vscode/"
    click ESLint "https://github.com/iantrich/config-template-card/blob/master/.eslintrc.js"
    click Prettier "https://github.com/iantrich/config-template-card/blob/master/.prettierrc.js"
    
    click Hacs "https://github.com/iantrich/config-template-card/blob/master/hacs.json"
    click Readme "https://github.com/iantrich/config-template-card/blob/master/README.md"
    
    click GitHub "https://github.com/iantrich/config-template-card/tree/master/.github/"
    click BuildWorkflow "https://github.com/iantrich/config-template-card/blob/master/.github/workflows/build.yml"
    click ReleaseWorkflow "https://github.com/iantrich/config-template-card/blob/master/.github/workflows/release.yml"
    click IssueTemplate "https://github.com/iantrich/config-template-card/tree/master/.github/ISSUE_TEMPLATE"
    
    %% Styles
    classDef dev fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef code fill:#A9DFBF,stroke:#186A3B,stroke-width:2px;
    classDef build fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ci fill:#F5CBA7,stroke:#CB4335,stroke-width:2px;
    classDef dist fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
