# ag0x123/pinesign architecture

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

- Interactive diagram: https://gitdiagram.com/ag0x123/pinesign
- Repository: https://github.com/ag0x123/pinesign

## Overview

PineSign encrypts files in the sender’s browser, stores ciphertext through a self-hostable gateway, and lets the recipient decrypt and sign a claim. The gateway verifies that claim and publishes a frozen receipt through ENS on Ethereum. The README describes email-code/passkey sign-in as the current direction, while sampled sign-in code still implements Circle; the graph preserves the documented capability without asserting those implementations are the same. Some gateway routes and setup steps were not excerpted, so uncertain links are omitted.

Main entry points: [`gateway/server.js`](https://github.com/ag0x123/pinesign/blob/main/gateway/server.js) (HTTP gateway), [`shared/keysource.js`](https://github.com/ag0x123/pinesign/blob/main/shared/keysource.js) (Key selection), [`gateway/ens.js`](https://github.com/ag0x123/pinesign/blob/main/gateway/ens.js) (ENSv2 integration), [`shared/client.js`](https://github.com/ag0x123/pinesign/blob/main/shared/client.js) (Gateway client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_onboard["Sign-in and send<br/>[onboard.js]"]
  node_claim["Claim transfer<br/>[claim.js]"]
  node_setupui["Gateway setup UI<br/>[setup.js]"]
  node_session["Account session<br/>[session.js]"]
end

subgraph group_keys["Identity and cryptography"]
  node_keysource["Key selection<br/>[keysource.js]"]
  node_identity[("Local identity<br/>[identity.js]")]
  node_crypto["Encryption and signatures<br/>[crypto.js]"]
  node_bridge["Extension bridge<br/>[bridge.js]"]
end

subgraph group_gateway["Gateway services"]
  node_gatewayclient["Gateway client<br/>[client.js]"]
  node_server["HTTP gateway<br/>[server.js]"]
  node_store[("Transfer storage<br/>[store.js]")]
  node_swarm["Ciphertext storage<br/>[swarm.js]"]
  node_bee["Swarm access<br/>[bee.js]"]
  node_auth["Nonce authentication<br/>[auth.js]"]
  node_setup["Gateway provisioning<br/>[setup.js]"]
  node_mail["Email delivery<br/>[mail.js]"]
  node_names["Name resolution<br/>[names.js]"]
end

subgraph group_proof["ENS receipts"]
  node_chain["Ethereum operations<br/>[chain.js]"]
  node_ens["ENSv2 integration<br/>[ens.js]"]
  node_resolver["Receipt resolver"]
  node_receipts["Receipt contract"]
end

node_sender(("Sender"))
node_recipient(("Recipient"))
node_ethereum{{"Ethereum and ENS"}}
node_swarmservice{{"Swarm network"}}

node_sender -->|"starts transfer"| node_onboard
node_recipient -->|"opens transfer"| node_claim
node_onboard -->|"uses keys"| node_keysource
node_onboard -->|"sends request"| node_gatewayclient
node_claim -->|"decrypts and signs"| node_keysource
node_claim -->|"claims transfer"| node_gatewayclient
node_session -->|"reads session"| node_onboard
node_keysource -->|"loads identity"| node_identity
node_keysource -->|"checks extension"| node_bridge
node_keysource -->|"encrypts and signs"| node_crypto
node_keysource -->|"creates signer"| node_gatewayclient
node_gatewayclient -->|"signs nonce"| node_crypto
node_gatewayclient -->|"calls API"| node_server
node_server -->|"authenticates writes"| node_auth
node_server -->|"reads and records transfers"| node_store
node_server -->|"handles blob routes"| node_swarm
node_swarm -->|"uses Swarm access"| node_bee
node_swarm -->|"stores ciphertext"| node_swarmservice
node_server -->|"routes setup"| node_setup
node_server -->|"routes name lookup"| node_names
node_server -.->|"sends email"| node_mail
node_setupui -.->|"configures gateway"| node_server
node_setup -->|"provisions chain"| node_chain
node_setup -->|"registers name"| node_ens
node_ens -->|"deploys and attaches"| node_resolver
node_ens -->|"writes ENS records"| node_ethereum
node_chain -->|"reads and writes chain"| node_ethereum
node_server -.->|"publishes claim receipt"| node_ens
node_ens -->|"finalizes records"| node_resolver
node_resolver -->|"serves frozen proof"| node_ethereum
node_receipts -.->|"records receipts"| node_ethereum

click node_onboard "https://github.com/ag0x123/pinesign/blob/main/web/src/onboard.js"
click node_claim "https://github.com/ag0x123/pinesign/blob/main/web/src/claim.js"
click node_setupui "https://github.com/ag0x123/pinesign/blob/main/web/src/setup.js"
click node_session "https://github.com/ag0x123/pinesign/blob/main/web/src/session.js"
click node_keysource "https://github.com/ag0x123/pinesign/blob/main/shared/keysource.js"
click node_identity "https://github.com/ag0x123/pinesign/blob/main/shared/identity.js"
click node_crypto "https://github.com/ag0x123/pinesign/blob/main/shared/crypto.js"
click node_bridge "https://github.com/ag0x123/pinesign/blob/main/shared/bridge.js"
click node_gatewayclient "https://github.com/ag0x123/pinesign/blob/main/shared/client.js"
click node_server "https://github.com/ag0x123/pinesign/blob/main/gateway/server.js"
click node_store "https://github.com/ag0x123/pinesign/blob/main/gateway/store.js"
click node_swarm "https://github.com/ag0x123/pinesign/blob/main/gateway/swarm.js"
click node_bee "https://github.com/ag0x123/pinesign/blob/main/gateway/bee.js"
click node_auth "https://github.com/ag0x123/pinesign/blob/main/gateway/auth.js"
click node_setup "https://github.com/ag0x123/pinesign/blob/main/gateway/setup.js"
click node_mail "https://github.com/ag0x123/pinesign/blob/main/gateway/mail.js"
click node_names "https://github.com/ag0x123/pinesign/blob/main/gateway/names.js"
click node_chain "https://github.com/ag0x123/pinesign/blob/main/gateway/chain.js"
click node_ens "https://github.com/ag0x123/pinesign/blob/main/gateway/ens.js"
click node_resolver "https://github.com/ag0x123/pinesign/blob/main/contracts/src/PineSignResolver.sol"
click node_receipts "https://github.com/ag0x123/pinesign/blob/main/contracts/src/PineSignReceipts.sol"

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_onboard,node_claim,node_setupui,node_session toneBlue
class node_keysource,node_identity,node_crypto,node_bridge toneAmber
class node_gatewayclient,node_server,node_store,node_swarm,node_bee,node_auth,node_setup,node_mail,node_names toneMint
class node_chain,node_ens,node_resolver,node_receipts toneRose
class node_sender,node_recipient,node_ethereum,node_swarmservice toneIndigo
```

## Components

### Web experience

- [Sign-in and send](https://github.com/ag0x123/pinesign/blob/main/web/src/onboard.js): `web/src/onboard.js`
- [Claim transfer](https://github.com/ag0x123/pinesign/blob/main/web/src/claim.js): `web/src/claim.js`
- [Gateway setup UI](https://github.com/ag0x123/pinesign/blob/main/web/src/setup.js): `web/src/setup.js`
- [Account session](https://github.com/ag0x123/pinesign/blob/main/web/src/session.js): `web/src/session.js`

### Identity and cryptography

- [Key selection](https://github.com/ag0x123/pinesign/blob/main/shared/keysource.js): `shared/keysource.js`
- [Local identity](https://github.com/ag0x123/pinesign/blob/main/shared/identity.js): `shared/identity.js`
- [Encryption and signatures](https://github.com/ag0x123/pinesign/blob/main/shared/crypto.js): `shared/crypto.js`
- [Extension bridge](https://github.com/ag0x123/pinesign/blob/main/shared/bridge.js): `shared/bridge.js`

### Gateway services

- [Gateway client](https://github.com/ag0x123/pinesign/blob/main/shared/client.js): `shared/client.js`
- [HTTP gateway](https://github.com/ag0x123/pinesign/blob/main/gateway/server.js): `gateway/server.js`
- [Transfer storage](https://github.com/ag0x123/pinesign/blob/main/gateway/store.js): `gateway/store.js`
- [Ciphertext storage](https://github.com/ag0x123/pinesign/blob/main/gateway/swarm.js): `gateway/swarm.js`
- [Swarm access](https://github.com/ag0x123/pinesign/blob/main/gateway/bee.js): `gateway/bee.js`
- [Nonce authentication](https://github.com/ag0x123/pinesign/blob/main/gateway/auth.js): `gateway/auth.js`
- [Gateway provisioning](https://github.com/ag0x123/pinesign/blob/main/gateway/setup.js): `gateway/setup.js`
- [Email delivery](https://github.com/ag0x123/pinesign/blob/main/gateway/mail.js): `gateway/mail.js`
- [Name resolution](https://github.com/ag0x123/pinesign/blob/main/gateway/names.js): `gateway/names.js`

### ENS receipts

- [Ethereum operations](https://github.com/ag0x123/pinesign/blob/main/gateway/chain.js): `gateway/chain.js`
- [ENSv2 integration](https://github.com/ag0x123/pinesign/blob/main/gateway/ens.js): `gateway/ens.js`
- [Receipt resolver](https://github.com/ag0x123/pinesign/blob/main/contracts/src/PineSignResolver.sol): `contracts/src/PineSignResolver.sol`
- [Receipt contract](https://github.com/ag0x123/pinesign/blob/main/contracts/src/PineSignReceipts.sol): `contracts/src/PineSignReceipts.sol`

### Other components

- **Sender**
- **Recipient**
- **Ethereum and ENS**
- **Swarm network**

## Connections

- Sender → Sign-in and send: starts transfer (evidence: `README.md`)
- Recipient → Claim transfer: opens transfer (evidence: `README.md`)
- Sign-in and send → Key selection: uses keys (evidence: `shared/keysource.js`)
- Sign-in and send → Gateway client: sends request (evidence: `shared/client.js`)
- Claim transfer → Key selection: decrypts and signs (evidence: `shared/keysource.js`)
- Claim transfer → Gateway client: claims transfer (evidence: `shared/client.js`)
- Account session → Sign-in and send: reads session (evidence: `web/src/session.js`)
- Key selection → Local identity: loads identity (evidence: `shared/keysource.js`)
- Key selection → Extension bridge: checks extension (evidence: `shared/keysource.js`)
- Key selection → Encryption and signatures: encrypts and signs (evidence: `shared/keysource.js`)
- Key selection → Gateway client: creates signer (evidence: `shared/keysource.js`)
- Gateway client → Encryption and signatures: signs nonce (evidence: `shared/client.js`)
- Gateway client → HTTP gateway: calls API (evidence: `shared/client.js`)
- HTTP gateway → Nonce authentication: authenticates writes (evidence: `gateway/server.js`)
- HTTP gateway → Transfer storage: reads and records transfers (evidence: `gateway/server.js`)
- HTTP gateway → Ciphertext storage: handles blob routes (evidence: `gateway/server.js`)
- Ciphertext storage → Swarm access: uses Swarm access (evidence: `gateway/swarm.js`)
- Ciphertext storage → Swarm network: stores ciphertext (evidence: `README.md`)
- HTTP gateway → Gateway provisioning: routes setup (evidence: `gateway/server.js`)
- HTTP gateway → Name resolution: routes name lookup (evidence: `gateway/server.js`)
- HTTP gateway → Email delivery: sends email (evidence: `gateway/server.js`)
- Gateway setup UI → HTTP gateway: configures gateway
- Gateway provisioning → Ethereum operations: provisions chain (evidence: `gateway/setup.js`)
- Gateway provisioning → ENSv2 integration: registers name (evidence: `gateway/setup.js`)
- ENSv2 integration → Receipt resolver: deploys and attaches (evidence: `gateway/ens.js`)
- ENSv2 integration → Ethereum and ENS: writes ENS records (evidence: `README.md`)
- Ethereum operations → Ethereum and ENS: reads and writes chain (evidence: `gateway/chain.js`)
- HTTP gateway → ENSv2 integration: publishes claim receipt (evidence: `gateway/server.js`)
- ENSv2 integration → Receipt resolver: finalizes records (evidence: `gateway/ens.js`)
- Receipt resolver → Ethereum and ENS: serves frozen proof (evidence: `README.md`)
- Receipt contract → Ethereum and ENS: records receipts
