# goen237/secure-file-sharing architecture

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

- Interactive diagram: https://gitdiagram.com/goen237/secure-file-sharing
- Repository: https://github.com/goen237/secure-file-sharing

## Overview

Secure File Sharing is a browser-based file-sharing application backed by FastAPI and MongoDB. Users register or log in, then upload files for envelope encryption and can list, preview, download, or delete their own files; administrators can manage users, roles, and files. The API routes these operations and delegates authentication, encryption, and persistence to backend modules. The README documents the frontend/API relationship and major capabilities; source excerpts show the specific calls and browser requests represented below.

Main entry points: [`backend/main.py`](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py) (FastAPI routes), [`frontend/index.html`](https://github.com/goen237/secure-file-sharing/blob/main/frontend/index.html) (User pages), [`frontend/script.js`](https://github.com/goen237/secure-file-sharing/blob/main/frontend/script.js) (User actions), [`frontend/admin.html`](https://github.com/goen237/secure-file-sharing/blob/main/frontend/admin.html) (Admin dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_user_ui["User pages<br/>[index.html]"]
  node_user_actions["User actions<br/>[script.js]"]
  node_admin_ui["Admin dashboard<br/>[admin.html]"]
  node_admin_actions["Admin actions<br/>[admin.js]"]
end

subgraph group_accounts["Accounts and access"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_account_ops["Registration and login<br/>[main.py]"]
  node_token_access["Token and role checks<br/>[main.py]"]
  node_user_admin["User administration<br/>[main.py]"]
  node_password_change["Password change<br/>[main.py]"]
end

subgraph group_files["File workflows"]
  node_upload["Upload and encrypt<br/>[main.py]"]
  node_file_access["List, preview, download<br/>[main.py]"]
  node_file_delete["File deletion<br/>[main.py]"]
end

subgraph group_storage["Security and storage"]
  node_auth["Password and JWT<br/>[auth.py]"]
  node_encryption["Envelope encryption<br/>[encryption.py]"]
  node_db["MongoDB operations<br/>[db.py]"]
end

node_browser(("User or admin"))
node_mongo[("MongoDB")]

node_browser -->|"uses"| node_user_ui
node_browser -->|"uses"| node_admin_ui
node_user_ui -.->|"loads"| node_user_actions
node_admin_ui -.->|"loads"| node_admin_actions
node_user_actions -->|"sends REST requests"| node_api
node_admin_actions -->|"sends REST requests"| node_api
node_api -->|"routes"| node_account_ops
node_api -->|"routes"| node_token_access
node_api -->|"routes"| node_user_admin
node_api -->|"routes"| node_upload
node_api -->|"routes"| node_file_access
node_api -->|"routes"| node_file_delete
node_api -->|"routes"| node_password_change
node_api -->|"calls"| node_auth
node_api -->|"encrypts and decrypts"| node_encryption
node_api -->|"calls"| node_db
node_db -->|"reads and writes"| node_mongo

click node_user_ui "https://github.com/goen237/secure-file-sharing/blob/main/frontend/index.html"
click node_user_actions "https://github.com/goen237/secure-file-sharing/blob/main/frontend/script.js"
click node_admin_ui "https://github.com/goen237/secure-file-sharing/blob/main/frontend/admin.html"
click node_admin_actions "https://github.com/goen237/secure-file-sharing/blob/main/frontend/admin.js"
click node_api "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_account_ops "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_token_access "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_user_admin "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_upload "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_file_access "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_file_delete "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_password_change "https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py"
click node_auth "https://github.com/goen237/secure-file-sharing/blob/main/backend/auth.py"
click node_encryption "https://github.com/goen237/secure-file-sharing/blob/main/backend/encryption.py"
click node_db "https://github.com/goen237/secure-file-sharing/blob/main/backend/db.py"

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_user_ui,node_user_actions,node_admin_ui,node_admin_actions,node_browser toneBlue
class node_api,node_account_ops,node_token_access,node_user_admin,node_password_change,node_mongo toneAmber
class node_upload,node_file_access,node_file_delete toneMint
class node_auth,node_encryption,node_db toneRose
```

## Components

### Browser client

- [User pages](https://github.com/goen237/secure-file-sharing/blob/main/frontend/index.html): `frontend/index.html`
- [User actions](https://github.com/goen237/secure-file-sharing/blob/main/frontend/script.js): `frontend/script.js`
- [Admin dashboard](https://github.com/goen237/secure-file-sharing/blob/main/frontend/admin.html): `frontend/admin.html`
- [Admin actions](https://github.com/goen237/secure-file-sharing/blob/main/frontend/admin.js): `frontend/admin.js`

### Accounts and access

- [FastAPI routes](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [Registration and login](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [Token and role checks](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [User administration](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [Password change](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`

### File workflows

- [Upload and encrypt](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [List, preview, download](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`
- [File deletion](https://github.com/goen237/secure-file-sharing/blob/main/backend/main.py): `backend/main.py`

### Security and storage

- [Password and JWT](https://github.com/goen237/secure-file-sharing/blob/main/backend/auth.py): `backend/auth.py`
- [Envelope encryption](https://github.com/goen237/secure-file-sharing/blob/main/backend/encryption.py): `backend/encryption.py`
- [MongoDB operations](https://github.com/goen237/secure-file-sharing/blob/main/backend/db.py): `backend/db.py`

### Other components

- **User or admin**
- **MongoDB**

## Connections

- User or admin → User pages: uses (evidence: `README.md`)
- User or admin → Admin dashboard: uses (evidence: `README.md`)
- User pages → User actions: loads
- Admin dashboard → Admin actions: loads
- User actions → FastAPI routes: sends REST requests (evidence: `frontend/script.js`)
- Admin actions → FastAPI routes: sends REST requests (evidence: `frontend/admin.js`)
- FastAPI routes → Registration and login: routes (evidence: `backend/main.py`)
- FastAPI routes → Token and role checks: routes (evidence: `backend/main.py`)
- FastAPI routes → User administration: routes (evidence: `backend/main.py`)
- FastAPI routes → Upload and encrypt: routes (evidence: `backend/main.py`)
- FastAPI routes → List, preview, download: routes (evidence: `backend/main.py`)
- FastAPI routes → File deletion: routes (evidence: `backend/main.py`)
- FastAPI routes → Password change: routes (evidence: `backend/main.py`)
- FastAPI routes → Password and JWT: calls (evidence: `backend/main.py`)
- FastAPI routes → Envelope encryption: encrypts and decrypts (evidence: `backend/main.py`)
- FastAPI routes → MongoDB operations: calls (evidence: `backend/main.py`)
- MongoDB operations → MongoDB: reads and writes (evidence: `backend/db.py`)
