# kedarnath21y/firmware_system architecture

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

- Interactive diagram: https://gitdiagram.com/kedarnath21y/firmware_system
- Repository: https://github.com/kedarnath21y/firmware_system

## Overview

This repository implements a small firmware-service runtime: it initializes logging and a configured UART driver, listens for delimited serial frames, and sends an ACK for each received frame. It also includes a standalone JSON configuration-loading subsystem. The graph preserves the distinct service, UART transport, logging, and configuration layers; edges reflect calls shown in the excerpts or module references in the source index.

Main entry points: [`service/service_layer.py`](https://github.com/kedarnath21y/firmware_system/blob/main/service/service_layer.py) (Firmware service), [`uart/serial_driver.py`](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_driver.py) (Serial driver), [`log/log_handler.py`](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_handler.py) (Log handler), [`uart/serial_handler.py`](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_handler.py) (Serial handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["Service orchestration"]
  node_firmware_service["Firmware service<br/>[service_layer.py]"]
end

subgraph group_uart["UART transport"]
  node_serial_driver["Serial driver<br/>[serial_driver.py]"]
  node_serial_handler["Serial handler<br/>[serial_handler.py]"]
  node_serial_config["Serial settings<br/>[serial_config.py]"]
  node_serial_errors["Serial errors"]
end

subgraph group_logging["Logging"]
  node_log_handler["Log handler<br/>[log_handler.py]"]
  node_custom_logger["Named logger<br/>[log_handler.py]"]
  node_log_config["Log settings<br/>[log_config.py]"]
  node_log_metrics["Log metrics<br/>[log_metrics.py]"]
  node_log_errors["Log errors<br/>[log_exceptions.py]"]
end

subgraph group_configuration["Configuration"]
  node_config_loader["Configuration loader<br/>[config_loader.py]"]
  node_config_loader_settings["Loader settings<br/>[config_models.py]"]
  node_configuration_model["Configuration model<br/>[config_models.py]"]
  node_config_errors["Configuration errors"]
end

node_serial_peer(("Serial peer"))
node_log_files["Log files"]
node_json_source["JSON source file"]

node_firmware_service -->|"creates settings"| node_log_config
node_firmware_service -->|"starts logging"| node_log_handler
node_firmware_service -->|"gets loggers"| node_custom_logger
node_firmware_service -->|"creates settings"| node_serial_config
node_firmware_service -->|"opens and listens"| node_serial_driver
node_firmware_service -->|"sends ACK"| node_serial_driver
node_serial_peer -.->|"sends bytes"| node_serial_handler
node_serial_handler -.->|"receives bytes"| node_serial_peer
node_serial_driver -->|"delegates I/O"| node_serial_handler
node_serial_driver -->|"reads settings"| node_serial_config
node_serial_handler -->|"reads settings"| node_serial_config
node_serial_driver -->|"raises and handles"| node_serial_errors
node_serial_handler -->|"raises"| node_serial_errors
node_serial_driver -->|"calls frame callback"| node_firmware_service
node_serial_driver -->|"calls error callback"| node_firmware_service
node_custom_logger -->|"enqueues records"| node_log_handler
node_log_handler -->|"reads settings"| node_log_config
node_log_handler -->|"updates counters"| node_log_metrics
node_log_handler -->|"raises sink error"| node_log_errors
node_log_handler -->|"writes and rotates"| node_log_files
node_config_loader -->|"reads JSON"| node_json_source
node_config_loader -->|"reads loader settings"| node_config_loader_settings
node_config_loader -->|"constructs and validates"| node_configuration_model
node_config_loader -->|"raises validation errors"| node_config_errors

click node_firmware_service "https://github.com/kedarnath21y/firmware_system/blob/main/service/service_layer.py"
click node_serial_driver "https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_driver.py"
click node_serial_handler "https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_handler.py"
click node_serial_config "https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_config.py"
click node_serial_errors "https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_exceptions.py"
click node_log_handler "https://github.com/kedarnath21y/firmware_system/blob/main/log/log_handler.py"
click node_custom_logger "https://github.com/kedarnath21y/firmware_system/blob/main/log/log_handler.py"
click node_log_config "https://github.com/kedarnath21y/firmware_system/blob/main/log/log_config.py"
click node_log_metrics "https://github.com/kedarnath21y/firmware_system/blob/main/log/log_metrics.py"
click node_log_errors "https://github.com/kedarnath21y/firmware_system/blob/main/log/log_exceptions.py"
click node_config_loader "https://github.com/kedarnath21y/firmware_system/blob/main/config/config_loader.py"
click node_config_loader_settings "https://github.com/kedarnath21y/firmware_system/blob/main/config/config_models.py"
click node_configuration_model "https://github.com/kedarnath21y/firmware_system/blob/main/config/config_models.py"
click node_config_errors "https://github.com/kedarnath21y/firmware_system/blob/main/config/config_exceptions.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_firmware_service toneBlue
class node_serial_driver,node_serial_handler,node_serial_config,node_serial_errors toneAmber
class node_log_handler,node_custom_logger,node_log_config,node_log_metrics,node_log_errors toneMint
class node_config_loader,node_config_loader_settings,node_configuration_model,node_config_errors toneRose
class node_serial_peer,node_log_files,node_json_source toneIndigo
```

## Components

### Service orchestration

- [Firmware service](https://github.com/kedarnath21y/firmware_system/blob/main/service/service_layer.py): `service/service_layer.py`

### UART transport

- [Serial driver](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_driver.py): `uart/serial_driver.py`
- [Serial handler](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_handler.py): `uart/serial_handler.py`
- [Serial settings](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_config.py): `uart/serial_config.py`
- [Serial errors](https://github.com/kedarnath21y/firmware_system/blob/main/uart/serial_exceptions.py): `uart/serial_exceptions.py`

### Logging

- [Log handler](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_handler.py): `log/log_handler.py`
- [Named logger](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_handler.py): `log/log_handler.py`
- [Log settings](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_config.py): `log/log_config.py`
- [Log metrics](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_metrics.py): `log/log_metrics.py`
- [Log errors](https://github.com/kedarnath21y/firmware_system/blob/main/log/log_exceptions.py): `log/log_exceptions.py`

### Configuration

- [Configuration loader](https://github.com/kedarnath21y/firmware_system/blob/main/config/config_loader.py): `config/config_loader.py`
- [Loader settings](https://github.com/kedarnath21y/firmware_system/blob/main/config/config_models.py): `config/config_models.py`
- [Configuration model](https://github.com/kedarnath21y/firmware_system/blob/main/config/config_models.py): `config/config_models.py`
- [Configuration errors](https://github.com/kedarnath21y/firmware_system/blob/main/config/config_exceptions.py): `config/config_exceptions.py`

### Other components

- **Serial peer**
- **Log files**
- **JSON source file**

## Connections

- Firmware service → Log settings: creates settings (evidence: `service/service_layer.py`)
- Firmware service → Log handler: starts logging (evidence: `service/service_layer.py`)
- Firmware service → Named logger: gets loggers (evidence: `service/service_layer.py`)
- Firmware service → Serial settings: creates settings (evidence: `service/service_layer.py`)
- Firmware service → Serial driver: opens and listens (evidence: `service/service_layer.py`)
- Firmware service → Serial driver: sends ACK (evidence: `service/service_layer.py`)
- Serial peer → Serial handler: sends bytes
- Serial handler → Serial peer: receives bytes
- Serial driver → Serial handler: delegates I/O (evidence: `uart/serial_driver.py`)
- Serial driver → Serial settings: reads settings (evidence: `uart/serial_driver.py`)
- Serial handler → Serial settings: reads settings (evidence: `uart/serial_handler.py`)
- Serial driver → Serial errors: raises and handles (evidence: `uart/serial_driver.py`)
- Serial handler → Serial errors: raises (evidence: `uart/serial_handler.py`)
- Serial driver → Firmware service: calls frame callback (evidence: `service/service_layer.py`)
- Serial driver → Firmware service: calls error callback (evidence: `service/service_layer.py`)
- Named logger → Log handler: enqueues records (evidence: `log/log_handler.py`)
- Log handler → Log settings: reads settings (evidence: `log/log_handler.py`)
- Log handler → Log metrics: updates counters (evidence: `log/log_handler.py`)
- Log handler → Log errors: raises sink error (evidence: `log/log_handler.py`)
- Log handler → Log files: writes and rotates (evidence: `log/log_handler.py`)
- Configuration loader → JSON source file: reads JSON (evidence: `config/config_loader.py`)
- Configuration loader → Loader settings: reads loader settings (evidence: `config/config_loader.py`)
- Configuration loader → Configuration model: constructs and validates (evidence: `config/config_loader.py`)
- Configuration loader → Configuration errors: raises validation errors (evidence: `config/config_loader.py`)
