# thisgmailisminelilfella-dev/aprture-mibole architecture

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

- Interactive diagram: https://gitdiagram.com/thisgmailisminelilfella-dev/aprture-mibole
- Repository: https://github.com/thisgmailisminelilfella-dev/aprture-mibole

## Overview

Aperture Phone is a local, phone-first market-analysis companion: a user unlocks the browser interface, chooses a market or symbol, and requests a paper-only scan. The server fetches daily prices, the quant module produces illustrative trend signals, and successful results are saved for later display; an optional OpenRouter summary can supplement them. PIN-based sessions, persistent pause state, encrypted key management, and the installable cached shell support the workflow. The graph follows the shown client calls and module references; scan details and several UI capabilities are documented in the README but not fully sampled.

Main entry points: [`server.js`](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/server.js) (HTTP server), [`public/index.html`](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/public/index.html) (Browser shell), [`src/app.ts`](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/src/app.ts) (Market interface), [`lib/key-pool.mjs`](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/key-pool.mjs) (Encrypted key pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Phone experience"]
  node_browser["Browser shell<br/>[index.html]"]
  node_ui["Market interface<br/>[app.ts]"]
  node_shellcache["Shell cache<br/>[sw.js]"]
end

subgraph group_service["Scan service"]
  node_server["HTTP server<br/>[server.js]"]
  node_quant["Trend analysis<br/>[quant.mjs]"]
end

subgraph group_security["Access and keys"]
  node_pin["PIN utilities<br/>[pin.mjs]"]
  node_keypool["Encrypted key pool<br/>[key-pool.mjs]"]
  node_pinchange["PIN change command<br/>[change-pin.mjs]"]
end

subgraph group_state["Local state"]
  node_sqlite[("Local SQLite<br/>[server.js]")]
end

subgraph group_integrations["External services"]
  node_yahoo["Yahoo Finance"]
  node_openrouter["OpenRouter"]
end

node_user(("Phone user"))

node_user -->|"opens"| node_browser
node_browser -->|"loads"| node_ui
node_ui -->|"requests state and scans"| node_server
node_server -->|"publishes updates"| node_ui
node_browser -.->|"registers shell cache"| node_shellcache
node_server -->|"reads and writes"| node_sqlite
node_server -->|"checks and hashes PINs"| node_pin
node_server -->|"creates and manages"| node_keypool
node_pinchange -->|"verifies and hashes"| node_pin
node_pinchange -->|"updates PIN settings"| node_sqlite
node_server -->|"fetches price history"| node_yahoo
node_server -->|"analyzes closes"| node_quant
node_server -.->|"requests summaries"| node_keypool
node_keypool -->|"requests model summary"| node_openrouter
node_server -->|"persists snapshots and pause"| node_sqlite

click node_browser "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/public/index.html"
click node_ui "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/src/app.ts"
click node_shellcache "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/public/sw.js"
click node_server "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/server.js"
click node_quant "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/quant.mjs"
click node_pin "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/pin.mjs"
click node_keypool "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/key-pool.mjs"
click node_pinchange "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/tools/change-pin.mjs"
click node_sqlite "https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/server.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_browser,node_ui,node_shellcache,node_user toneBlue
class node_server,node_quant toneAmber
class node_pin,node_keypool,node_pinchange toneMint
class node_sqlite toneRose
class node_yahoo,node_openrouter toneIndigo
```

## Components

### Phone experience

- [Browser shell](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/public/index.html): `public/index.html`
- [Market interface](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/src/app.ts): `src/app.ts`
- [Shell cache](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/public/sw.js): `public/sw.js`

### Scan service

- [HTTP server](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/server.js): `server.js`
- [Trend analysis](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/quant.mjs): `lib/quant.mjs`

### Access and keys

- [PIN utilities](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/pin.mjs): `lib/pin.mjs`
- [Encrypted key pool](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/lib/key-pool.mjs): `lib/key-pool.mjs`
- [PIN change command](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/tools/change-pin.mjs): `tools/change-pin.mjs`

### Local state

- [Local SQLite](https://github.com/thisgmailisminelilfella-dev/aprture-mibole/blob/main/server.js): `server.js`

### External services

- **Yahoo Finance**
- **OpenRouter**

### Other components

- **Phone user**

## Connections

- Phone user → Browser shell: opens (evidence: `README.md`)
- Browser shell → Market interface: loads (evidence: `README.md`)
- Market interface → HTTP server: requests state and scans (evidence: `src/app.ts`)
- HTTP server → Market interface: publishes updates (evidence: `src/app.ts`)
- Browser shell → Shell cache: registers shell cache (evidence: `README.md`)
- HTTP server → Local SQLite: reads and writes (evidence: `server.js`)
- HTTP server → PIN utilities: checks and hashes PINs (evidence: `server.js`)
- HTTP server → Encrypted key pool: creates and manages (evidence: `server.js`)
- PIN change command → PIN utilities: verifies and hashes (evidence: `tools/change-pin.mjs`)
- PIN change command → Local SQLite: updates PIN settings (evidence: `tools/change-pin.mjs`)
- HTTP server → Yahoo Finance: fetches price history (evidence: `README.md`)
- HTTP server → Trend analysis: analyzes closes (evidence: `server.js`)
- HTTP server → Encrypted key pool: requests summaries (evidence: `README.md`)
- Encrypted key pool → OpenRouter: requests model summary (evidence: `lib/key-pool.mjs`)
- HTTP server → Local SQLite: persists snapshots and pause (evidence: `README.md`)
