# elmo33/audio-twin architecture

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

- Interactive diagram: https://gitdiagram.com/elmo33/audio-twin
- Repository: https://github.com/elmo33/audio-twin

## Overview

Audio Twin Finder is a Next.js app for entering two listener profiles, finding similarly scored candidates, and confirming mutual matches before contact details unlock. Its main flow runs from the find form through submission and candidate scoring to match review and confirmation. Separate capabilities include city search and reporting, private session restoration, deletion, sharing, and aggregate campaign metrics. Some links below rely on README documentation; unsampled implementation details are not inferred beyond those documented relationships.

Main entry points: [`web/src/lib/db.ts`](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/db.ts) (Postgres + PostGIS), [`web/src/app/actions.ts`](https://github.com/elmo33/audio-twin/blob/main/web/src/app/actions.ts) (Confirm and delete), [`web/src/lib/data.ts`](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/data.ts) (Candidate search), [`web/src/components/CityPicker.tsx`](https://github.com/elmo33/audio-twin/blob/main/web/src/components/CityPicker.tsx) (City picker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_find_page["Find page<br/>[page.tsx]"]
  node_find_loader["Saved-card loader<br/>[FindLoader.tsx]"]
  node_find_flow["Profile form<br/>[FindFlow.tsx]"]
  node_matches_page["Match list<br/>[page.tsx]"]
  node_match_detail["Match detail<br/>[page.tsx]"]
  node_share["Sharing tools<br/>[share.ts]"]
  node_card_text["Card text<br/>[cardText.ts]"]
  node_home["Landing and totals<br/>[page.tsx]"]
end

subgraph group_matching["Profiles and matching"]
  node_submit_route["Profile submission<br/>[route.ts]"]
  node_submit_logic["Submission rules<br/>[submit.ts]"]
  node_match_data["Candidate search<br/>[data.ts]"]
  node_scoring["Match scoring<br/>[match.ts]"]
  node_pair_records["Pair confirmations<br/>[pairs.ts]"]
end

subgraph group_cities["City discovery"]
  node_city_picker["City picker<br/>[CityPicker.tsx]"]
  node_city_keys["City search keys<br/>[city-key.mjs]"]
  node_city_export["City shard export<br/>[cities-export.mjs]"]
  node_city_setup["City data setup<br/>[setup.mjs]"]
  node_extra_cities["Hand-added cities<br/>[extra-cities.mjs]"]
  node_city_report["Missing-city reports<br/>[route.ts]"]
  node_city_reports["Report triage<br/>[city-triage.mjs]"]
end

subgraph group_operations["Privacy and metrics"]
  node_actions["Confirm and delete<br/>[actions.ts]"]
  node_session["Session and data<br/>[data.ts]"]
  node_session_flag["Card flag<br/>[session-flag.ts]"]
  node_database[("Postgres + PostGIS<br/>[db.ts]")]
  node_private_link["Private session link<br/>[route.ts]"]
  node_campaign_metrics["Campaign analytics<br/>[analytics.ts]"]
end

node_listener(("Listener"))

node_listener -->|"opens"| node_find_page
node_find_page -->|"renders"| node_find_loader
node_find_loader -->|"loads form"| node_find_flow
node_listener -->|"enters profiles"| node_find_flow
node_find_flow -->|"submits"| node_submit_route
node_submit_route -.->|"processes"| node_submit_logic
node_submit_logic -.->|"saves profiles"| node_database
node_listener -->|"views candidates"| node_matches_page
node_matches_page -->|"loads candidates"| node_match_data
node_match_data -->|"scores candidates"| node_scoring
node_match_data -->|"queries profiles"| node_database
node_match_detail -->|"loads match"| node_match_data
node_match_detail -->|"confirms match"| node_actions
node_actions -->|"records confirmation"| node_pair_records
node_actions -->|"checks perfection"| node_match_data
node_pair_records -.->|"persists pairs"| node_database
node_listener -->|"opens private link"| node_private_link
node_private_link -->|"restores session"| node_session
node_session -->|"reads session"| node_database
node_find_loader -->|"checks card flag"| node_session_flag
node_listener -->|"searches cities"| node_city_picker
node_city_picker -->|"normalizes query"| node_city_keys
node_city_picker -->|"loads static shards"| node_city_export
node_city_export -->|"keys city names"| node_city_keys
node_city_setup -->|"parses additions"| node_extra_cities
node_city_setup -.->|"loads city data"| node_database
node_city_export -->|"reads city rows"| node_database
node_city_picker -->|"reports missing city"| node_city_report
node_city_reports -->|"reviews reports"| node_database
node_listener -->|"shares result"| node_share
node_share -.->|"formats card"| node_card_text
node_listener -->|"deletes data"| node_actions
node_actions -->|"deletes account"| node_database
node_actions -->|"tracks events"| node_campaign_metrics
node_home -->|"shows pair totals"| node_campaign_metrics

click node_find_page "https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/page.tsx"
click node_find_loader "https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/FindLoader.tsx"
click node_find_flow "https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/FindFlow.tsx"
click node_submit_route "https://github.com/elmo33/audio-twin/blob/main/web/src/app/api/submit/route.ts"
click node_submit_logic "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/submit.ts"
click node_match_data "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/data.ts"
click node_scoring "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/match.ts"
click node_matches_page "https://github.com/elmo33/audio-twin/blob/main/web/src/app/matches/page.tsx"
click node_match_detail "https://github.com/elmo33/audio-twin/blob/main/web/src/app/matches/%5Bid%5D/page.tsx"
click node_actions "https://github.com/elmo33/audio-twin/blob/main/web/src/app/actions.ts"
click node_pair_records "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/pairs.ts"
click node_session "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/data.ts"
click node_session_flag "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/session-flag.ts"
click node_database "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/db.ts"
click node_private_link "https://github.com/elmo33/audio-twin/blob/main/web/src/app/r/%5Btoken%5D/route.ts"
click node_city_picker "https://github.com/elmo33/audio-twin/blob/main/web/src/components/CityPicker.tsx"
click node_city_keys "https://github.com/elmo33/audio-twin/blob/main/web/db/city-key.mjs"
click node_city_export "https://github.com/elmo33/audio-twin/blob/main/web/db/cities-export.mjs"
click node_city_setup "https://github.com/elmo33/audio-twin/blob/main/web/db/setup.mjs"
click node_extra_cities "https://github.com/elmo33/audio-twin/blob/main/web/db/extra-cities.mjs"
click node_city_report "https://github.com/elmo33/audio-twin/blob/main/web/src/app/api/city-report/route.ts"
click node_city_reports "https://github.com/elmo33/audio-twin/blob/main/web/db/city-triage.mjs"
click node_share "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/share.ts"
click node_card_text "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/cardText.ts"
click node_campaign_metrics "https://github.com/elmo33/audio-twin/blob/main/web/src/lib/analytics.ts"
click node_home "https://github.com/elmo33/audio-twin/blob/main/web/src/app/page.tsx"

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_find_page,node_find_loader,node_find_flow,node_matches_page,node_match_detail,node_share,node_card_text,node_home toneBlue
class node_submit_route,node_submit_logic,node_match_data,node_scoring,node_pair_records toneAmber
class node_city_picker,node_city_keys,node_city_export,node_city_setup,node_extra_cities,node_city_report,node_city_reports toneMint
class node_actions,node_session,node_session_flag,node_database,node_private_link,node_campaign_metrics toneRose
class node_listener toneIndigo
```

## Components

### User experience

- [Find page](https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/page.tsx): `web/src/app/find/page.tsx`
- [Saved-card loader](https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/FindLoader.tsx): `web/src/app/find/FindLoader.tsx`
- [Profile form](https://github.com/elmo33/audio-twin/blob/main/web/src/app/find/FindFlow.tsx): `web/src/app/find/FindFlow.tsx`
- [Match list](https://github.com/elmo33/audio-twin/blob/main/web/src/app/matches/page.tsx): `web/src/app/matches/page.tsx`
- [Match detail](https://github.com/elmo33/audio-twin/blob/main/web/src/app/matches/%5Bid%5D/page.tsx): `web/src/app/matches/[id]/page.tsx`
- [Sharing tools](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/share.ts): `web/src/lib/share.ts`
- [Card text](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/cardText.ts): `web/src/lib/cardText.ts`
- [Landing and totals](https://github.com/elmo33/audio-twin/blob/main/web/src/app/page.tsx): `web/src/app/page.tsx`

### Profiles and matching

- [Profile submission](https://github.com/elmo33/audio-twin/blob/main/web/src/app/api/submit/route.ts): `web/src/app/api/submit/route.ts`
- [Submission rules](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/submit.ts): `web/src/lib/submit.ts`
- [Candidate search](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/data.ts): `web/src/lib/data.ts`
- [Match scoring](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/match.ts): `web/src/lib/match.ts`
- [Pair confirmations](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/pairs.ts): `web/src/lib/pairs.ts`

### City discovery

- [City picker](https://github.com/elmo33/audio-twin/blob/main/web/src/components/CityPicker.tsx): `web/src/components/CityPicker.tsx`
- [City search keys](https://github.com/elmo33/audio-twin/blob/main/web/db/city-key.mjs): `web/db/city-key.mjs`
- [City shard export](https://github.com/elmo33/audio-twin/blob/main/web/db/cities-export.mjs): `web/db/cities-export.mjs`
- [City data setup](https://github.com/elmo33/audio-twin/blob/main/web/db/setup.mjs): `web/db/setup.mjs`
- [Hand-added cities](https://github.com/elmo33/audio-twin/blob/main/web/db/extra-cities.mjs): `web/db/extra-cities.mjs`
- [Missing-city reports](https://github.com/elmo33/audio-twin/blob/main/web/src/app/api/city-report/route.ts): `web/src/app/api/city-report/route.ts`
- [Report triage](https://github.com/elmo33/audio-twin/blob/main/web/db/city-triage.mjs): `web/db/city-triage.mjs`

### Privacy and metrics

- [Confirm and delete](https://github.com/elmo33/audio-twin/blob/main/web/src/app/actions.ts): `web/src/app/actions.ts`
- [Session and data](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/data.ts): `web/src/lib/data.ts`
- [Card flag](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/session-flag.ts): `web/src/lib/session-flag.ts`
- [Postgres + PostGIS](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/db.ts): `web/src/lib/db.ts`
- [Private session link](https://github.com/elmo33/audio-twin/blob/main/web/src/app/r/%5Btoken%5D/route.ts): `web/src/app/r/[token]/route.ts`
- [Campaign analytics](https://github.com/elmo33/audio-twin/blob/main/web/src/lib/analytics.ts): `web/src/lib/analytics.ts`

### Other components

- **Listener**

## Connections

- Listener → Find page: opens (evidence: `README.md`)
- Find page → Saved-card loader: renders (evidence: `web/src/app/find/page.tsx`)
- Saved-card loader → Profile form: loads form (evidence: `web/src/app/find/FindLoader.tsx`)
- Listener → Profile form: enters profiles (evidence: `README.md`)
- Profile form → Profile submission: submits (evidence: `README.md`)
- Profile submission → Submission rules: processes
- Submission rules → Postgres + PostGIS: saves profiles
- Listener → Match list: views candidates (evidence: `README.md`)
- Match list → Candidate search: loads candidates
- Candidate search → Match scoring: scores candidates (evidence: `web/src/lib/data.ts`)
- Candidate search → Postgres + PostGIS: queries profiles (evidence: `web/src/lib/data.ts`)
- Match detail → Candidate search: loads match (evidence: `web/src/app/matches/[id]/page.tsx`)
- Match detail → Confirm and delete: confirms match (evidence: `web/src/app/matches/[id]/page.tsx`)
- Confirm and delete → Pair confirmations: records confirmation (evidence: `web/src/app/actions.ts`)
- Confirm and delete → Candidate search: checks perfection (evidence: `web/src/app/actions.ts`)
- Pair confirmations → Postgres + PostGIS: persists pairs
- Listener → Private session link: opens private link (evidence: `README.md`)
- Private session link → Session and data: restores session (evidence: `README.md`)
- Session and data → Postgres + PostGIS: reads session (evidence: `web/src/lib/data.ts`)
- Saved-card loader → Card flag: checks card flag (evidence: `README.md`)
- Listener → City picker: searches cities (evidence: `README.md`)
- City picker → City search keys: normalizes query (evidence: `web/db/city-key.mjs`)
- City picker → City shard export: loads static shards (evidence: `README.md`)
- City shard export → City search keys: keys city names (evidence: `web/db/cities-export.mjs`)
- City data setup → Hand-added cities: parses additions (evidence: `web/db/setup.mjs`)
- City data setup → Postgres + PostGIS: loads city data
- City shard export → Postgres + PostGIS: reads city rows (evidence: `web/db/cities-export.mjs`)
- City picker → Missing-city reports: reports missing city (evidence: `README.md`)
- Report triage → Postgres + PostGIS: reviews reports (evidence: `web/db/city-triage.mjs`)
- Listener → Sharing tools: shares result (evidence: `README.md`)
- Sharing tools → Card text: formats card
- Listener → Confirm and delete: deletes data
- Confirm and delete → Postgres + PostGIS: deletes account (evidence: `web/src/app/actions.ts`)
- Confirm and delete → Campaign analytics: tracks events (evidence: `web/src/app/actions.ts`)
- Landing and totals → Campaign analytics: shows pair totals (evidence: `README.md`)
