# zainaali/solar-api architecture

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

- Interactive diagram: https://gitdiagram.com/zainaali/solar-api
- Repository: https://github.com/zainaali/solar-api

## Overview

This is a browser-based solar-potential viewer. A user searches for a location, the app resolves it and requests Google Solar data, then displays the location and roof information on a satellite map. Users can inspect roof segments and adjust a panel configuration to see panel counts and energy estimates. The main runtime logic is concentrated in script.js; the README documents the user-facing capabilities, while the excerpts show only parts of their implementation.

Main entry points: [`script.js`](https://github.com/zainaali/solar-api/blob/main/script.js) (Result processing), [`index.html`](https://github.com/zainaali/solar-api/blob/main/index.html) (Search input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_search["Location search"]
  node_search_ui["Search input<br/>[index.html]"]
  node_autocomplete["Place autocomplete<br/>[script.js]"]
  node_geocoding["Address geocoding<br/>[script.js]"]
end

subgraph group_solar["Solar data"]
  node_solar_request["Solar data request<br/>[script.js]"]
  node_results["Result processing<br/>[script.js]"]
end

subgraph group_view["Map and configuration"]
  node_map["Satellite map<br/>[script.js]"]
  node_roof_markers["Roof segments<br/>[script.js]"]
  node_location_marker["Location marker<br/>[script.js]"]
  node_solar_details["Solar details<br/>[script.js]"]
  node_panel_controls["Panel controls<br/>[script.js]"]
  node_panel_polygons["Panel polygons<br/>[script.js]"]
  node_energy_output["Energy estimate<br/>[script.js]"]
end

node_user(("User"))
node_places["Google Places"]
node_geocoder["Google Geocoder"]
node_solar_api["Google Solar API"]

node_user -->|"enters location"| node_search_ui
node_search_ui -->|"offers suggestions"| node_autocomplete
node_autocomplete -->|"uses Places API"| node_places
node_autocomplete -->|"resolves address"| node_geocoding
node_geocoding -->|"geocodes address"| node_geocoder
node_geocoding -->|"passes coordinates"| node_solar_request
node_solar_request -->|"requests insights"| node_solar_api
node_solar_request -->|"passes response"| node_results
node_results -->|"renders results"| node_map
node_results -->|"creates markers"| node_roof_markers
node_results -->|"creates marker"| node_location_marker
node_roof_markers -->|"shows segment data"| node_solar_details
node_location_marker -->|"shows location data"| node_solar_details
node_results -->|"creates slider"| node_panel_controls
node_panel_controls -.->|"adjusts layout"| node_panel_polygons
node_panel_controls -->|"updates estimate"| node_energy_output

click node_search_ui "https://github.com/zainaali/solar-api/blob/main/index.html"
click node_autocomplete "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_geocoding "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_solar_request "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_results "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_map "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_roof_markers "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_location_marker "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_solar_details "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_panel_controls "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_panel_polygons "https://github.com/zainaali/solar-api/blob/main/script.js"
click node_energy_output "https://github.com/zainaali/solar-api/blob/main/script.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_search_ui,node_autocomplete,node_geocoding,node_user toneBlue
class node_solar_request,node_results toneAmber
class node_map,node_roof_markers,node_location_marker,node_solar_details,node_panel_controls,node_panel_polygons,node_energy_output,node_solar_api toneMint
class node_places,node_geocoder toneIndigo
```

## Components

### Location search

- [Search input](https://github.com/zainaali/solar-api/blob/main/index.html): `index.html`
- [Place autocomplete](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Address geocoding](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`

### Solar data

- [Solar data request](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Result processing](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`

### Map and configuration

- [Satellite map](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Roof segments](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Location marker](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Solar details](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Panel controls](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Panel polygons](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`
- [Energy estimate](https://github.com/zainaali/solar-api/blob/main/script.js): `script.js`

### Other components

- **User**
- **Google Places**
- **Google Geocoder**
- **Google Solar API**

## Connections

- User → Search input: enters location (evidence: `README.md`)
- Search input → Place autocomplete: offers suggestions (evidence: `README.md`)
- Place autocomplete → Google Places: uses Places API (evidence: `script.js`)
- Place autocomplete → Address geocoding: resolves address (evidence: `script.js`)
- Address geocoding → Google Geocoder: geocodes address (evidence: `script.js`)
- Address geocoding → Solar data request: passes coordinates (evidence: `script.js`)
- Solar data request → Google Solar API: requests insights (evidence: `script.js`)
- Solar data request → Result processing: passes response (evidence: `script.js`)
- Result processing → Satellite map: renders results (evidence: `script.js`)
- Result processing → Roof segments: creates markers (evidence: `script.js`)
- Result processing → Location marker: creates marker (evidence: `script.js`)
- Roof segments → Solar details: shows segment data (evidence: `script.js`)
- Location marker → Solar details: shows location data (evidence: `script.js`)
- Result processing → Panel controls: creates slider (evidence: `script.js`)
- Panel controls → Panel polygons: adjusts layout (evidence: `README.md`)
- Panel controls → Energy estimate: updates estimate (evidence: `script.js`)
