# dev-festival/insy7970-sensor-data architecture

> Architecture diagram of the GitHub repository dev-festival/insy7970-sensor-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dev-festival/insy7970-sensor-data
- Repository: https://github.com/dev-festival/insy7970-sensor-data

## Overview

#### Purpose and Runtime

INSY Sensor Data is a Python 3.13 service for collecting Waites vibration/temperature data, preserving raw evidence, producing daily sensor snapshots and trends, and exposing those artifacts through a CLI and FastAPI. The package is managed with `uv`; local filesystem storage is the active persistence boundary. Maximo maintenance integration and clustering are scaffolded but not yet active capabilities.

Primary entry points: `main.py`, `src/insy_sensor_data/cli.py`, and `src/insy_sensor_data/api/main.py`.

#### Dual Application Surfaces

The Typer CLI is the canonical automation interface for fetch, validation, raw lifecycle, snapshot/trend builds, health, and serving the API. FastAPI is the canonical service interface, intended to reuse the same core modules rather than duplicate pipeline logic.

- CLI orchestration: `src/insy_sensor_data/cli.py`
- API app factory: `src/insy_sensor_data/api/main.py`
- Runtime configuration: `src/insy_sensor_data/config.py`

#### Waites Ingestion Boundary

Waites is the first external integration. Fetching supports deterministic fixture-backed mock data and opt-in live API requests authenticated from environment configuration. The client/fetch layer writes endpoint responses as raw evidence rather than treating remote payloads as directly processed data.

- HTTP/source client: `src/insy_sensor_data/waites/client.py`
- Fetch orchestration: `src/insy_sensor_data/waites/fetch.py`
- Mock source fixtures: `src/insy_sensor_data/waites/fixtures.py`

Live access depends on `WAITES_BASE_URL` and `WAITES_ACCESS_TOKEN`; tests remain mock-first and do not require plant-network, DB2, or ODBC access.

#### Raw Evidence and Validation Gate

Raw Waites runs are organized by date under `data/raw/waites/date=YYYY-MM-DD/`. Each run includes endpoint artifacts and manifests with byte counts and SHA-256 checksums; secrets are excluded. The lifecycle supports verification, gzip compression, and dry-run-first pruning. Shape validation writes `validation.json` beside raw data and forms a hard gate for API-source snapshot processing.

- Raw lifecycle operations: `src/insy_sensor_data/raw_lifecycle.py`
- Payload validation: `src/insy_sensor_data/waites/validate.py`
- Artifact/manifest handling: `src/insy_sensor_data/artifacts.py`

#### Processing: References, Snapshots, and Trends

Processed Waites reference data is stored separately from raw evidence. Snapshot construction converts a validated daily source run into daily, sensor-oriented outputs under `data/processed/snapshots/`. Trend construction reads a date range of snapshots and emits trend-ready results under `data/processed/trends/`; API trends only consume snapshots explicitly marked with API source metadata.

- Snapshot build stage: `src/insy_sensor_data/snapshots/build.py`
- Trend build stage: `src/insy_sensor_data/snapshots/trends.py`
- Storage abstraction and paths: `src/insy_sensor_data/storage.py`

#### Read-Service and Static UI

The API is a read/visibility boundary over generated artifacts: health, available dates, raw Waites runs, individual snapshots, and date-ranged trends. It also serves a small static browser shell; it is not the ingestion control plane.

- API routes: `src/insy_sensor_data/api/routes/waites.py`, `src/insy_sensor_data/api/routes/snapshots.py`, `src/insy_sensor_data/api/routes/trends.py`
- Date discovery and health: `src/insy_sensor_data/api/routes/dates.py`, `src/insy_sensor_data/api/routes/health.py`
- Static client: `src/insy_sensor_data/api/static/index.html`

#### Future Integration Boundaries

The repository reserves modules for correlating sensor outputs with maintenance history and for clustering/analysis, likely downstream of normalized snapshots and joins. Their presence defines intended extension points, not current runtime workflows.

- Sensor/maintenance joins: `src/insy_sensor_data/joins.py`
- Maximo boundary: `src/insy_sensor_data/maximo/__init__.py`
- Clustering boundary: `src/insy_sensor_data/clustering/__init__.py`

Main entry points: [`src/insy_sensor_data/cli.py`](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/cli.py) (Typer CLI), [`src/insy_sensor_data/api/routes/snapshots.py`](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/routes/snapshots.py) (API routes), [`src/insy_sensor_data/waites/fetch.py`](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/fetch.py) (Fetch orchestration), [`src/insy_sensor_data/api/main.py`](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/main.py) (FastAPI app factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["Application Surfaces"]
  node_cli["Typer CLI<br/>automation interface<br/>[cli.py]"]
  node_config["Runtime configuration<br/>configuration module<br/>[config.py]"]
end

subgraph group_ingestion["Waites Ingestion"]
  node_waites_client["Waites client<br/>HTTP source client<br/>[client.py]"]
  node_fixtures["Mock fixtures<br/>deterministic source<br/>[fixtures.py]"]
  node_fetch["Fetch orchestration<br/>ingestion stage<br/>[fetch.py]"]
end

subgraph group_pipeline["Evidence &amp; Processing"]
  node_artifacts["Artifacts &amp; manifests<br/>evidence metadata<br/>[artifacts.py]"]
  node_raw_evidence[("Raw Waites evidence<br/>filesystem dataset")]
  node_raw_lifecycle["Raw lifecycle<br/>evidence operations<br/>[raw_lifecycle.py]"]
  node_validation["Payload validation<br/>validation gate<br/>[validate.py]"]
  node_storage["Storage abstraction<br/>filesystem access<br/>[storage.py]"]
  node_snapshots["Daily snapshots<br/>processing stage<br/>[build.py]"]
  node_snapshot_data[("Snapshot artifacts<br/>filesystem dataset")]
  node_trends["Trend builder<br/>processing stage<br/>[trends.py]"]
  node_trend_data[("Trend artifacts<br/>filesystem dataset")]
end

subgraph group_read["Read Service"]
  node_api_app["FastAPI app factory<br/>read-service interface<br/>[main.py]"]
  node_api_routes["API routes<br/>read endpoints<br/>[snapshots.py]"]
  node_static_ui["Static browser shell<br/>static client<br/>[index.html]"]
end

subgraph group_future["Future Boundaries"]
  node_joins["Sensor-maintenance joins<br/>future correlation<br/>[joins.py]"]
  node_maximo["Maximo boundary<br/>future integration<br/>[__init__.py]"]
  node_clustering["Clustering boundary<br/>future analysis<br/>[__init__.py]"]
end

node_cli -->|"runs"| node_fetch
node_cli -->|"operates"| node_raw_lifecycle
node_cli -->|"runs"| node_validation
node_cli -->|"builds"| node_snapshots
node_cli -->|"builds"| node_trends
node_cli -->|"serves"| node_api_app
node_config -.->|"live credentials"| node_waites_client
node_fixtures -->|"mock source"| node_waites_client
node_waites_client -->|"retrieves payloads"| node_fetch
node_fetch -->|"creates manifests"| node_artifacts
node_fetch -->|"writes responses"| node_raw_evidence
node_artifacts -->|"records alongside"| node_raw_evidence
node_raw_lifecycle -->|"verifies and manages"| node_raw_evidence
node_raw_evidence -->|"validates shapes"| node_validation
node_validation -->|"validated API runs"| node_snapshots
node_storage -->|"accesses"| node_snapshot_data
node_storage -->|"accesses"| node_trend_data
node_snapshots -->|"writes daily outputs"| node_snapshot_data
node_snapshot_data -->|"reads date range"| node_trends
node_trends -->|"writes results"| node_trend_data
node_api_app -->|"mounts"| node_api_routes
node_api_app -->|"serves"| node_static_ui
node_api_routes -->|"lists runs"| node_raw_evidence
node_api_routes -->|"reads snapshots and dates"| node_snapshot_data
node_api_routes -->|"reads trends"| node_trend_data
node_snapshot_data -.->|"future input"| node_joins
node_maximo -.->|"future maintenance history"| node_joins
node_snapshot_data -.->|"future input"| node_clustering

click node_cli "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/cli.py"
click node_config "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/config.py"
click node_waites_client "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/client.py"
click node_fixtures "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/fixtures.py"
click node_fetch "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/fetch.py"
click node_artifacts "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/artifacts.py"
click node_raw_lifecycle "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/raw_lifecycle.py"
click node_validation "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/validate.py"
click node_storage "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/storage.py"
click node_snapshots "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/snapshots/build.py"
click node_trends "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/snapshots/trends.py"
click node_api_app "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/main.py"
click node_api_routes "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/routes/snapshots.py"
click node_static_ui "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/static/index.html"
click node_joins "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/joins.py"
click node_maximo "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/maximo/__init__.py"
click node_clustering "https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/clustering/__init__.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_cli,node_config toneBlue
class node_waites_client,node_fixtures,node_fetch toneAmber
class node_artifacts,node_raw_evidence,node_raw_lifecycle,node_validation,node_storage,node_snapshots,node_snapshot_data,node_trends,node_trend_data toneMint
class node_api_app,node_api_routes,node_static_ui toneRose
class node_joins,node_maximo,node_clustering toneIndigo
```

## Components

### Application Surfaces

- [Typer CLI](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/cli.py): automation interface · Canonical control plane for pipeline operations and API serving. · `src/insy_sensor_data/cli.py`
- [Runtime configuration](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/config.py): configuration module · Supplies environment-backed live Waites settings. · `src/insy_sensor_data/config.py`

### Waites Ingestion

- [Waites client](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/client.py): HTTP source client · Uses fixtures by default or opt-in authenticated live requests. · `src/insy_sensor_data/waites/client.py`
- [Mock fixtures](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/fixtures.py): deterministic source · `src/insy_sensor_data/waites/fixtures.py`
- [Fetch orchestration](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/fetch.py): ingestion stage · Captures endpoint responses as evidence. · `src/insy_sensor_data/waites/fetch.py`

### Evidence & Processing

- [Artifacts & manifests](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/artifacts.py): evidence metadata · Records byte counts and SHA-256 checksums without secrets. · `src/insy_sensor_data/artifacts.py`
- **Raw Waites evidence**: filesystem dataset · Date-partitioned endpoint artifacts and manifests.
- [Raw lifecycle](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/raw_lifecycle.py): evidence operations · Verifies, compresses, and dry-run prunes raw runs. · `src/insy_sensor_data/raw_lifecycle.py`
- [Payload validation](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/waites/validate.py): validation gate · Writes validation.json and gates API-source snapshot processing. · `src/insy_sensor_data/waites/validate.py`
- [Storage abstraction](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/storage.py): filesystem access · Owns processed-data paths and artifact access. · `src/insy_sensor_data/storage.py`
- [Daily snapshots](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/snapshots/build.py): processing stage · Builds sensor-oriented daily outputs from validated runs. · `src/insy_sensor_data/snapshots/build.py`
- **Snapshot artifacts**: filesystem dataset · Daily sensor outputs.
- [Trend builder](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/snapshots/trends.py): processing stage · Reads date-ranged snapshots, restricted to API-marked sources. · `src/insy_sensor_data/snapshots/trends.py`
- **Trend artifacts**: filesystem dataset · Trend-ready date-range results.

### Read Service

- [FastAPI app factory](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/main.py): read-service interface · Read-only visibility boundary over generated artifacts. · `src/insy_sensor_data/api/main.py`
- [API routes](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/routes/snapshots.py): read endpoints · Exposes health, dates, raw runs, snapshots, and trends. · `src/insy_sensor_data/api/routes/snapshots.py`
- [Static browser shell](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/api/static/index.html): static client · `src/insy_sensor_data/api/static/index.html`

### Future Boundaries

Reserved extension points, not active workflows.

- [Sensor-maintenance joins](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/joins.py): future correlation · Planned downstream join over normalized snapshots. · `src/insy_sensor_data/joins.py`
- [Maximo boundary](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/maximo/__init__.py): future integration · `src/insy_sensor_data/maximo/__init__.py`
- [Clustering boundary](https://github.com/dev-festival/insy7970-sensor-data/blob/master/src/insy_sensor_data/clustering/__init__.py): future analysis · `src/insy_sensor_data/clustering/__init__.py`

## Connections

- Typer CLI → Fetch orchestration: runs
- Typer CLI → Raw lifecycle: operates
- Typer CLI → Payload validation: runs
- Typer CLI → Daily snapshots: builds
- Typer CLI → Trend builder: builds
- Typer CLI → FastAPI app factory: serves
- Runtime configuration → Waites client: live credentials
- Mock fixtures → Waites client: mock source
- Waites client → Fetch orchestration: retrieves payloads
- Fetch orchestration → Artifacts & manifests: creates manifests
- Fetch orchestration → Raw Waites evidence: writes responses
- Artifacts & manifests → Raw Waites evidence: records alongside
- Raw lifecycle → Raw Waites evidence: verifies and manages
- Raw Waites evidence → Payload validation: validates shapes
- Payload validation → Daily snapshots: validated API runs
- Storage abstraction → Snapshot artifacts: accesses
- Storage abstraction → Trend artifacts: accesses
- Daily snapshots → Snapshot artifacts: writes daily outputs
- Snapshot artifacts → Trend builder: reads date range
- Trend builder → Trend artifacts: writes results
- FastAPI app factory → API routes: mounts
- FastAPI app factory → Static browser shell: serves
- API routes → Raw Waites evidence: lists runs
- API routes → Snapshot artifacts: reads snapshots and dates
- API routes → Trend artifacts: reads trends
- Snapshot artifacts → Sensor-maintenance joins: future input
- Maximo boundary → Sensor-maintenance joins: future maintenance history
- Snapshot artifacts → Clustering boundary: future input
