# hanruiz07/microelectr-nicos architecture

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

- Interactive diagram: https://gitdiagram.com/hanruiz07/microelectr-nicos
- Repository: https://github.com/hanruiz07/microelectr-nicos

## Overview

This is a sensor-monitoring application: an MQTT subscriber receives accelerometer samples, logs raw readings, detects kick events and records their estimates; a separate Streamlit dashboard reads the CSV logs to show trends, metrics and recent records. Configuration supplies broker, topic and detector/logger settings. The source shows the main runtime calls and CSV reads/writes; the dashboard’s human user and some operational startup details are not documented, so those links are omitted.

Main entry points: [`mqtt_handler.py`](https://github.com/hanruiz07/microelectr-nicos/blob/main/mqtt_handler.py) (MQTT handler), [`data_logger.py`](https://github.com/hanruiz07/microelectr-nicos/blob/main/data_logger.py) (CSV logger), [`config.py`](https://github.com/hanruiz07/microelectr-nicos/blob/main/config.py) (Configuration), [`dashboard.py`](https://github.com/hanruiz07/microelectr-nicos/blob/main/dashboard.py) (Monitoring dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["MQTT ingestion"]
  node_main["Runtime entry<br/>[main.py]"]
  node_mqtt_handler["MQTT handler<br/>[mqtt_handler.py]"]
  node_broker["MQTT broker"]
end

subgraph group_processing["Detection and storage"]
  node_config["Configuration<br/>[config.py]"]
  node_detector["Kick detector<br/>[kick_detector.py]"]
  node_logger["CSV logger<br/>[data_logger.py]"]
  node_raw_csv[("Sensor log<br/>[datos_sensores.csv]")]
  node_kicks_csv[("Kick log<br/>[disparos.csv]")]
end

subgraph group_visualization["Dashboard"]
  node_dashboard["Monitoring dashboard<br/>[dashboard.py]"]
end

node_operator(("Operator"))

node_operator -.->|"starts"| node_main
node_main -->|"starts"| node_mqtt_handler
node_mqtt_handler -->|"connects and subscribes"| node_broker
node_broker -->|"delivers messages"| node_mqtt_handler
node_mqtt_handler -->|"reads settings"| node_config
node_mqtt_handler -->|"logs samples"| node_logger
node_mqtt_handler -->|"updates detector"| node_detector
node_mqtt_handler -->|"logs events"| node_logger
node_detector -->|"reads thresholds"| node_config
node_logger -->|"reads paths and limits"| node_config
node_logger -->|"writes samples"| node_raw_csv
node_logger -->|"writes events"| node_kicks_csv
node_dashboard -->|"reads samples"| node_raw_csv
node_dashboard -->|"reads events"| node_kicks_csv

click node_main "https://github.com/hanruiz07/microelectr-nicos/blob/main/main.py"
click node_mqtt_handler "https://github.com/hanruiz07/microelectr-nicos/blob/main/mqtt_handler.py"
click node_config "https://github.com/hanruiz07/microelectr-nicos/blob/main/config.py"
click node_detector "https://github.com/hanruiz07/microelectr-nicos/blob/main/kick_detector.py"
click node_logger "https://github.com/hanruiz07/microelectr-nicos/blob/main/data_logger.py"
click node_raw_csv "https://github.com/hanruiz07/microelectr-nicos/blob/main/datos_sensores.csv"
click node_kicks_csv "https://github.com/hanruiz07/microelectr-nicos/blob/main/disparos.csv"
click node_dashboard "https://github.com/hanruiz07/microelectr-nicos/blob/main/dashboard.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_main,node_mqtt_handler,node_broker toneBlue
class node_config,node_detector,node_logger,node_raw_csv,node_kicks_csv toneAmber
class node_dashboard toneMint
class node_operator toneIndigo
```

## Components

### MQTT ingestion

- [Runtime entry](https://github.com/hanruiz07/microelectr-nicos/blob/main/main.py): `main.py`
- [MQTT handler](https://github.com/hanruiz07/microelectr-nicos/blob/main/mqtt_handler.py): `mqtt_handler.py`
- **MQTT broker**

### Detection and storage

- [Configuration](https://github.com/hanruiz07/microelectr-nicos/blob/main/config.py): `config.py`
- [Kick detector](https://github.com/hanruiz07/microelectr-nicos/blob/main/kick_detector.py): `kick_detector.py`
- [CSV logger](https://github.com/hanruiz07/microelectr-nicos/blob/main/data_logger.py): `data_logger.py`
- [Sensor log](https://github.com/hanruiz07/microelectr-nicos/blob/main/datos_sensores.csv): `datos_sensores.csv`
- [Kick log](https://github.com/hanruiz07/microelectr-nicos/blob/main/disparos.csv): `disparos.csv`

### Dashboard

- [Monitoring dashboard](https://github.com/hanruiz07/microelectr-nicos/blob/main/dashboard.py): `dashboard.py`

### Other components

- **Operator**

## Connections

- Operator → Runtime entry: starts
- Runtime entry → MQTT handler: starts (evidence: `main.py`)
- MQTT handler → MQTT broker: connects and subscribes (evidence: `mqtt_handler.py`)
- MQTT broker → MQTT handler: delivers messages (evidence: `mqtt_handler.py`)
- MQTT handler → Configuration: reads settings (evidence: `mqtt_handler.py`)
- MQTT handler → CSV logger: logs samples (evidence: `mqtt_handler.py`)
- MQTT handler → Kick detector: updates detector (evidence: `mqtt_handler.py`)
- MQTT handler → CSV logger: logs events (evidence: `mqtt_handler.py`)
- Kick detector → Configuration: reads thresholds (evidence: `kick_detector.py`)
- CSV logger → Configuration: reads paths and limits (evidence: `data_logger.py`)
- CSV logger → Sensor log: writes samples (evidence: `data_logger.py`)
- CSV logger → Kick log: writes events (evidence: `data_logger.py`)
- Monitoring dashboard → Sensor log: reads samples (evidence: `dashboard.py`)
- Monitoring dashboard → Kick log: reads events (evidence: `dashboard.py`)
