# dckiller51/bodymiscale architecture

> Architecture diagram of the GitHub repository dckiller51/bodymiscale, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dckiller51/bodymiscale
- Repository: https://github.com/dckiller51/bodymiscale

## Overview

Bodymiscale is a local Home Assistant integration that turns configured weight and optional impedance readings into body-composition sensor entities. The main path is configuration and profile selection, live measurement handling, mode-specific calculations, then sensor publication. The README also documents three calculation modes and interactive profile assignment. Some modules are only partially sampled, so uncertain internal call paths are omitted; unsampled capabilities are represented only where the tree or README supports them.

Main entry points: [`custom_components/bodymiscale/metrics/__init__.py`](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/__init__.py) (Metrics handler), [`custom_components/bodymiscale/__init__.py`](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/__init__.py) (Integration lifecycle), [`custom_components/bodymiscale/sensor.py`](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/sensor.py) (Metric sensors), [`custom_components/bodymiscale/profile.py`](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/profile.py) (Profile matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup &amp; Profiles"]
  node_config_flow["Integration setup<br/>[config_flow.py]"]
  node_profile["Profile matching<br/>[profile.py]"]
  node_integration["Integration lifecycle<br/>[__init__.py]"]
end

subgraph group_runtime["Measurement Runtime"]
  node_handler["Metrics handler<br/>[__init__.py]"]
  node_models["Metric definitions<br/>[models.py]"]
end

subgraph group_calculations["Calculation Engines"]
  node_weight["Weight metrics<br/>[weight.py]"]
  node_impedance["Impedance metrics<br/>[impedance.py]"]
  node_score["Body score<br/>[body_score.py]"]
  node_scale_rules["Reference scales<br/>[scale.py]"]
  node_util["Formula utilities<br/>[util.py]"]
end

subgraph group_entities["Home Assistant Entities"]
  node_sensors["Metric sensors<br/>[sensor.py]"]
  node_entities["Entity base<br/>[entity.py]"]
end

node_user(("Home Assistant user"))
node_ha(("Home Assistant"))
node_scale(("Scale sensors"))
node_notify(("Notify service"))

node_user -->|"configures"| node_config_flow
node_config_flow -->|"provides settings"| node_integration
node_ha -->|"loads integration"| node_integration
node_integration -->|"creates handler"| node_handler
node_integration -->|"registers filter"| node_profile
node_scale -->|"reports readings"| node_handler
node_handler -->|"checks profile"| node_profile
node_handler -->|"calculates weight metrics"| node_weight
node_handler -->|"calculates impedance metrics"| node_impedance
node_handler -->|"calculates score"| node_score
node_handler -->|"uses metric types"| node_models
node_weight -->|"uses formulas"| node_util
node_impedance -->|"uses constraints"| node_util
node_score -->|"uses thresholds"| node_scale_rules
node_sensors -->|"subscribes to metrics"| node_handler
node_sensors -->|"extends entity base"| node_entities
node_ha -->|"hosts sensors"| node_sensors
node_profile -.->|"sends selection prompt"| node_notify

click node_config_flow "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/config_flow.py"
click node_profile "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/profile.py"
click node_integration "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/__init__.py"
click node_handler "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/__init__.py"
click node_models "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/models.py"
click node_weight "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/weight.py"
click node_impedance "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/impedance.py"
click node_score "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/body_score.py"
click node_scale_rules "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/scale.py"
click node_util "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/util.py"
click node_sensors "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/sensor.py"
click node_entities "https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/entity.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_config_flow,node_profile,node_integration,node_user toneBlue
class node_handler,node_models toneAmber
class node_weight,node_impedance,node_score,node_scale_rules,node_util toneMint
class node_sensors,node_entities toneRose
class node_ha,node_scale,node_notify toneIndigo
```

## Components

### Setup & Profiles

- [Integration setup](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/config_flow.py): `custom_components/bodymiscale/config_flow.py`
- [Profile matching](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/profile.py): `custom_components/bodymiscale/profile.py`
- [Integration lifecycle](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/__init__.py): `custom_components/bodymiscale/__init__.py`

### Measurement Runtime

- [Metrics handler](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/__init__.py): `custom_components/bodymiscale/metrics/__init__.py`
- [Metric definitions](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/models.py): `custom_components/bodymiscale/models.py`

### Calculation Engines

- [Weight metrics](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/weight.py): `custom_components/bodymiscale/metrics/weight.py`
- [Impedance metrics](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/impedance.py): `custom_components/bodymiscale/metrics/impedance.py`
- [Body score](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/body_score.py): `custom_components/bodymiscale/metrics/body_score.py`
- [Reference scales](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/metrics/scale.py): `custom_components/bodymiscale/metrics/scale.py`
- [Formula utilities](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/util.py): `custom_components/bodymiscale/util.py`

### Home Assistant Entities

- [Metric sensors](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/sensor.py): `custom_components/bodymiscale/sensor.py`
- [Entity base](https://github.com/dckiller51/bodymiscale/blob/main/custom_components/bodymiscale/entity.py): `custom_components/bodymiscale/entity.py`

### Other components

- **Home Assistant user**
- **Home Assistant**
- **Scale sensors**
- **Notify service**

## Connections

- Home Assistant user → Integration setup: configures
- Integration setup → Integration lifecycle: provides settings
- Home Assistant → Integration lifecycle: loads integration
- Integration lifecycle → Metrics handler: creates handler
- Integration lifecycle → Profile matching: registers filter
- Scale sensors → Metrics handler: reports readings
- Metrics handler → Profile matching: checks profile
- Metrics handler → Weight metrics: calculates weight metrics
- Metrics handler → Impedance metrics: calculates impedance metrics
- Metrics handler → Body score: calculates score
- Metrics handler → Metric definitions: uses metric types
- Weight metrics → Formula utilities: uses formulas
- Impedance metrics → Formula utilities: uses constraints
- Body score → Reference scales: uses thresholds
- Metric sensors → Metrics handler: subscribes to metrics
- Metric sensors → Entity base: extends entity base
- Home Assistant → Metric sensors: hosts sensors
- Profile matching → Notify service: sends selection prompt
