# zubir2k/homeassistant-mutiarahadith architecture

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

- Interactive diagram: https://gitdiagram.com/zubir2k/homeassistant-mutiarahadith
- Repository: https://github.com/zubir2k/homeassistant-mutiarahadith

## Overview

This Home Assistant integration fetches JAKIM’s currently featured hadith from MyHadith, exposes its content and metadata as a sensor, and displays it with a bundled dashboard card. Setup validates the selected source; the integration then creates a backend and coordinator for scheduled updates. The README also documents a key-gated API mode, interval options, reconfiguration, and diagnostics. API-mode featured retrieval is explicitly not implemented yet. Edges reflect calls or documented behavior visible in the excerpts; unsampled modules are represented only where the README establishes the capability.

Main entry points: [`custom_components/mutiara_hadith/__init__.py`](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/__init__.py) (Integration lifecycle), [`custom_components/mutiara_hadith/coordinator.py`](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/coordinator.py) (Scheduled coordinator), [`custom_components/mutiara_hadith/client.py`](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py) (Website scraper), [`custom_components/mutiara_hadith/config_flow.py`](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/config_flow.py) (Setup and reconfigure)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and lifecycle"]
  node_entry_flow["Setup and reconfigure<br/>[config_flow.py]"]
  node_interval_options["Refresh options<br/>[config_flow.py]"]
  node_integration_lifecycle["Integration lifecycle<br/>[__init__.py]"]
  node_diagnostics["Redacted diagnostics<br/>[diagnostics.py]"]
end

subgraph group_fetch["Hadith retrieval"]
  node_coordinator["Scheduled coordinator<br/>[coordinator.py]"]
  node_scrape_backend["Website scraper<br/>[client.py]"]
  node_html_parsing["Hadith parsing<br/>[client.py]"]
  node_api_backend["Key-gated API backend<br/>[client.py]"]
end

subgraph group_presentation["Home Assistant presentation"]
  node_sensor["Hadith sensor<br/>[sensor.py]"]
  node_dashboard_card["Dashboard card"]
end

node_user(("Home Assistant user"))
node_myhadith{{"MyHadith service"}}
node_home_assistant(("Home Assistant"))

node_user -->|"configures"| node_entry_flow
node_entry_flow -->|"validates source"| node_scrape_backend
node_entry_flow -->|"validates key"| node_api_backend
node_user -->|"sets interval"| node_interval_options
node_integration_lifecycle -->|"creates"| node_coordinator
node_integration_lifecycle -->|"selects backend"| node_scrape_backend
node_integration_lifecycle -->|"selects backend"| node_api_backend
node_coordinator -->|"fetches featured"| node_scrape_backend
node_coordinator -->|"fetches featured"| node_api_backend
node_scrape_backend -->|"requests pages"| node_myhadith
node_scrape_backend -->|"parses responses"| node_html_parsing
node_api_backend -->|"requests JSON"| node_myhadith
node_integration_lifecycle -->|"forwards platform"| node_sensor
node_sensor -->|"reads update data"| node_coordinator
node_integration_lifecycle -->|"registers frontend"| node_dashboard_card
node_dashboard_card -->|"renders entity"| node_sensor
node_diagnostics -->|"reads status"| node_coordinator
node_home_assistant -->|"loads integration"| node_integration_lifecycle

click node_entry_flow "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/config_flow.py"
click node_interval_options "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/config_flow.py"
click node_integration_lifecycle "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/__init__.py"
click node_diagnostics "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/diagnostics.py"
click node_coordinator "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/coordinator.py"
click node_scrape_backend "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py"
click node_html_parsing "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py"
click node_api_backend "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py"
click node_sensor "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/sensor.py"
click node_dashboard_card "https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/frontend/mutiara-hadith-card.js"

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_entry_flow,node_interval_options,node_integration_lifecycle,node_diagnostics,node_user toneBlue
class node_coordinator,node_scrape_backend,node_html_parsing,node_api_backend toneAmber
class node_sensor,node_dashboard_card toneMint
class node_myhadith,node_home_assistant toneIndigo
```

## Components

### Setup and lifecycle

- [Setup and reconfigure](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/config_flow.py): `custom_components/mutiara_hadith/config_flow.py`
- [Refresh options](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/config_flow.py): `custom_components/mutiara_hadith/config_flow.py`
- [Integration lifecycle](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/__init__.py): `custom_components/mutiara_hadith/__init__.py`
- [Redacted diagnostics](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/diagnostics.py): `custom_components/mutiara_hadith/diagnostics.py`

### Hadith retrieval

- [Scheduled coordinator](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/coordinator.py): `custom_components/mutiara_hadith/coordinator.py`
- [Website scraper](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py): `custom_components/mutiara_hadith/client.py`
- [Hadith parsing](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py): `custom_components/mutiara_hadith/client.py`
- [Key-gated API backend](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/client.py): `custom_components/mutiara_hadith/client.py`

### Home Assistant presentation

- [Hadith sensor](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/sensor.py): `custom_components/mutiara_hadith/sensor.py`
- [Dashboard card](https://github.com/zubir2k/homeassistant-mutiarahadith/blob/main/custom_components/mutiara_hadith/frontend/mutiara-hadith-card.js): `custom_components/mutiara_hadith/frontend/mutiara-hadith-card.js`

### Other components

- **Home Assistant user**
- **MyHadith service**
- **Home Assistant**

## Connections

- Home Assistant user → Setup and reconfigure: configures (evidence: `README.md`)
- Setup and reconfigure → Website scraper: validates source (evidence: `custom_components/mutiara_hadith/config_flow.py`)
- Setup and reconfigure → Key-gated API backend: validates key (evidence: `custom_components/mutiara_hadith/config_flow.py`)
- Home Assistant user → Refresh options: sets interval (evidence: `README.md`)
- Integration lifecycle → Scheduled coordinator: creates (evidence: `custom_components/mutiara_hadith/__init__.py`)
- Integration lifecycle → Website scraper: selects backend (evidence: `custom_components/mutiara_hadith/__init__.py`)
- Integration lifecycle → Key-gated API backend: selects backend (evidence: `custom_components/mutiara_hadith/__init__.py`)
- Scheduled coordinator → Website scraper: fetches featured (evidence: `custom_components/mutiara_hadith/coordinator.py`)
- Scheduled coordinator → Key-gated API backend: fetches featured (evidence: `custom_components/mutiara_hadith/coordinator.py`)
- Website scraper → MyHadith service: requests pages (evidence: `custom_components/mutiara_hadith/client.py`)
- Website scraper → Hadith parsing: parses responses (evidence: `custom_components/mutiara_hadith/client.py`)
- Key-gated API backend → MyHadith service: requests JSON (evidence: `custom_components/mutiara_hadith/client.py`)
- Integration lifecycle → Hadith sensor: forwards platform (evidence: `custom_components/mutiara_hadith/__init__.py`)
- Hadith sensor → Scheduled coordinator: reads update data (evidence: `custom_components/mutiara_hadith/sensor.py`)
- Integration lifecycle → Dashboard card: registers frontend (evidence: `custom_components/mutiara_hadith/__init__.py`)
- Dashboard card → Hadith sensor: renders entity (evidence: `README.md`)
- Redacted diagnostics → Scheduled coordinator: reads status (evidence: `custom_components/mutiara_hadith/diagnostics.py`)
- Home Assistant → Integration lifecycle: loads integration (evidence: `custom_components/mutiara_hadith/__init__.py`)
