# treybell/time-series-database architecture

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

- Interactive diagram: https://gitdiagram.com/treybell/time-series-database
- Repository: https://github.com/treybell/time-series-database

## Overview

This small Linux metrics agent repeatedly samples CPU and memory data, computes CPU usage, and prints timestamped metrics. The main loop owns the sampling cadence and calls the metric routines; the routines read Linux procfs. The graph reflects only the sampled source and explicit runtime behavior.

Main entry points: [`main.cpp`](https://github.com/treybell/time-series-database/blob/main/main.cpp) (Metrics loop), [`metrics.cpp`](https://github.com/treybell/time-series-database/blob/main/metrics.cpp) (CPU sampler)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_loop["Metrics loop<br/>[main.cpp]"]
node_api["Metrics API<br/>[metrics.hpp]"]
node_cpu_reader["CPU sampler<br/>[metrics.cpp]"]
node_cpu_calc["CPU calculator<br/>[metrics.cpp]"]
node_memory_reader["Memory sampler<br/>[metrics.cpp]"]
node_proc_stat["CPU proc data"]
node_proc_meminfo["Memory proc data"]
node_stdout["Standard output"]

node_loop -->|"samples CPU"| node_cpu_reader
node_loop -->|"computes usage"| node_cpu_calc
node_loop -->|"samples memory"| node_memory_reader
node_cpu_reader -->|"reads counters"| node_proc_stat
node_memory_reader -->|"reads memory"| node_proc_meminfo
node_loop -->|"prints metrics"| node_stdout

click node_loop "https://github.com/treybell/time-series-database/blob/main/main.cpp"
click node_api "https://github.com/treybell/time-series-database/blob/main/metrics.hpp"
click node_cpu_reader "https://github.com/treybell/time-series-database/blob/main/metrics.cpp"
click node_cpu_calc "https://github.com/treybell/time-series-database/blob/main/metrics.cpp"
click node_memory_reader "https://github.com/treybell/time-series-database/blob/main/metrics.cpp"

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_loop,node_cpu_reader,node_cpu_calc,node_memory_reader toneTeal
class node_api toneMint
class node_proc_stat,node_proc_meminfo,node_stdout toneIndigo
```

## Components

### Other components

- [Metrics loop](https://github.com/treybell/time-series-database/blob/main/main.cpp): `main.cpp`
- [Metrics API](https://github.com/treybell/time-series-database/blob/main/metrics.hpp): `metrics.hpp`
- [CPU sampler](https://github.com/treybell/time-series-database/blob/main/metrics.cpp): `metrics.cpp`
- [CPU calculator](https://github.com/treybell/time-series-database/blob/main/metrics.cpp): `metrics.cpp`
- [Memory sampler](https://github.com/treybell/time-series-database/blob/main/metrics.cpp): `metrics.cpp`
- **CPU proc data**
- **Memory proc data**
- **Standard output**

## Connections

- Metrics loop → CPU sampler: samples CPU (evidence: `main.cpp`)
- Metrics loop → CPU calculator: computes usage (evidence: `main.cpp`)
- Metrics loop → Memory sampler: samples memory (evidence: `main.cpp`)
- CPU sampler → CPU proc data: reads counters (evidence: `metrics.cpp`)
- Memory sampler → Memory proc data: reads memory (evidence: `metrics.cpp`)
- Metrics loop → Standard output: prints metrics (evidence: `main.cpp`)
