# kmfouda/energy_watch_nyc architecture

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

- Interactive diagram: https://gitdiagram.com/kmfouda/energy_watch_nyc
- Repository: https://github.com/kmfouda/energy_watch_nyc
- Video tour (about a minute): https://gitdiagram.com/kmfouda/energy_watch_nyc/video

## Overview

NYC Energy Watch is a static compliance dashboard and information site for NYC building energy laws. Its main user workflow resolves an address, BBL, or BIN into a building identity, combines CBL, violations, and benchmarking records, then renders a compliance report and runs a BIN-completeness audit. Other documented capabilities include a ZIP-level EUI map, compliance articles, and gated PDF downloads. The README provides the search flow, but the dashboard source was not sampled; links from it to Netlify endpoints are therefore shown as unverified. The backend endpoint behavior is supported by sampled source.

Main entry points: [`index.html`](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html) (Search and report UI), [`netlify/functions/get-resource.js`](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/get-resource.js) (Signed download link), [`insights.html`](https://github.com/kmfouda/energy_watch_nyc/blob/main/insights.html) (Insights index), [`netlify/functions/geocode-address.js`](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/geocode-address.js) (Address geocoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Building dashboard"]
  node_dashboard_ui["Search and report UI<br/>[index.html]"]
  node_address_resolution["Address resolution<br/>[index.html]"]
  node_identity_resolution["BBL and BIN resolution<br/>[index.html]"]
  node_finalize["Search finalization<br/>[index.html]"]
  node_compliance_report["Compliance report<br/>[index.html]"]
  node_bin_audit["BIN completeness audit<br/>[index.html]"]
end

subgraph group_data["Compliance data"]
  node_cbl[("Covered Buildings List")]
  node_nyc_data[("NYC Open Data")]
  node_ll84_data[("LL84 benchmarking")]
  node_map["ZIP EUI map<br/>[nycenergymap.html]"]
  node_google_sheets[("Google Sheets")]
end

subgraph group_content["Insights and resources"]
  node_insights_index["Insights index<br/>[insights.html]"]
  node_articles["Insight articles"]
  node_download_form["Resource download request<br/>[insights.html]"]
  node_pdf_library[("PDF resources")]
end

subgraph group_services["Supporting services"]
  node_geocoder["Address geocoder<br/>[geocode-address.js]"]
  node_data_query["NYC data query<br/>[query-nyc-data.js]"]
  node_resource_token["Signed download link<br/>[get-resource.js]"]
  node_pdf_delivery["PDF link validation<br/>[serve-pdf.js]"]
  node_event_logger["Event logger<br/>[log-event.js]"]
  node_sheet_logger["Resource download logger<br/>[Code.gs]"]
end

node_visitor(("Building visitor"))

node_visitor -->|"searches"| node_dashboard_ui
node_dashboard_ui -->|"submits address"| node_address_resolution
node_dashboard_ui -->|"submits BBL or BIN"| node_identity_resolution
node_address_resolution -.->|"geocodes address"| node_geocoder
node_geocoder -->|"returns coordinates"| node_dashboard_ui
node_identity_resolution -->|"looks up BIN"| node_cbl
node_identity_resolution -->|"resolves identity"| node_nyc_data
node_identity_resolution -->|"fallback lookup"| node_ll84_data
node_address_resolution -->|"passes resolved identity"| node_finalize
node_identity_resolution -->|"passes resolved identity"| node_finalize
node_finalize -->|"fetches violations"| node_nyc_data
node_finalize -->|"fetches filings"| node_ll84_data
node_finalize -->|"renders report"| node_compliance_report
node_finalize -->|"starts audit"| node_bin_audit
node_bin_audit -->|"compares official BINs"| node_cbl
node_bin_audit -->|"checks filing BINs"| node_ll84_data
node_dashboard_ui -.->|"queries NYC data"| node_data_query
node_visitor -->|"views map"| node_map
node_visitor -->|"browses insights"| node_insights_index
node_insights_index -->|"links articles"| node_articles
node_visitor -.->|"requests resource"| node_download_form
node_download_form -.->|"requests download link"| node_resource_token
node_resource_token -->|"logs request"| node_google_sheets
node_resource_token -.->|"issues signed link"| node_pdf_delivery
node_pdf_delivery -->|"redirects to file"| node_pdf_library
node_dashboard_ui -.->|"logs events"| node_event_logger
node_event_logger -->|"forwards event"| node_google_sheets
node_sheet_logger -.->|"records download"| node_google_sheets

click node_dashboard_ui "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_address_resolution "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_identity_resolution "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_finalize "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_compliance_report "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_bin_audit "https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html"
click node_map "https://github.com/kmfouda/energy_watch_nyc/blob/main/nycenergymap.html"
click node_geocoder "https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/geocode-address.js"
click node_data_query "https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/query-nyc-data.js"
click node_insights_index "https://github.com/kmfouda/energy_watch_nyc/blob/main/insights.html"
click node_articles "https://github.com/kmfouda/energy_watch_nyc/tree/main/insights"
click node_download_form "https://github.com/kmfouda/energy_watch_nyc/blob/main/insights.html"
click node_resource_token "https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/get-resource.js"
click node_pdf_delivery "https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/serve-pdf.js"
click node_pdf_library "https://github.com/kmfouda/energy_watch_nyc/tree/main/pdfs"
click node_event_logger "https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/log-event.js"
click node_sheet_logger "https://github.com/kmfouda/energy_watch_nyc/blob/main/google-apps-script/Code.gs"

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_dashboard_ui,node_address_resolution,node_identity_resolution,node_finalize,node_compliance_report,node_bin_audit toneBlue
class node_cbl,node_nyc_data,node_ll84_data,node_map,node_google_sheets toneAmber
class node_insights_index,node_articles,node_download_form,node_pdf_library toneMint
class node_geocoder,node_data_query,node_resource_token,node_pdf_delivery,node_event_logger,node_sheet_logger toneRose
class node_visitor toneIndigo
```

## Components

### Building dashboard

- [Search and report UI](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`
- [Address resolution](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`
- [BBL and BIN resolution](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`
- [Search finalization](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`
- [Compliance report](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`
- [BIN completeness audit](https://github.com/kmfouda/energy_watch_nyc/blob/main/index.html): `index.html`

### Compliance data

- **Covered Buildings List**
- **NYC Open Data**
- **LL84 benchmarking**
- [ZIP EUI map](https://github.com/kmfouda/energy_watch_nyc/blob/main/nycenergymap.html): `nycenergymap.html`
- **Google Sheets**

### Insights and resources

- [Insights index](https://github.com/kmfouda/energy_watch_nyc/blob/main/insights.html): `insights.html`
- [Insight articles](https://github.com/kmfouda/energy_watch_nyc/tree/main/insights): `insights`
- [Resource download request](https://github.com/kmfouda/energy_watch_nyc/blob/main/insights.html): `insights.html`
- [PDF resources](https://github.com/kmfouda/energy_watch_nyc/tree/main/pdfs): `pdfs`

### Supporting services

- [Address geocoder](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/geocode-address.js): `netlify/functions/geocode-address.js`
- [NYC data query](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/query-nyc-data.js): `netlify/functions/query-nyc-data.js`
- [Signed download link](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/get-resource.js): `netlify/functions/get-resource.js`
- [PDF link validation](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/serve-pdf.js): `netlify/functions/serve-pdf.js`
- [Event logger](https://github.com/kmfouda/energy_watch_nyc/blob/main/netlify/functions/log-event.js): `netlify/functions/log-event.js`
- [Resource download logger](https://github.com/kmfouda/energy_watch_nyc/blob/main/google-apps-script/Code.gs): `google-apps-script/Code.gs`

### Other components

- **Building visitor**

## Connections

- Building visitor → Search and report UI: searches (evidence: `README.md`)
- Search and report UI → Address resolution: submits address (evidence: `README.md`)
- Search and report UI → BBL and BIN resolution: submits BBL or BIN (evidence: `README.md`)
- Address resolution → Address geocoder: geocodes address
- Address geocoder → Search and report UI: returns coordinates (evidence: `netlify/functions/geocode-address.js`)
- BBL and BIN resolution → Covered Buildings List: looks up BIN (evidence: `README.md`)
- BBL and BIN resolution → NYC Open Data: resolves identity (evidence: `README.md`)
- BBL and BIN resolution → LL84 benchmarking: fallback lookup (evidence: `README.md`)
- Address resolution → Search finalization: passes resolved identity (evidence: `README.md`)
- BBL and BIN resolution → Search finalization: passes resolved identity (evidence: `README.md`)
- Search finalization → NYC Open Data: fetches violations (evidence: `README.md`)
- Search finalization → LL84 benchmarking: fetches filings (evidence: `README.md`)
- Search finalization → Compliance report: renders report (evidence: `README.md`)
- Search finalization → BIN completeness audit: starts audit (evidence: `README.md`)
- BIN completeness audit → Covered Buildings List: compares official BINs (evidence: `README.md`)
- BIN completeness audit → LL84 benchmarking: checks filing BINs (evidence: `README.md`)
- Search and report UI → NYC data query: queries NYC data
- Building visitor → ZIP EUI map: views map (evidence: `README.md`)
- Building visitor → Insights index: browses insights (evidence: `README.md`)
- Insights index → Insight articles: links articles (evidence: `README.md`)
- Building visitor → Resource download request: requests resource
- Resource download request → Signed download link: requests download link
- Signed download link → Google Sheets: logs request (evidence: `netlify/functions/get-resource.js`)
- Signed download link → PDF link validation: issues signed link
- PDF link validation → PDF resources: redirects to file (evidence: `netlify/functions/serve-pdf.js`)
- Search and report UI → Event logger: logs events
- Event logger → Google Sheets: forwards event (evidence: `netlify/functions/log-event.js`)
- Resource download logger → Google Sheets: records download
