# blacksmoke16/gesi architecture

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

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

## Overview

GESI is a Google Sheets add-on and Apps Script library for authenticating EVE characters and querying EVE ESI from sheet formulas or scripts. A formula wrapper dispatches through GESI, which selects character credentials and configures an ESIClient; the client builds and fetches endpoint requests, then formats results for Sheets. The README also documents multi-character invocation, raw JSON, endpoint parsing, and reusable clients. Some runtime connections are documented but fall in unsampled source, so those links are marked unverified rather than inferred from imports alone.

Main entry points: [`src/script/src/gesi.ts`](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts) (GESI orchestration), [`src/script/src/esi_client.ts`](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/esi_client.ts) (ESI client), [`src/script/src/token_storage.ts`](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/token_storage.ts) (Token storage adapter), [`src/script/src/endpoints.ts`](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/endpoints.ts) (Endpoint catalog and scopes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Sheets entry points"]
  node_formula_wrappers["Custom functions<br/>[functions.ts]"]
  node_gesi["GESI orchestration<br/>[gesi.ts]"]
  node_advanced_script["Script library API<br/>[gesi.ts]"]
  node_multi_character["Multi-character invocation<br/>[gesi.ts]"]
end

subgraph group_identity["Character identity"]
  node_addon_ui["Add-on authorization UI<br/>[gesi.ts]"]
  node_oauth["OAuth service<br/>[gesi.ts]"]
  node_token_storage["Token storage adapter<br/>[token_storage.ts]"]
  node_character_data["Authenticated characters<br/>[gesi.ts]"]
  node_affiliation_lookup["Character affiliation lookup<br/>[gesi.ts]"]
end

subgraph group_esi["ESI request runtime"]
  node_esi_client["ESI client<br/>[esi_client.ts]"]
  node_endpoint_catalog["Endpoint catalog and scopes<br/>[endpoints.ts]"]
end

subgraph group_results["Results and storage"]
  node_document_properties[("Document properties")]
  node_document_cache[("Document cache")]
  node_array_parser["Nested array parser<br/>[gesi.ts]"]
  node_sheet_results["Sheet-formatted results"]
end

node_sheet_user(("Sheet user"))
node_eve_sso{{"EVE SSO"}}
node_esi_api{{"EVE ESI API"}}
node_url_fetch["Apps Script URL fetch"]

node_sheet_user -->|"calls formula"| node_formula_wrappers
node_formula_wrappers -->|"invokes endpoint"| node_gesi
node_advanced_script -.->|"invokes functions"| node_gesi
node_sheet_user -->|"authorizes character"| node_addon_ui
node_addon_ui -.->|"starts authorization"| node_oauth
node_oauth -.->|"authorizes with"| node_eve_sso
node_oauth -->|"uses token store"| node_token_storage
node_token_storage -->|"reads and writes"| node_document_properties
node_token_storage -->|"caches access token"| node_document_cache
node_gesi -->|"selects character"| node_character_data
node_gesi -->|"creates client"| node_esi_client
node_affiliation_lookup -->|"queries affiliation"| node_esi_client
node_esi_client -->|"looks up endpoints"| node_endpoint_catalog
node_gesi -->|"loads scopes"| node_endpoint_catalog
node_esi_client -->|"fetches requests"| node_url_fetch
node_url_fetch -.->|"sends HTTP requests"| node_esi_api
node_esi_client -->|"formats response"| node_sheet_results
node_gesi -.->|"dispatches per character"| node_multi_character
node_multi_character -.->|"invokes endpoint"| node_gesi
node_sheet_user -->|"parses endpoint data"| node_array_parser
node_array_parser -->|"reads headers"| node_endpoint_catalog
node_sheet_results -.->|"returns data"| node_sheet_user

click node_formula_wrappers "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/functions.ts"
click node_gesi "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_advanced_script "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_addon_ui "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_oauth "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_token_storage "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/token_storage.ts"
click node_character_data "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_affiliation_lookup "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_esi_client "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/esi_client.ts"
click node_endpoint_catalog "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/endpoints.ts"
click node_multi_character "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"
click node_array_parser "https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts"

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_formula_wrappers,node_gesi,node_advanced_script,node_multi_character,node_sheet_user toneBlue
class node_addon_ui,node_oauth,node_token_storage,node_character_data,node_affiliation_lookup toneAmber
class node_esi_client,node_endpoint_catalog,node_esi_api toneMint
class node_document_properties,node_document_cache,node_array_parser,node_sheet_results toneRose
class node_eve_sso,node_url_fetch toneIndigo
```

## Components

### Sheets entry points

- [Custom functions](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/functions.ts): `src/script/src/functions.ts`
- [GESI orchestration](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- [Script library API](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- [Multi-character invocation](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`

### Character identity

- [Add-on authorization UI](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- [OAuth service](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- [Token storage adapter](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/token_storage.ts): `src/script/src/token_storage.ts`
- [Authenticated characters](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- [Character affiliation lookup](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`

### ESI request runtime

- [ESI client](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/esi_client.ts): `src/script/src/esi_client.ts`
- [Endpoint catalog and scopes](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/endpoints.ts): `src/script/src/endpoints.ts`

### Results and storage

- **Document properties**
- **Document cache**
- [Nested array parser](https://github.com/blacksmoke16/gesi/blob/master/src/script/src/gesi.ts): `src/script/src/gesi.ts`
- **Sheet-formatted results**

### Other components

- **Sheet user**
- **EVE SSO**
- **EVE ESI API**
- **Apps Script URL fetch**

## Connections

- Sheet user → Custom functions: calls formula (evidence: `README.md`)
- Custom functions → GESI orchestration: invokes endpoint (evidence: `src/script/src/functions.ts`)
- Script library API → GESI orchestration: invokes functions (evidence: `README.md`)
- Sheet user → Add-on authorization UI: authorizes character (evidence: `README.md`)
- Add-on authorization UI → OAuth service: starts authorization (evidence: `src/script/src/gesi.ts`)
- OAuth service → EVE SSO: authorizes with
- OAuth service → Token storage adapter: uses token store (evidence: `src/script/src/gesi.ts`)
- Token storage adapter → Document properties: reads and writes (evidence: `src/script/src/token_storage.ts`)
- Token storage adapter → Document cache: caches access token (evidence: `src/script/src/token_storage.ts`)
- GESI orchestration → Authenticated characters: selects character (evidence: `src/script/src/gesi.ts`)
- GESI orchestration → ESI client: creates client (evidence: `src/script/src/gesi.ts`)
- Character affiliation lookup → ESI client: queries affiliation (evidence: `src/script/src/gesi.ts`)
- ESI client → Endpoint catalog and scopes: looks up endpoints (evidence: `src/script/src/esi_client.ts`)
- GESI orchestration → Endpoint catalog and scopes: loads scopes (evidence: `src/script/src/gesi.ts`)
- ESI client → Apps Script URL fetch: fetches requests (evidence: `src/script/src/esi_client.ts`)
- Apps Script URL fetch → EVE ESI API: sends HTTP requests
- ESI client → Sheet-formatted results: formats response (evidence: `src/script/src/esi_client.ts`)
- GESI orchestration → Multi-character invocation: dispatches per character (evidence: `README.md`)
- Multi-character invocation → GESI orchestration: invokes endpoint (evidence: `README.md`)
- Sheet user → Nested array parser: parses endpoint data (evidence: `src/script/src/gesi.ts`)
- Nested array parser → Endpoint catalog and scopes: reads headers (evidence: `src/script/src/gesi.ts`)
- Sheet-formatted results → Sheet user: returns data (evidence: `README.md`)
