# resolvr-io/apogee architecture

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

- Interactive diagram: https://gitdiagram.com/resolvr-io/apogee
- Repository: https://github.com/resolvr-io/apogee

## Overview

#### Purpose and Entry Points
Apogee is an MV3 Chromium browser extension providing a self-custodial Liquid wallet and injected Liquid dapp provider. Build manifests define extension surfaces in `manifest.config.ts` and `manifest.shared.ts`. Runtime entry points are the background service worker (`src/background/index.ts`), offscreen wallet runtime (`src/offscreen/offscreen.ts`), side-panel React app (`src/sidepanel/main.tsx`), and page/content provider bridge (`src/content/content.ts`, `src/provider/liquid-provider.ts`).

#### Privileged Wallet Boundary
Keys, `lwk_wasm`, signing, descriptor derivation, chain synchronization, and transaction operations are confined to the offscreen document. The background worker brokers requests and serializes engine access, preventing UI and dapp calls from re-entrantly sharing cached wallet state. Core wallet protocol and operations reside in `src/engine/protocol.ts`, `src/engine/engine-core.ts`, and `src/offscreen/offscreen.ts`.

#### Persistence, Identity, and Locking
The keystore stores an encrypted local BIP-39 seed while retaining a cleartext watch-only descriptor for locked-state synchronization. It supports migrations and service-worker/session recovery; seeds are only decrypted for signing. Wallet identity and public descriptor handling are separated from signing material in `src/keystore/keystore.ts`, `src/keystore/crypto.ts`, `src/engine/wallet-identity.ts`, and `src/engine/public-wallet-descriptor.ts`. Jade wallets are seedless/watch-only locally.

#### UI and Approval Control Plane
The React side panel owns onboarding, unlock, portfolio, receive, send, swap, settings, and user-facing transaction/connection state. Sensitive dapp connection and transaction requests are routed into approval UI, using the side panel when available or a prompt surface otherwise. Principal surfaces are `src/sidepanel/App.tsx`, `src/sidepanel/wallet-client.ts`, `src/sidepanel/screens/Approval.tsx`, and `src/prompt/prompt.tsx`.

#### Dapp Provider Pipeline
A MAIN-world provider exposes `window.apogee` and compatibility surfaces, while an isolated content script relays page messages through Chrome runtime messaging. The background validates origin sessions, permissions, lock state, and approval outcomes before forwarding privileged requests to the engine. Provider methods cover wallet status/data, transfers, UTXOs, descriptor disclosure, and PSET signing/broadcast. Relevant boundaries are `src/provider/liquid-provider.ts`, `src/provider/liquid-browser-provider-runtime.ts`, `src/content/content.ts`, and `src/background/index.ts`.

#### Transaction and PSET Safety
Side-panel sends and provider calls converge on engine PSET construction/signing/broadcast. Provider-built PSETs receive wallet-scoped analysis and explicit capability/request approval before local or hardware signing; broadcasting is separately explicit. Transaction validation and output/recipient interpretation are implemented in `src/engine/provider-pset-analyzer.ts`, `src/engine/provider-pset-review.ts`, `src/engine/verify-dealer-pset.ts`, and `src/provider/liquid-provider-pset-broadcast.ts`.

#### External Integrations and Infrastructure
`lwk_wasm` is the Liquid Wallet Kit engine and uses Esplora for Liquid chain data. SideSwap integration supplies swap orchestration through `src/sideswap/client.ts` and `src/sideswap/orchestrator.ts`. Blockstream Jade support uses Web Serial in a dedicated pairing/signing window (`src/jade/jade.ts`, `src/sidepanel/jade-window.ts`). The project uses CRXJS/Vite, React, Tailwind, TypeScript, pnpm, and GitHub Actions; provider conformance has a standalone browser playground at `playground/liquid-provider/main.ts`.

Main entry points: [`src/background/index.ts`](https://github.com/resolvr-io/apogee/blob/main/src/background/index.ts) (Background broker), [`src/engine/engine-core.ts`](https://github.com/resolvr-io/apogee/blob/main/src/engine/engine-core.ts) (Wallet engine core), [`manifest.config.ts`](https://github.com/resolvr-io/apogee/blob/main/manifest.config.ts) (MV3 manifests), [`src/offscreen/offscreen.ts`](https://github.com/resolvr-io/apogee/blob/main/src/offscreen/offscreen.ts) (Offscreen wallet runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Extension surfaces"]
  node_manifest["MV3 manifests<br/>build configuration<br/>[manifest.config.ts]"]
  node_background{{"Background broker<br/>service worker<br/>[index.ts]"}}
end

subgraph group_wallet["Wallet security boundary"]
  node_offscreen{{"Offscreen wallet runtime<br/>[offscreen.ts]"}}
  node_engine["Wallet engine core<br/>wallet operations<br/>[engine-core.ts]"]
  node_keystore[("Encrypted keystore<br/>seed storage<br/>[keystore.ts]")]
  node_identity["Wallet identity<br/>public descriptor"]
  node_pset_review["PSET safety review<br/>transaction validation"]
end

subgraph group_dapp["Dapp provider pipeline"]
  node_provider["MAIN-world provider<br/>injected API<br/>[liquid-provider.ts]"]
  node_content["Content bridge<br/>isolated content script<br/>[content.ts]"]
end

subgraph group_ui["User control plane"]
  node_sidepanel["Side panel app<br/>React UI<br/>[App.tsx]"]
  node_wallet_client["Wallet client<br/>UI protocol client<br/>[wallet-client.ts]"]
  node_approval["Approval UI<br/>request approval<br/>[Approval.tsx]"]
  node_prompt["Prompt surface<br/>fallback approval UI<br/>[prompt.tsx]"]
end

subgraph group_integrations["External integrations"]
  node_lwk{{"Liquid Wallet Kit<br/>lwk_wasm engine"}}
  node_esplora[("Esplora<br/>Liquid chain service")]
  node_sideswap["SideSwap orchestration<br/>swap integration<br/>[orchestrator.ts]"]
  node_jade["Jade hardware wallet<br/>Web Serial integration<br/>[jade.ts]"]
end

node_manifest -->|"declares"| node_background
node_manifest -->|"declares"| node_offscreen
node_manifest -->|"declares"| node_sidepanel
node_provider -->|"page messages"| node_content
node_content -->|"runtime messages"| node_background
node_background -->|"serialized privileged requests"| node_offscreen
node_background -->|"approval requests"| node_approval
node_background -.->|"fallback approval"| node_prompt
node_sidepanel -->|"uses"| node_wallet_client
node_wallet_client -->|"wallet requests"| node_background
node_approval -->|"decision"| node_background
node_prompt -->|"decision"| node_background
node_offscreen -->|"runs"| node_engine
node_engine -->|"loads encrypted seed"| node_keystore
node_engine -->|"uses public identity"| node_identity
node_engine -->|"reviews provider PSETs"| node_pset_review
node_engine -->|"wallet primitives"| node_lwk
node_lwk -->|"chain data"| node_esplora
node_engine -->|"swap operations"| node_sideswap
node_engine -->|"hardware signing"| node_jade
node_pset_review -->|"explicit capability approval"| node_approval

click node_manifest "https://github.com/resolvr-io/apogee/blob/main/manifest.config.ts"
click node_background "https://github.com/resolvr-io/apogee/blob/main/src/background/index.ts"
click node_offscreen "https://github.com/resolvr-io/apogee/blob/main/src/offscreen/offscreen.ts"
click node_engine "https://github.com/resolvr-io/apogee/blob/main/src/engine/engine-core.ts"
click node_keystore "https://github.com/resolvr-io/apogee/blob/main/src/keystore/keystore.ts"
click node_pset_review "https://github.com/resolvr-io/apogee/blob/main/src/engine/provider-pset-review.ts"
click node_provider "https://github.com/resolvr-io/apogee/blob/main/src/provider/liquid-provider.ts"
click node_content "https://github.com/resolvr-io/apogee/blob/main/src/content/content.ts"
click node_sidepanel "https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/App.tsx"
click node_wallet_client "https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/wallet-client.ts"
click node_approval "https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/screens/Approval.tsx"
click node_prompt "https://github.com/resolvr-io/apogee/blob/main/src/prompt/prompt.tsx"
click node_sideswap "https://github.com/resolvr-io/apogee/blob/main/src/sideswap/orchestrator.ts"
click node_jade "https://github.com/resolvr-io/apogee/blob/main/src/jade/jade.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_manifest,node_background toneBlue
class node_offscreen,node_engine,node_keystore,node_identity,node_pset_review toneAmber
class node_provider,node_content toneMint
class node_sidepanel,node_wallet_client,node_approval,node_prompt toneRose
class node_lwk,node_esplora,node_sideswap,node_jade toneIndigo
```

## Components

### Extension surfaces

- [MV3 manifests](https://github.com/resolvr-io/apogee/blob/main/manifest.config.ts): build configuration · Defines extension runtime surfaces. · `manifest.config.ts`
- [Background broker](https://github.com/resolvr-io/apogee/blob/main/src/background/index.ts): service worker · Serializes privileged requests and validates dapp sessions. · `src/background/index.ts`

### Wallet security boundary

Offscreen runtime exclusively owns keys and wallet engine access.

- [Offscreen wallet runtime](https://github.com/resolvr-io/apogee/blob/main/src/offscreen/offscreen.ts): wallet runtime · Exclusive execution boundary for keys, signing, and wallet state. · `src/offscreen/offscreen.ts`
- [Wallet engine core](https://github.com/resolvr-io/apogee/blob/main/src/engine/engine-core.ts): wallet operations · Implements wallet protocol, synchronization, and transaction operations. · `src/engine/engine-core.ts`
- [Encrypted keystore](https://github.com/resolvr-io/apogee/blob/main/src/keystore/keystore.ts): seed storage · Stores encrypted seed and cleartext watch-only descriptor. · `src/keystore/keystore.ts`
- **Wallet identity**: public descriptor · Separates public wallet identity from signing material.
- [PSET safety review](https://github.com/resolvr-io/apogee/blob/main/src/engine/provider-pset-review.ts): transaction validation · Analyzes wallet-scoped PSETs and recipient outputs before approval. · `src/engine/provider-pset-review.ts`

### Dapp provider pipeline

- [MAIN-world provider](https://github.com/resolvr-io/apogee/blob/main/src/provider/liquid-provider.ts): injected API · Exposes window.apogee and provider compatibility methods. · `src/provider/liquid-provider.ts`
- [Content bridge](https://github.com/resolvr-io/apogee/blob/main/src/content/content.ts): isolated content script · Relays page messages through Chrome runtime messaging. · `src/content/content.ts`

### User control plane

- [Side panel app](https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/App.tsx): React UI · Owns wallet flows and user-facing state. · `src/sidepanel/App.tsx`
- [Wallet client](https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/wallet-client.ts): UI protocol client · `src/sidepanel/wallet-client.ts`
- [Approval UI](https://github.com/resolvr-io/apogee/blob/main/src/sidepanel/screens/Approval.tsx): request approval · Collects connection and transaction decisions. · `src/sidepanel/screens/Approval.tsx`
- [Prompt surface](https://github.com/resolvr-io/apogee/blob/main/src/prompt/prompt.tsx): fallback approval UI · Used when the side panel is unavailable. · `src/prompt/prompt.tsx`

### External integrations

- **Liquid Wallet Kit**: lwk_wasm engine · Provides Liquid wallet primitives and chain synchronization.
- **Esplora**: Liquid chain service
- [SideSwap orchestration](https://github.com/resolvr-io/apogee/blob/main/src/sideswap/orchestrator.ts): swap integration · `src/sideswap/orchestrator.ts`
- [Jade hardware wallet](https://github.com/resolvr-io/apogee/blob/main/src/jade/jade.ts): Web Serial integration · Seedless local wallet pairing and hardware signing. · `src/jade/jade.ts`

## Connections

- MV3 manifests → Background broker: declares
- MV3 manifests → Offscreen wallet runtime: declares
- MV3 manifests → Side panel app: declares
- MAIN-world provider → Content bridge: page messages
- Content bridge → Background broker: runtime messages
- Background broker → Offscreen wallet runtime: serialized privileged requests
- Background broker → Approval UI: approval requests
- Background broker → Prompt surface: fallback approval
- Side panel app → Wallet client: uses
- Wallet client → Background broker: wallet requests
- Approval UI → Background broker: decision
- Prompt surface → Background broker: decision
- Offscreen wallet runtime → Wallet engine core: runs
- Wallet engine core → Encrypted keystore: loads encrypted seed
- Wallet engine core → Wallet identity: uses public identity
- Wallet engine core → PSET safety review: reviews provider PSETs
- Wallet engine core → Liquid Wallet Kit: wallet primitives
- Liquid Wallet Kit → Esplora: chain data
- Wallet engine core → SideSwap orchestration: swap operations
- Wallet engine core → Jade hardware wallet: hardware signing
- PSET safety review → Approval UI: explicit capability approval
