# antoniocas997/entrevista_tecnica architecture

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

- Interactive diagram: https://gitdiagram.com/antoniocas997/entrevista_tecnica
- Repository: https://github.com/antoniocas997/entrevista_tecnica

## Overview

1. **Repo purpose**
   - This repository is an interview exercise for building an **offline data-processing pipeline** from two CSV inputs: energy measurements and alarm events.
   - The repo is currently very small: it contains the **README**, and the raw inputs in `/data`. No source code is present yet.

2. **Main inputs**
   - `/data/energia.csv` is the numerical time-series source for energy and power.
   - `/data/Alarmas.csv` is the event source for device alarms.
   - These files are the only upstream systems; there are no APIs, queues, or external services implied by the repo.

3. **Energy-processing subsystem**
   - The energy flow reads `energia.csv`, filters the target period around **2026-03-16 through before 2026-03-22/23** as specified, and produces a daily view.
   - The key business split is by asset category:
     - Total
     - Refrigeración
     - Aire acondicionado
     - Iluminación
     - Otros, computed as **Total - Refrigeración - Aire acondicionado - Iluminación**
   - This is the main transformation boundary: raw readings in, daily aggregated metrics out.

4. **Aggregation model**
   - The README asks for “consumo total diario por activo,” which means the pipeline must normalize timestamped measurements into **day-level aggregates**.
   - The architecture should treat “daily aggregation” as a distinct stage between ingestion and reporting.

5. **Visualization subsystem**
   - A chart is required for the same energy period, showing the **behavior of power over time per asset**.
   - This is a separate presentation layer from the table output: it consumes the processed energy dataset and renders a time-series plot, likely saved as an artifact rather than served interactively.

6. **SQLite persistence subsystem**
   - Processed data must be stored in **SQLite**, which makes the solution a local, file-backed analytics pipeline.
   - The database is not the source of truth; it is a persistence/reporting layer for the transformed data.
   - The required view combines:
     - the main period from **2026-03-16 inclusive to before 2026-03-23**
     - a **comparison window one week earlier**
   - That means the DB layer needs to support both the primary analysis window and a historical comparison slice.

7. **Alarm-processing subsystem**
   - `Alarmas.csv` is processed independently from energy data.
   - The first step is extracting the **unique values** of `Advisory Message`.
   - The second step is grouping by **controller/source (`Source`)** and counting alarm types based on those unique advisory messages.
   - This subsystem is event-oriented rather than numeric time-series processing.

8. **Functional boundaries**
   - The repository’s architecture naturally splits into three pipelines:
     - **Energy ingestion + aggregation + charting**
     - **Energy persistence + SQLite view creation**
     - **Alarm ingestion + uniqueness extraction + per-controller counts**
   - These should be separate functions/modules because they operate on different schemas and outputs.

9. **Cross-cutting concerns**
   - The README explicitly requires:
     - code structured in functions
     - error handling
     - documentation
   - So the solution should include input validation, date parsing robustness, and graceful handling of malformed CSVs or missing columns.

10. **Expected outputs / artifacts**
   - The deliverables implied by the repo are:
     - source code
     - auxiliary scripts
     - generated SQLite database
     - README with execution instructions
     - likely a tabular report and a saved chart artifact
   - There is no indication of deployment or runtime infrastructure beyond local execution.

11. **Suggested architectural diagram perspective**
   - For an accurate diagram, show a **single batch-processing entry point** reading from the two CSV files, branching into:
     - an energy analytics path
     - an alarms analytics path
   - Both paths are local and deterministic, with the energy path additionally writing to SQLite and producing a visualization.

12. **Current repo maturity**
   - At present, the repository is mostly a **specification plus data bundle** rather than a completed system.
   - The architecture is therefore defined by the README requirements more than by implemented code.

Main entry points: [`README.md`](https://github.com/antoniocas997/entrevista_tecnica/blob/main/README.md) (README), [`data/energia.csv`](https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/energia.csv) (Energy CSV), [`data/Alarmas.csv`](https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/Alarmas.csv) (Alarm CSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs"]
  node_readme["README<br/>spec<br/>[README.md]"]
  node_energia_csv["Energy CSV<br/>raw timeseries<br/>[energia.csv]"]
  node_alarmas_csv["Alarm CSV<br/>raw events<br/>[Alarmas.csv]"]
end

subgraph group_energy["Energy pipeline"]
  node_entrypoint(("Batch entry<br/>orchestration"))
  node_energy_ingest["Energy ingest<br/>csv ingest"]
  node_energy_filter["Period filter<br/>date window"]
  node_daily_agg["Daily aggregate<br/>aggregation"]
  node_asset_split["Asset split<br/>business calc"]
  node_sqlite_store[("SQLite store<br/>persistence")]
end

subgraph group_alarms["Alarm pipeline"]
  node_alarm_ingest["Alarm ingest<br/>csv ingest"]
  node_alarm_uniques["Unique messages<br/>deduplication"]
  node_alarm_counts["Source counts<br/>grouping"]
end

subgraph group_outputs["Outputs"]
  node_energy_chart["Power chart<br/>visualization"]
  node_energy_table["Daily report<br/>tabular report"]
  node_alarm_report["Alarm summary<br/>tabular report"]
  node_docs["Instructions<br/>documentation<br/>[README.md]"]
end

node_readme -->|"defines"| node_entrypoint
node_energia_csv -->|"input"| node_energy_ingest
node_alarmas_csv -->|"input"| node_alarm_ingest
node_entrypoint -->|"runs"| node_energy_ingest
node_entrypoint -->|"runs"| node_alarm_ingest
node_energy_ingest -->|"cleaned data"| node_energy_filter
node_energy_filter -->|"windowed data"| node_daily_agg
node_daily_agg -->|"metrics"| node_asset_split
node_asset_split -->|"persist"| node_sqlite_store
node_sqlite_store -->|"query"| node_energy_table
node_asset_split -->|"render"| node_energy_chart
node_alarm_ingest -->|"extract"| node_alarm_uniques
node_alarm_uniques -->|"group"| node_alarm_counts
node_alarm_counts -->|"publish"| node_alarm_report
node_entrypoint -.->|"supports"| node_docs

click node_readme "https://github.com/antoniocas997/entrevista_tecnica/blob/main/README.md"
click node_energia_csv "https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/energia.csv"
click node_alarmas_csv "https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/Alarmas.csv"
click node_docs "https://github.com/antoniocas997/entrevista_tecnica/blob/main/README.md"

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_readme,node_energia_csv,node_alarmas_csv toneBlue
class node_entrypoint,node_energy_ingest,node_energy_filter,node_daily_agg,node_asset_split,node_sqlite_store toneAmber
class node_alarm_ingest,node_alarm_uniques,node_alarm_counts toneMint
class node_energy_chart,node_energy_table,node_alarm_report,node_docs toneRose
```

## Components

### Inputs

Raw local CSV sources bundled with the repository.

- [README](https://github.com/antoniocas997/entrevista_tecnica/blob/main/README.md): spec · Repository requirements and execution guidance. · `README.md`
- [Energy CSV](https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/energia.csv): raw timeseries · Numerical energy and power measurements. · `data/energia.csv`
- [Alarm CSV](https://github.com/antoniocas997/entrevista_tecnica/blob/main/data/Alarmas.csv): raw events · Alarm events with advisory messages and source controllers. · `data/Alarmas.csv`

### Energy pipeline

Batch flow for time-series energy processing, aggregation, storage, and charting.

- **Batch entry**: orchestration · Single local execution entry point coordinating both pipelines.
- **Energy ingest**: csv ingest · Loads and validates energy records, including date parsing and schema checks.
- **Period filter**: date window · Selects the target analysis window around 2026-03-16 through before 2026-03-23.
- **Daily aggregate**: aggregation · Normalizes timestamped readings into day-level consumption and power summaries.
- **Asset split**: business calc · Computes Total, Refrigeración, Aire acondicionado, Iluminación, and Otros.
- **SQLite store**: persistence · Writes processed energy data to local SQLite for reporting and comparison windows.

### Alarm pipeline

Batch flow for alarm event extraction and grouping.

- **Alarm ingest**: csv ingest · Loads alarm rows and validates required columns.
- **Unique messages**: deduplication · Extracts distinct Advisory Message values.
- **Source counts**: grouping · Groups by Source and counts alarm types from unique advisory messages.

### Outputs

Local analytical artifacts produced by the pipeline.

- **Power chart**: visualization · Renders time-series behavior of power over time per asset.
- **Daily report**: tabular report · Produces the required daily consumption view for the main and comparison periods.
- **Alarm summary**: tabular report · Local summary of unique messages and per-controller alarm counts.
- [Instructions](https://github.com/antoniocas997/entrevista_tecnica/blob/main/README.md): documentation · Execution notes, error handling expectations, and usage guidance. · `README.md`

## Connections

- README → Batch entry: defines · The README specifies the batch workflow.
- Energy CSV → Energy ingest: input · Raw energy measurements feed ingestion.
- Alarm CSV → Alarm ingest: input · Raw alarm events feed ingestion.
- Batch entry → Energy ingest: runs · The batch entry point starts the energy pipeline.
- Batch entry → Alarm ingest: runs · The batch entry point starts the alarm pipeline.
- Energy ingest → Period filter: cleaned data · Validated energy rows are filtered to the target window.
- Period filter → Daily aggregate: windowed data · Filtered readings are aggregated by day.
- Daily aggregate → Asset split: metrics · Daily metrics are split into business asset categories.
- Asset split → SQLite store: persist · Processed energy results are stored in SQLite.
- SQLite store → Daily report: query · The database supports the main and comparison reporting slices.
- Asset split → Power chart: render · Processed energy series are visualized as a chart.
- Alarm ingest → Unique messages: extract · Alarm rows are reduced to distinct advisory messages.
- Unique messages → Source counts: group · Unique messages are counted by source/controller.
- Source counts → Alarm summary: publish · Alarm analytics are emitted as a summary report.
- Batch entry → Instructions: supports · Documentation and error handling expectations wrap the batch flow.
