# ishaanman7898/sharesecure architecture

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

- Interactive diagram: https://gitdiagram.com/ishaanman7898/sharesecure
- Repository: https://github.com/ishaanman7898/sharesecure

## Overview

ShareSecure is an encrypted file-sharing product with website, self-hosted, desktop, and local-MCP modes. The main workflow is to choose a file and sharing rules, encrypt it in the browser or local client, upload it, and give a recipient a private link; recipients open or download the file before expiry. Other documented capabilities include username sends and requests, branching reshares, account access controls, and assistant integrations. The graph combines documented flows with source-index references; unsampled routes are grouped only where the tree supports their subsystem.

Main entry points: [`functions/_turso.js`](https://github.com/ishaanman7898/sharesecure/blob/main/functions/_turso.js) (Website API), [`server/index.js`](https://github.com/ishaanman7898/sharesecure/blob/main/server/index.js) (Self-host server), [`public/app.js`](https://github.com/ishaanman7898/sharesecure/blob/main/public/app.js) (Sharing interface), [`functions/api/upload.js`](https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/upload.js) (File upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Website sharing"]
  node_webapp["Sharing interface<br/>[app.js]"]
  node_upload["File upload<br/>[upload.js]"]
  node_link["Link delivery<br/>[&#91;shortId&#93;.js]"]
  node_recipient["Recipient viewer<br/>[viewer.js]"]
  node_inbox["Requests inbox<br/>[index.js]"]
  node_account["Accounts and access<br/>[_auth.js]"]
  node_branch["Reshare and deletion<br/>[&#91;shortId&#93;.js]"]
  node_cloudapi["Website API<br/>[_turso.js]"]
  node_cloudstore[("Website database<br/>[_turso.js]")]
end

subgraph group_crypto["Privacy and keys"]
  node_filetypes["File type rules<br/>[filetypes.js]"]
  node_sealed["File encryption<br/>[sealed.js]"]
  node_keys["Key management<br/>[keys.js]"]
  node_tokens["Anonymous tokens<br/>[tokens.js]"]
end

subgraph group_selfhost["Self-hosted service"]
  node_selfserver["Self-host server<br/>[index.js]"]
  node_selfauth["Owner authentication<br/>[auth.js]"]
  node_selfcloud["Username delivery<br/>[cloud.js]"]
  node_selfinbox["Self-host inbox<br/>[inbox.js]"]
  node_selffiles["Local file routes<br/>[files.js]"]
  node_localdb[("Local database<br/>[db.js]")]
  node_purge["Expiry and erasure<br/>[purge.js]"]
  node_desktop["Desktop app<br/>[main.js]"]
end

subgraph group_assistants["Assistant integrations"]
  node_localmcp["Local MCP tools<br/>[tools.js]"]
  node_mcpserver["Local MCP server<br/>[server.js]"]
  node_remoteagent["Hosted MCP tools<br/>[_mcp.js]"]
end

node_sender(("Sender"))
node_assistant(("AI assistant"))

node_sender -->|"selects and configures"| node_webapp
node_webapp -->|"encrypts file"| node_sealed
node_webapp -->|"uploads sealed file"| node_upload
node_upload -->|"stores upload metadata"| node_cloudapi
node_cloudapi -->|"reads and writes"| node_cloudstore
node_upload -->|"checks file type"| node_filetypes
node_webapp -->|"uses keys"| node_keys
node_webapp -->|"uses tokens"| node_tokens
node_link -->|"routes send requests"| node_cloudapi
node_link -->|"delivers to inbox"| node_inbox
node_recipient -->|"decrypts file"| node_sealed
node_recipient -->|"requests shared file"| node_cloudapi
node_account -->|"authorizes account actions"| node_cloudapi
node_branch -.->|"updates share records"| node_cloudapi
node_selfserver -->|"mounts auth routes"| node_selfauth
node_selfserver -->|"mounts file routes"| node_selffiles
node_selfserver -->|"mounts inbox routes"| node_selfinbox
node_selfserver -->|"mounts cloud routes"| node_selfcloud
node_selfauth -->|"reads and writes"| node_localdb
node_selffiles -->|"reads and writes"| node_localdb
node_selfinbox -->|"reads and writes"| node_localdb
node_selffiles -->|"purges shares"| node_purge
node_selfserver -->|"purges expired files"| node_purge
node_selfcloud -->|"calls website API"| node_cloudapi
node_desktop -->|"starts local service"| node_selfserver
node_assistant -->|"connects locally"| node_mcpserver
node_mcpserver -->|"dispatches tools"| node_localmcp
node_localmcp -->|"encrypts local files"| node_sealed
node_localmcp -->|"uploads and sends"| node_cloudapi
node_assistant -->|"calls hosted MCP"| node_remoteagent
node_remoteagent -->|"uses website API"| node_cloudapi
node_remoteagent -->|"lists inbox"| node_inbox

click node_webapp "https://github.com/ishaanman7898/sharesecure/blob/main/public/app.js"
click node_upload "https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/upload.js"
click node_link "https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/send/%5BshortId%5D.js"
click node_recipient "https://github.com/ishaanman7898/sharesecure/blob/main/public/viewer.js"
click node_inbox "https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/inbox/index.js"
click node_account "https://github.com/ishaanman7898/sharesecure/blob/main/functions/_auth.js"
click node_branch "https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/reshare/%5BshortId%5D.js"
click node_filetypes "https://github.com/ishaanman7898/sharesecure/blob/main/public/filetypes.js"
click node_sealed "https://github.com/ishaanman7898/sharesecure/blob/main/public/sealed.js"
click node_keys "https://github.com/ishaanman7898/sharesecure/blob/main/public/keys.js"
click node_tokens "https://github.com/ishaanman7898/sharesecure/blob/main/public/tokens.js"
click node_cloudapi "https://github.com/ishaanman7898/sharesecure/blob/main/functions/_turso.js"
click node_cloudstore "https://github.com/ishaanman7898/sharesecure/blob/main/functions/_turso.js"
click node_selfserver "https://github.com/ishaanman7898/sharesecure/blob/main/server/index.js"
click node_selfauth "https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/auth.js"
click node_selfcloud "https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/cloud.js"
click node_selfinbox "https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/inbox.js"
click node_selffiles "https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/files.js"
click node_localdb "https://github.com/ishaanman7898/sharesecure/blob/main/server/db.js"
click node_purge "https://github.com/ishaanman7898/sharesecure/blob/main/server/purge.js"
click node_localmcp "https://github.com/ishaanman7898/sharesecure/blob/main/packages/sharesecure-mcp/src/tools.js"
click node_mcpserver "https://github.com/ishaanman7898/sharesecure/blob/main/packages/sharesecure-mcp/src/server.js"
click node_remoteagent "https://github.com/ishaanman7898/sharesecure/blob/main/functions/_mcp.js"
click node_desktop "https://github.com/ishaanman7898/sharesecure/blob/main/desktop/main.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_webapp,node_upload,node_link,node_recipient,node_inbox,node_account,node_branch,node_cloudapi,node_cloudstore toneBlue
class node_filetypes,node_sealed,node_keys,node_tokens toneAmber
class node_selfserver,node_selfauth,node_selfcloud,node_selfinbox,node_selffiles,node_localdb,node_purge,node_desktop toneMint
class node_localmcp,node_mcpserver,node_remoteagent toneRose
class node_sender,node_assistant toneIndigo
```

## Components

### Website sharing

- [Sharing interface](https://github.com/ishaanman7898/sharesecure/blob/main/public/app.js): `public/app.js`
- [File upload](https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/upload.js): `functions/api/upload.js`
- [Link delivery](https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/send/%5BshortId%5D.js): `functions/api/send/[shortId].js`
- [Recipient viewer](https://github.com/ishaanman7898/sharesecure/blob/main/public/viewer.js): `public/viewer.js`
- [Requests inbox](https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/inbox/index.js): `functions/api/inbox/index.js`
- [Accounts and access](https://github.com/ishaanman7898/sharesecure/blob/main/functions/_auth.js): `functions/_auth.js`
- [Reshare and deletion](https://github.com/ishaanman7898/sharesecure/blob/main/functions/api/reshare/%5BshortId%5D.js): `functions/api/reshare/[shortId].js`
- [Website API](https://github.com/ishaanman7898/sharesecure/blob/main/functions/_turso.js): `functions/_turso.js`
- [Website database](https://github.com/ishaanman7898/sharesecure/blob/main/functions/_turso.js): `functions/_turso.js`

### Privacy and keys

- [File type rules](https://github.com/ishaanman7898/sharesecure/blob/main/public/filetypes.js): `public/filetypes.js`
- [File encryption](https://github.com/ishaanman7898/sharesecure/blob/main/public/sealed.js): `public/sealed.js`
- [Key management](https://github.com/ishaanman7898/sharesecure/blob/main/public/keys.js): `public/keys.js`
- [Anonymous tokens](https://github.com/ishaanman7898/sharesecure/blob/main/public/tokens.js): `public/tokens.js`

### Self-hosted service

- [Self-host server](https://github.com/ishaanman7898/sharesecure/blob/main/server/index.js): `server/index.js`
- [Owner authentication](https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Username delivery](https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/cloud.js): `server/routes/cloud.js`
- [Self-host inbox](https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/inbox.js): `server/routes/inbox.js`
- [Local file routes](https://github.com/ishaanman7898/sharesecure/blob/main/server/routes/files.js): `server/routes/files.js`
- [Local database](https://github.com/ishaanman7898/sharesecure/blob/main/server/db.js): `server/db.js`
- [Expiry and erasure](https://github.com/ishaanman7898/sharesecure/blob/main/server/purge.js): `server/purge.js`
- [Desktop app](https://github.com/ishaanman7898/sharesecure/blob/main/desktop/main.js): `desktop/main.js`

### Assistant integrations

- [Local MCP tools](https://github.com/ishaanman7898/sharesecure/blob/main/packages/sharesecure-mcp/src/tools.js): `packages/sharesecure-mcp/src/tools.js`
- [Local MCP server](https://github.com/ishaanman7898/sharesecure/blob/main/packages/sharesecure-mcp/src/server.js): `packages/sharesecure-mcp/src/server.js`
- [Hosted MCP tools](https://github.com/ishaanman7898/sharesecure/blob/main/functions/_mcp.js): `functions/_mcp.js`

### Other components

- **Sender**
- **AI assistant**

## Connections

- Sender → Sharing interface: selects and configures
- Sharing interface → File encryption: encrypts file (evidence: `public/app.js`)
- Sharing interface → File upload: uploads sealed file
- File upload → Website API: stores upload metadata (evidence: `functions/api/upload.js`)
- Website API → Website database: reads and writes (evidence: `functions/_turso.js`)
- File upload → File type rules: checks file type (evidence: `functions/api/upload.js`)
- Sharing interface → Key management: uses keys (evidence: `public/app.js`)
- Sharing interface → Anonymous tokens: uses tokens (evidence: `public/app.js`)
- Link delivery → Website API: routes send requests (evidence: `functions/api/send/[shortId].js`)
- Link delivery → Requests inbox: delivers to inbox
- Recipient viewer → File encryption: decrypts file (evidence: `public/viewer.js`)
- Recipient viewer → Website API: requests shared file
- Accounts and access → Website API: authorizes account actions (evidence: `functions/_auth.js`)
- Reshare and deletion → Website API: updates share records
- Self-host server → Owner authentication: mounts auth routes (evidence: `server/index.js`)
- Self-host server → Local file routes: mounts file routes (evidence: `server/index.js`)
- Self-host server → Self-host inbox: mounts inbox routes (evidence: `server/index.js`)
- Self-host server → Username delivery: mounts cloud routes (evidence: `server/index.js`)
- Owner authentication → Local database: reads and writes (evidence: `server/routes/auth.js`)
- Local file routes → Local database: reads and writes (evidence: `server/routes/files.js`)
- Self-host inbox → Local database: reads and writes (evidence: `server/routes/inbox.js`)
- Local file routes → Expiry and erasure: purges shares (evidence: `server/routes/files.js`)
- Self-host server → Expiry and erasure: purges expired files (evidence: `server/index.js`)
- Username delivery → Website API: calls website API (evidence: `server/routes/cloud.js`)
- Desktop app → Self-host server: starts local service (evidence: `desktop/main.js`)
- AI assistant → Local MCP server: connects locally
- Local MCP server → Local MCP tools: dispatches tools (evidence: `packages/sharesecure-mcp/src/server.js`)
- Local MCP tools → File encryption: encrypts local files
- Local MCP tools → Website API: uploads and sends
- AI assistant → Hosted MCP tools: calls hosted MCP
- Hosted MCP tools → Website API: uses website API (evidence: `functions/_mcp.js`)
- Hosted MCP tools → Requests inbox: lists inbox (evidence: `functions/_mcp.js`)
