# markizano/smartmetertx architecture

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

- Interactive diagram: https://gitdiagram.com/markizano/smartmetertx
- Repository: https://github.com/markizano/smartmetertx

## Overview

SmartMeterTX preserves electricity-usage history and provides tools to collect meter data, compare provider plans, report usage, and visualize reads. The main workflow fetches SmartMeter Texas reads, converts and stores them in MongoDB, then exposes them through a local server and supports reports. A separate plan workflow stores Power to Choose listings for reconciliation against usage history. Edges reflect excerpted calls or README-described capabilities; some command internals and server routes were not sampled, so undocumented links are omitted.

Main entry points: [`lib/smartmetertx/smtx2mongo.py`](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/smtx2mongo.py) (Meter Fetch), [`lib/smartmetertx/power2choose.py`](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/power2choose.py) (Plan Fetch), [`lib/smartmetertx/reconcile.py`](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/reconcile.py) (Plan Reconciliation), [`lib/smartmetertx/server.py`](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/server.py) (Local Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Data Collection"]
  node_smtx_fetch["Meter Fetch<br/>[smtx2mongo.py]"]
  node_meter_api["SMTX API Client<br/>[api.py]"]
  node_schema["Document Schema<br/>[schema.py]"]
  node_mongo_utils["Mongo Connection<br/>[utils.py]"]
end

subgraph group_plans["Plan Comparison"]
  node_power_fetch["Plan Fetch<br/>[power2choose.py]"]
  node_reconcile["Plan Reconciliation<br/>[reconcile.py]"]
  node_markdown["Ranked Markdown Report"]
end

subgraph group_reporting["Reports and Alerts"]
  node_meter_report["Usage Report<br/>[meterReport.py]"]
  node_notify["SNS Notifications<br/>[notify.py]"]
end

subgraph group_interface["Web Interface"]
  node_server["Local Server<br/>[server.py]"]
  node_controller["Request Validation<br/>[controller.py]"]
  node_ui["Browser UI<br/>[index.js]"]
end

node_user(("Operator"))
node_smtx_service{{"SmartMeter Texas"}}
node_mongo[("MongoDB")]
node_power_api{{"Power to Choose"}}
node_efl_source{{"Plan EFLs"}}
node_sns{{"AWS SNS"}}
node_browser_user(("Browser User"))

node_user -->|"runs fetch"| node_smtx_fetch
node_smtx_fetch -->|"requests reads"| node_meter_api
node_meter_api -->|"fetches reads"| node_smtx_service
node_smtx_fetch -->|"casts records"| node_schema
node_smtx_fetch -->|"opens connection"| node_mongo_utils
node_smtx_fetch -->|"writes reads"| node_mongo
node_user -->|"runs fetch"| node_power_fetch
node_power_fetch -->|"fetches plans"| node_power_api
node_power_fetch -->|"casts plans"| node_schema
node_power_fetch -->|"stores plans"| node_mongo
node_user -->|"runs comparison"| node_reconcile
node_reconcile -->|"reads usage and plans"| node_mongo
node_reconcile -->|"downloads EFLs"| node_efl_source
node_reconcile -->|"produces report"| node_markdown
node_user -->|"runs report"| node_meter_report
node_meter_report -->|"reads usage"| node_mongo
node_meter_report -->|"sends summary"| node_notify
node_notify -->|"publishes alert"| node_sns
node_browser_user -->|"requests interface"| node_server
node_server -->|"reads meter data"| node_mongo
node_server -->|"uses validation"| node_controller
node_server -->|"serves UI files"| node_ui

click node_smtx_fetch "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/smtx2mongo.py"
click node_meter_api "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/api.py"
click node_schema "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/schema.py"
click node_mongo_utils "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/utils.py"
click node_power_fetch "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/power2choose.py"
click node_reconcile "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/reconcile.py"
click node_meter_report "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/meterReport.py"
click node_notify "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/notify.py"
click node_server "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/server.py"
click node_controller "https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/controller.py"
click node_ui "https://github.com/markizano/smartmetertx/blob/master/lib/ui/index.js"

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_smtx_fetch,node_meter_api,node_schema,node_mongo_utils,node_browser_user toneBlue
class node_power_fetch,node_reconcile,node_markdown,node_mongo toneAmber
class node_meter_report,node_notify toneMint
class node_server,node_controller,node_ui toneRose
class node_user,node_smtx_service,node_power_api,node_efl_source,node_sns toneIndigo
```

## Components

### Data Collection

- [Meter Fetch](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/smtx2mongo.py): `lib/smartmetertx/smtx2mongo.py`
- [SMTX API Client](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/api.py): `lib/smartmetertx/api.py`
- [Document Schema](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/schema.py): `lib/smartmetertx/schema.py`
- [Mongo Connection](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/utils.py): `lib/smartmetertx/utils.py`

### Plan Comparison

- [Plan Fetch](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/power2choose.py): `lib/smartmetertx/power2choose.py`
- [Plan Reconciliation](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/reconcile.py): `lib/smartmetertx/reconcile.py`
- **Ranked Markdown Report**

### Reports and Alerts

- [Usage Report](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/meterReport.py): `lib/smartmetertx/meterReport.py`
- [SNS Notifications](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/notify.py): `lib/smartmetertx/notify.py`

### Web Interface

- [Local Server](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/server.py): `lib/smartmetertx/server.py`
- [Request Validation](https://github.com/markizano/smartmetertx/blob/master/lib/smartmetertx/controller.py): `lib/smartmetertx/controller.py`
- [Browser UI](https://github.com/markizano/smartmetertx/blob/master/lib/ui/index.js): `lib/ui/index.js`

### Other components

- **Operator**
- **SmartMeter Texas**
- **MongoDB**
- **Power to Choose**
- **Plan EFLs**
- **AWS SNS**
- **Browser User**

## Connections

- Operator → Meter Fetch: runs fetch (evidence: `README.md`)
- Meter Fetch → SMTX API Client: requests reads (evidence: `lib/smartmetertx/smtx2mongo.py`)
- SMTX API Client → SmartMeter Texas: fetches reads (evidence: `lib/smartmetertx/api.py`)
- Meter Fetch → Document Schema: casts records (evidence: `lib/smartmetertx/smtx2mongo.py`)
- Meter Fetch → Mongo Connection: opens connection (evidence: `lib/smartmetertx/smtx2mongo.py`)
- Meter Fetch → MongoDB: writes reads (evidence: `README.md`)
- Operator → Plan Fetch: runs fetch (evidence: `README.md`)
- Plan Fetch → Power to Choose: fetches plans (evidence: `lib/smartmetertx/power2choose.py`)
- Plan Fetch → Document Schema: casts plans (evidence: `lib/smartmetertx/power2choose.py`)
- Plan Fetch → MongoDB: stores plans (evidence: `lib/smartmetertx/power2choose.py`)
- Operator → Plan Reconciliation: runs comparison (evidence: `README.md`)
- Plan Reconciliation → MongoDB: reads usage and plans (evidence: `README.md`)
- Plan Reconciliation → Plan EFLs: downloads EFLs (evidence: `lib/smartmetertx/reconcile.py`)
- Plan Reconciliation → Ranked Markdown Report: produces report (evidence: `lib/smartmetertx/reconcile.py`)
- Operator → Usage Report: runs report (evidence: `README.md`)
- Usage Report → MongoDB: reads usage (evidence: `lib/smartmetertx/meterReport.py`)
- Usage Report → SNS Notifications: sends summary (evidence: `lib/smartmetertx/meterReport.py`)
- SNS Notifications → AWS SNS: publishes alert (evidence: `lib/smartmetertx/notify.py`)
- Browser User → Local Server: requests interface (evidence: `README.md`)
- Local Server → MongoDB: reads meter data (evidence: `lib/smartmetertx/server.py`)
- Local Server → Request Validation: uses validation (evidence: `lib/smartmetertx/server.py`)
- Local Server → Browser UI: serves UI files (evidence: `lib/smartmetertx/server.py`)
