# k-phi-entreprise/treasury-synapse architecture

> Architecture diagram of the GitHub repository k-phi-entreprise/treasury-synapse, 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/k-phi-entreprise/treasury-synapse
- Repository: https://github.com/k-phi-entreprise/treasury-synapse

## Overview

Treasury Synapse is a public-source map of treasury technology companies, systems, and people, with market, people, topics, and connections views. The main visitor workflow is to explore the map and its graph API; visitors can also claim cards, make declarations, submit corrections or connection requests, and request help. Separately, crawler jobs build and deepen the evidence-backed market and people data. The README documents major capabilities whose implementation was not fully sampled; edges are included only where the README or excerpts support the relationship.

Main entry points: [`db/schema.sql`](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/db/schema.sql) (Postgres facts store), [`mail.js`](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/mail.js) (Email delivery), [`scripts/crawl.js`](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/crawl.js) (People crawler), [`public/index.html`](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/public/index.html) (Interactive map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_map["Map and discovery"]
  node_map_ui["Interactive map<br/>[index.html]"]
  node_graph_api["Graph API<br/>[server.js]"]
  node_chat["Map chat<br/>[chat.js]"]
end

subgraph group_evidence["Evidence collection"]
  node_market_crawler["Market harvester<br/>[market.js]"]
  node_people_crawler["People crawler<br/>[crawl.js]"]
  node_company_enrichment["Company enrichment<br/>[enrich.js]"]
  node_seed_data["Market seed data<br/>[market-seed.json]"]
end

subgraph group_community["People and submissions"]
  node_claims["Card claims<br/>[claims.js]"]
  node_declarations["Profile declarations<br/>[declarations.js]"]
  node_connections["Connection submissions<br/>[server.js]"]
end

subgraph group_operations["Review and requests"]
  node_submissions["Visitor submissions<br/>[server.js]"]
  node_review["Owner review<br/>[review.html]"]
  node_help_requests["Help requests<br/>[requests.js]"]
  node_consultant_search["Consultant search<br/>[consultants.js]"]
  node_mail["Email delivery<br/>[mail.js]"]
  node_digest["Queue digest<br/>[digest.js]"]
end

subgraph group_platform["Data platform"]
  node_postgres[("Postgres facts store<br/>[schema.sql]")]
  node_db_pool["Database pool<br/>[db.js]"]
end

node_visitor(("Map visitor"))
node_anthropic{{"Anthropic API"}}
node_market_sources{{"Public web sources"}}
node_wikidata{{"Wikidata"}}

node_visitor -->|"explores"| node_map_ui
node_map_ui -->|"fetches graph"| node_graph_api
node_graph_api -->|"reads facts"| node_postgres
node_map_ui -->|"asks questions"| node_chat
node_chat -->|"queries model"| node_anthropic
node_market_crawler -->|"harvests pages"| node_market_sources
node_market_crawler -->|"writes installs"| node_postgres
node_seed_data -->|"seeds market"| node_market_crawler
node_people_crawler -->|"fetches pages"| node_market_sources
node_people_crawler -->|"uses web tools"| node_anthropic
node_people_crawler -->|"writes findings"| node_postgres
node_company_enrichment -->|"looks up companies"| node_wikidata
node_company_enrichment -->|"updates profiles"| node_postgres
node_visitor -->|"claims card"| node_claims
node_claims -->|"sends sign-in links"| node_mail
node_visitor -->|"updates profile"| node_declarations
node_declarations -->|"stores declarations"| node_postgres
node_visitor -->|"declares connection"| node_connections
node_connections -->|"stores pending link"| node_postgres
node_visitor -->|"submits correction"| node_submissions
node_submissions -->|"queues for review"| node_review
node_submissions -->|"sends confirmation"| node_mail
node_visitor -->|"requests help"| node_help_requests
node_help_requests -->|"stores request"| node_postgres
node_help_requests -->|"sends confirmation"| node_mail
node_visitor -->|"finds advisers"| node_consultant_search
node_digest -->|"reads queue"| node_postgres
node_digest -->|"sends digest"| node_mail
node_db_pool -->|"connects pool"| node_postgres

click node_map_ui "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/public/index.html"
click node_graph_api "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js"
click node_chat "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/chat.js"
click node_market_crawler "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/market.js"
click node_people_crawler "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/crawl.js"
click node_company_enrichment "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/enrich.js"
click node_seed_data "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/data/market-seed.json"
click node_claims "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/claims.js"
click node_declarations "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/declarations.js"
click node_connections "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js"
click node_submissions "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js"
click node_review "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/public/review.html"
click node_help_requests "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/requests.js"
click node_consultant_search "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/consultants.js"
click node_mail "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/mail.js"
click node_postgres "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/db/schema.sql"
click node_db_pool "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/db.js"
click node_digest "https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/digest.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_map_ui,node_graph_api,node_chat toneBlue
class node_market_crawler,node_people_crawler,node_company_enrichment,node_seed_data toneAmber
class node_claims,node_declarations,node_connections,node_anthropic toneMint
class node_submissions,node_review,node_help_requests,node_consultant_search,node_mail,node_digest toneRose
class node_postgres,node_db_pool,node_visitor,node_market_sources,node_wikidata toneIndigo
```

## Components

### Map and discovery

- [Interactive map](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/public/index.html): `public/index.html`
- [Graph API](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js): `server.js`
- [Map chat](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/chat.js): `chat.js`

### Evidence collection

- [Market harvester](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/market.js): `scripts/market.js`
- [People crawler](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/crawl.js): `scripts/crawl.js`
- [Company enrichment](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/enrich.js): `scripts/enrich.js`
- [Market seed data](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/data/market-seed.json): `data/market-seed.json`

### People and submissions

- [Card claims](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/claims.js): `claims.js`
- [Profile declarations](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/declarations.js): `declarations.js`
- [Connection submissions](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js): `server.js`

### Review and requests

- [Visitor submissions](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/server.js): `server.js`
- [Owner review](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/public/review.html): `public/review.html`
- [Help requests](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/requests.js): `requests.js`
- [Consultant search](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/consultants.js): `consultants.js`
- [Email delivery](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/mail.js): `mail.js`
- [Queue digest](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/digest.js): `scripts/digest.js`

### Data platform

- [Postgres facts store](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/db/schema.sql): `db/schema.sql`
- [Database pool](https://github.com/k-phi-entreprise/treasury-synapse/blob/main/scripts/db.js): `scripts/db.js`

### Other components

- **Map visitor**
- **Anthropic API**
- **Public web sources**
- **Wikidata**

## Connections

- Map visitor → Interactive map: explores (evidence: `README.md`)
- Interactive map → Graph API: fetches graph (evidence: `README.md`)
- Graph API → Postgres facts store: reads facts (evidence: `README.md`)
- Interactive map → Map chat: asks questions (evidence: `README.md`)
- Map chat → Anthropic API: queries model (evidence: `chat.js`)
- Market harvester → Public web sources: harvests pages (evidence: `scripts/market.js`)
- Market harvester → Postgres facts store: writes installs (evidence: `scripts/market.js`)
- Market seed data → Market harvester: seeds market (evidence: `scripts/market.js`)
- People crawler → Public web sources: fetches pages (evidence: `scripts/crawl.js`)
- People crawler → Anthropic API: uses web tools (evidence: `scripts/crawl.js`)
- People crawler → Postgres facts store: writes findings (evidence: `scripts/crawl.js`)
- Company enrichment → Wikidata: looks up companies (evidence: `scripts/enrich.js`)
- Company enrichment → Postgres facts store: updates profiles (evidence: `scripts/enrich.js`)
- Map visitor → Card claims: claims card (evidence: `README.md`)
- Card claims → Email delivery: sends sign-in links (evidence: `claims.js`)
- Map visitor → Profile declarations: updates profile (evidence: `README.md`)
- Profile declarations → Postgres facts store: stores declarations (evidence: `declarations.js`)
- Map visitor → Connection submissions: declares connection (evidence: `server.js`)
- Connection submissions → Postgres facts store: stores pending link (evidence: `server.js`)
- Map visitor → Visitor submissions: submits correction (evidence: `README.md`)
- Visitor submissions → Owner review: queues for review (evidence: `README.md`)
- Visitor submissions → Email delivery: sends confirmation (evidence: `server.js`)
- Map visitor → Help requests: requests help (evidence: `requests.js`)
- Help requests → Postgres facts store: stores request (evidence: `requests.js`)
- Help requests → Email delivery: sends confirmation (evidence: `requests.js`)
- Map visitor → Consultant search: finds advisers (evidence: `consultants.js`)
- Queue digest → Postgres facts store: reads queue (evidence: `scripts/digest.js`)
- Queue digest → Email delivery: sends digest (evidence: `scripts/digest.js`)
- Database pool → Postgres facts store: connects pool (evidence: `scripts/db.js`)
