# nanda2708/trie-connect architecture

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

- Interactive diagram: https://gitdiagram.com/nanda2708/trie-connect
- Repository: https://github.com/nanda2708/trie-connect

## Overview

TrieConnect is a contact search app: users search by name-word or phone prefix, inspect the matching trie path and results, and can create, edit, or delete contacts. The API validates and coordinates contact records in MongoDB or memory with a separate C++ trie process; it also exposes trie stats and a trie-versus-linear benchmark. The React UI consumes those API capabilities. Relationships are grounded in the README or shown source excerpts; the store implementation and some UI components are not sampled, so their internal behavior is not expanded.

Main entry points: [`frontend/src/App.tsx`](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/App.tsx) (Search and manage), [`frontend/src/api.ts`](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/api.ts) (API client), [`server/src/index.js`](https://github.com/nanda2708/trie-connect/blob/main/server/src/index.js) (HTTP routes), [`server/src/store.js`](https://github.com/nanda2708/trie-connect/blob/main/server/src/store.js) (Contact storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["React interface"]
  node_app["Search and manage<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_form["Contact form<br/>[ContactForm.tsx]"]
  node_list["Contact list<br/>[ContactList.tsx]"]
  node_path_view["Trie path view<br/>[TriePath.tsx]"]
  node_benchmark_panel["Benchmark panel<br/>[BenchmarkPanel.tsx]"]
end

subgraph group_api["Express API"]
  node_http_api["HTTP routes<br/>[index.js]"]
end

subgraph group_index["Search index"]
  node_search_index["Key mapping and search<br/>[searchIndex.js]"]
  node_bridge["Engine process bridge<br/>[engine.js]"]
end

subgraph group_engine["C++ engine"]
  node_trie["Prefix trie<br/>[Trie.cpp]"]
  node_engine_commands["Command and benchmark handling<br/>[main.cpp]"]
end

subgraph group_records["Contact records"]
  node_record_store[("Contact storage<br/>[store.js]")]
end

node_user(("Contact user"))
node_mongodb[("MongoDB")]
node_memory[("In-memory records")]

node_user -->|"searches and edits"| node_app
node_app -->|"requests data"| node_api_client
node_app -->|"renders"| node_form
node_app -->|"renders"| node_list
node_app -->|"renders"| node_path_view
node_app -->|"renders"| node_benchmark_panel
node_form -->|"saves via callback"| node_api_client
node_api_client -->|"HTTP requests"| node_http_api
node_http_api -->|"searches and updates"| node_search_index
node_http_api -->|"reads and writes"| node_record_store
node_http_api -->|"requests stats and benchmark"| node_bridge
node_search_index -->|"sends trie commands"| node_bridge
node_bridge -->|"stdin and stdout"| node_engine_commands
node_engine_commands -->|"executes trie operations"| node_trie
node_record_store -.->|"optional persistence"| node_mongodb
node_record_store -.->|"fallback storage"| node_memory
node_benchmark_panel -->|"requests benchmark"| node_api_client
node_app -->|"loads walk and stats"| node_api_client
node_path_view -->|"displays walk data"| node_app

click node_app "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/api.ts"
click node_form "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/ContactForm.tsx"
click node_list "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/ContactList.tsx"
click node_path_view "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/TriePath.tsx"
click node_benchmark_panel "https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/BenchmarkPanel.tsx"
click node_http_api "https://github.com/nanda2708/trie-connect/blob/main/server/src/index.js"
click node_search_index "https://github.com/nanda2708/trie-connect/blob/main/server/src/searchIndex.js"
click node_bridge "https://github.com/nanda2708/trie-connect/blob/main/server/src/engine.js"
click node_trie "https://github.com/nanda2708/trie-connect/blob/main/cpp/Trie.cpp"
click node_engine_commands "https://github.com/nanda2708/trie-connect/blob/main/cpp/main.cpp"
click node_record_store "https://github.com/nanda2708/trie-connect/blob/main/server/src/store.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_app,node_api_client,node_form,node_list,node_path_view,node_benchmark_panel,node_user toneBlue
class node_http_api,node_mongodb,node_memory toneAmber
class node_search_index,node_bridge toneMint
class node_trie,node_engine_commands toneRose
class node_record_store toneIndigo
```

## Components

### React interface

- [Search and manage](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Contact form](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/ContactForm.tsx): `frontend/src/components/ContactForm.tsx`
- [Contact list](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/ContactList.tsx): `frontend/src/components/ContactList.tsx`
- [Trie path view](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/TriePath.tsx): `frontend/src/components/TriePath.tsx`
- [Benchmark panel](https://github.com/nanda2708/trie-connect/blob/main/frontend/src/components/BenchmarkPanel.tsx): `frontend/src/components/BenchmarkPanel.tsx`

### Express API

- [HTTP routes](https://github.com/nanda2708/trie-connect/blob/main/server/src/index.js): `server/src/index.js`

### Search index

- [Key mapping and search](https://github.com/nanda2708/trie-connect/blob/main/server/src/searchIndex.js): `server/src/searchIndex.js`
- [Engine process bridge](https://github.com/nanda2708/trie-connect/blob/main/server/src/engine.js): `server/src/engine.js`

### C++ engine

- [Prefix trie](https://github.com/nanda2708/trie-connect/blob/main/cpp/Trie.cpp): `cpp/Trie.cpp`
- [Command and benchmark handling](https://github.com/nanda2708/trie-connect/blob/main/cpp/main.cpp): `cpp/main.cpp`

### Contact records

- [Contact storage](https://github.com/nanda2708/trie-connect/blob/main/server/src/store.js): `server/src/store.js`

### Other components

- **Contact user**
- **MongoDB**
- **In-memory records**

## Connections

- Contact user → Search and manage: searches and edits (evidence: `README.md`)
- Search and manage → API client: requests data (evidence: `frontend/src/App.tsx`)
- Search and manage → Contact form: renders (evidence: `frontend/src/App.tsx`)
- Search and manage → Contact list: renders (evidence: `frontend/src/App.tsx`)
- Search and manage → Trie path view: renders (evidence: `frontend/src/App.tsx`)
- Search and manage → Benchmark panel: renders (evidence: `frontend/src/App.tsx`)
- Contact form → API client: saves via callback (evidence: `frontend/src/App.tsx`)
- API client → HTTP routes: HTTP requests (evidence: `README.md`)
- HTTP routes → Key mapping and search: searches and updates (evidence: `server/src/index.js`)
- HTTP routes → Contact storage: reads and writes (evidence: `server/src/index.js`)
- HTTP routes → Engine process bridge: requests stats and benchmark (evidence: `server/src/index.js`)
- Key mapping and search → Engine process bridge: sends trie commands (evidence: `server/src/searchIndex.js`)
- Engine process bridge → Command and benchmark handling: stdin and stdout (evidence: `server/src/engine.js`)
- Command and benchmark handling → Prefix trie: executes trie operations (evidence: `cpp/main.cpp`)
- Contact storage → MongoDB: optional persistence (evidence: `README.md`)
- Contact storage → In-memory records: fallback storage (evidence: `README.md`)
- Benchmark panel → API client: requests benchmark (evidence: `frontend/src/components/BenchmarkPanel.tsx`)
- Search and manage → API client: loads walk and stats (evidence: `frontend/src/App.tsx`)
- Trie path view → Search and manage: displays walk data (evidence: `frontend/src/App.tsx`)
