# tanay2005-pixel/synapse architecture

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

- Interactive diagram: https://gitdiagram.com/tanay2005-pixel/synapse
- Repository: https://github.com/tanay2005-pixel/synapse

## Overview

Synapse is a LAN-oriented, multi-user file-management platform. Users authenticate, browse and share files, then upload or download files through the workspace API; the Python backend delegates chunk storage to a C++ engine and records metadata through a selectable JSON or PostgreSQL store. A separate editing workflow acquires an exclusive lock, serves a working copy, and saves edits as a new file version. The README also describes semantic search as planned. Edges reflect shown imports/calls or README statements; unsampled route details and search integration are not inferred.

Main entry points: [`src/py/workspace.py`](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/workspace.py) (Workspace API), [`src/py/store.py`](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/store.py) (Storage selector), [`src/py/user_login.py`](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/user_login.py) (Login and session), [`src/py/editing.py`](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/editing.py) (Editing sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_auth["Login and session<br/>[user_login.py]"]
  node_registration["Registration<br/>[registration.py]"]
end

subgraph group_files["Workspace and files"]
  node_workspace["Workspace API<br/>[workspace.py]"]
  node_editing["Editing sessions<br/>[editing.py]"]
  node_office["Office templates"]
end

subgraph group_runtime["Storage and concurrency"]
  node_store_selector["Storage selector<br/>[store.py]"]
  node_json_store[("JSON metadata store<br/>[json_store.py]")]
  node_postgres_store[("PostgreSQL store<br/>[postgres_store.py]")]
  node_schema["Metadata schema<br/>[schema.sql]"]
  node_chunk_bridge["Chunk engine bridge<br/>[chunk_engine.py]"]
  node_cpp_engine["Chunk CLI<br/>[main.cpp]"]
  node_file_engine["Chunk processing<br/>[chunker.cpp]"]
  node_cas[("Content-addressed storage<br/>[cas.cpp]")]
  node_sha["SHA-256 hashing<br/>[sha256.cpp]"]
  node_lock_client["Lock client<br/>[lock_client.py]"]
  node_lock_cli["Lock CLI<br/>[lock_main.cpp]"]
  node_lock_manager["Lock manager<br/>[lock_manager.cpp]"]
end

subgraph group_search["Semantic search"]
  node_file_reader["Document extraction<br/>[reading_files.py]"]
  node_cleaning["Text cleaning and chunking"]
  node_embeddings["Embedding generation<br/>[embeddings.py]"]
  node_vector_search[("Vector similarity search")]
end

node_user(("LAN user"))

node_user -->|"signs in"| node_auth
node_user -->|"manages files"| node_workspace
node_auth -->|"uses"| node_registration
node_auth -->|"routes to"| node_workspace
node_auth -->|"routes to"| node_editing
node_registration -->|"uses"| node_store_selector
node_workspace -->|"uses"| node_store_selector
node_workspace -->|"chunks files"| node_chunk_bridge
node_editing -->|"requests locks"| node_lock_client
node_editing -->|"records sessions"| node_store_selector
node_editing -->|"handles file content"| node_chunk_bridge
node_workspace -->|"uses templates"| node_office
node_store_selector -->|"selects backend"| node_json_store
node_store_selector -->|"selects backend"| node_postgres_store
node_postgres_store -.->|"implements schema"| node_schema
node_chunk_bridge -->|"runs CLI"| node_cpp_engine
node_cpp_engine -->|"splits and merges"| node_file_engine
node_file_engine -->|"stores chunks"| node_cas
node_file_engine -->|"hashes chunks"| node_sha
node_lock_client -->|"runs CLI"| node_lock_cli
node_lock_cli -->|"dispatches commands"| node_lock_manager
node_file_reader -->|"loads documents"| node_cleaning
node_cleaning -->|"supplies text chunks"| node_embeddings
node_file_reader -->|"loads source text"| node_embeddings
node_embeddings -.->|"feeds planned search"| node_vector_search

click node_auth "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/user_login.py"
click node_registration "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/registration.py"
click node_workspace "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/workspace.py"
click node_editing "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/editing.py"
click node_office "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/office_templates.py"
click node_store_selector "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/store.py"
click node_json_store "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/json_store.py"
click node_postgres_store "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/postgres_store.py"
click node_schema "https://github.com/tanay2005-pixel/synapse/blob/main/database/schema.sql"
click node_chunk_bridge "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/chunk_engine.py"
click node_cpp_engine "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/main.cpp"
click node_file_engine "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/chunker.cpp"
click node_cas "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/cas.cpp"
click node_sha "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/sha256.cpp"
click node_lock_client "https://github.com/tanay2005-pixel/synapse/blob/main/src/py/lock_client.py"
click node_lock_cli "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/lock_main.cpp"
click node_lock_manager "https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/lock_manager.cpp"
click node_file_reader "https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/reading_files.py"
click node_cleaning "https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/cleaning_chunking.py"
click node_embeddings "https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/embeddings.py"
click node_vector_search "https://github.com/tanay2005-pixel/synapse/tree/main/embeddings"

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_auth,node_registration,node_user toneBlue
class node_workspace,node_editing,node_office toneAmber
class node_store_selector,node_json_store,node_postgres_store,node_schema,node_chunk_bridge,node_cpp_engine,node_file_engine,node_cas,node_sha,node_lock_client,node_lock_cli,node_lock_manager toneMint
class node_file_reader,node_cleaning,node_embeddings,node_vector_search toneRose
```

## Components

### Identity and access

- [Login and session](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/user_login.py): `src/py/user_login.py`
- [Registration](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/registration.py): `src/py/registration.py`

### Workspace and files

- [Workspace API](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/workspace.py): `src/py/workspace.py`
- [Editing sessions](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/editing.py): `src/py/editing.py`
- [Office templates](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/office_templates.py): `src/py/office_templates.py`

### Storage and concurrency

- [Storage selector](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/store.py): `src/py/store.py`
- [JSON metadata store](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/json_store.py): `src/py/json_store.py`
- [PostgreSQL store](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/postgres_store.py): `src/py/postgres_store.py`
- [Metadata schema](https://github.com/tanay2005-pixel/synapse/blob/main/database/schema.sql): `database/schema.sql`
- [Chunk engine bridge](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/chunk_engine.py): `src/py/chunk_engine.py`
- [Chunk CLI](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/main.cpp): `src/cpp/src/main.cpp`
- [Chunk processing](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/chunker.cpp): `src/cpp/src/chunker.cpp`
- [Content-addressed storage](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/cas.cpp): `src/cpp/src/cas.cpp`
- [SHA-256 hashing](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/sha256.cpp): `src/cpp/src/sha256.cpp`
- [Lock client](https://github.com/tanay2005-pixel/synapse/blob/main/src/py/lock_client.py): `src/py/lock_client.py`
- [Lock CLI](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/lock_main.cpp): `src/cpp/src/lock_main.cpp`
- [Lock manager](https://github.com/tanay2005-pixel/synapse/blob/main/src/cpp/src/lock_manager.cpp): `src/cpp/src/lock_manager.cpp`

### Semantic search

- [Document extraction](https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/reading_files.py): `embeddings/reading_files.py`
- [Text cleaning and chunking](https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/cleaning_chunking.py): `embeddings/cleaning_chunking.py`
- [Embedding generation](https://github.com/tanay2005-pixel/synapse/blob/main/embeddings/embeddings.py): `embeddings/embeddings.py`
- [Vector similarity search](https://github.com/tanay2005-pixel/synapse/tree/main/embeddings): `embeddings`

### Other components

- **LAN user**

## Connections

- LAN user → Login and session: signs in (evidence: `README.md`)
- LAN user → Workspace API: manages files (evidence: `README.md`)
- Login and session → Registration: uses (evidence: `src/py/user_login.py`)
- Login and session → Workspace API: routes to (evidence: `src/py/user_login.py`)
- Login and session → Editing sessions: routes to (evidence: `src/py/user_login.py`)
- Registration → Storage selector: uses (evidence: `src/py/registration.py`)
- Workspace API → Storage selector: uses (evidence: `src/py/workspace.py`)
- Workspace API → Chunk engine bridge: chunks files (evidence: `README.md`)
- Editing sessions → Lock client: requests locks (evidence: `src/py/editing.py`)
- Editing sessions → Storage selector: records sessions (evidence: `src/py/editing.py`)
- Editing sessions → Chunk engine bridge: handles file content (evidence: `src/py/editing.py`)
- Workspace API → Office templates: uses templates (evidence: `src/py/workspace.py`)
- Storage selector → JSON metadata store: selects backend (evidence: `src/py/store.py`)
- Storage selector → PostgreSQL store: selects backend (evidence: `src/py/store.py`)
- PostgreSQL store → Metadata schema: implements schema (evidence: `README.md`)
- Chunk engine bridge → Chunk CLI: runs CLI (evidence: `README.md`)
- Chunk CLI → Chunk processing: splits and merges (evidence: `src/cpp/src/main.cpp`)
- Chunk processing → Content-addressed storage: stores chunks (evidence: `src/cpp/src/chunker.cpp`)
- Chunk processing → SHA-256 hashing: hashes chunks (evidence: `src/cpp/src/chunker.cpp`)
- Lock client → Lock CLI: runs CLI (evidence: `README.md`)
- Lock CLI → Lock manager: dispatches commands (evidence: `src/cpp/src/lock_main.cpp`)
- Document extraction → Text cleaning and chunking: loads documents (evidence: `embeddings/cleaning_chunking.py`)
- Text cleaning and chunking → Embedding generation: supplies text chunks (evidence: `embeddings/embeddings.py`)
- Document extraction → Embedding generation: loads source text (evidence: `embeddings/embeddings.py`)
- Embedding generation → Vector similarity search: feeds planned search (evidence: `README.md`)
