# rumjerr/fileserver architecture

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

- Interactive diagram: https://gitdiagram.com/rumjerr/fileserver
- Repository: https://github.com/rumjerr/fileserver

## Overview

fileserver is a browser-based remote file manager. A user works through the browser UI; HTTP handlers in the server validate paths and dispatch file operations, previews, trash actions, and storage reporting. The implementation layer in mainfunctions.cpp performs filesystem work, HEIC conversion, trash retention, and storage calculations. The README documents the product capabilities, but the frontend’s API wiring is not shown in the excerpts; that connection is marked unverified. The server’s mounted directory is ./www, which is not present in the supplied tree.

Main entry points: [`main.cpp`](https://github.com/rumjerr/fileserver/blob/main/main.cpp) (API routes), [`mainfunctions.cpp`](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp) (Trash and restore), [`index.html`](https://github.com/rumjerr/fileserver/blob/main/index.html) (File manager UI), [`httplib.h`](https://github.com/rumjerr/fileserver/blob/main/httplib.h) (HTTP server library)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser interface"]
  node_ui["File manager UI<br/>[index.html]"]
end

subgraph group_server["HTTP server"]
  node_routes["API routes<br/>[main.cpp]"]
  node_http["HTTP server library<br/>[httplib.h]"]
  node_json["JSON support<br/>[json.hpp]"]
end

subgraph group_files["File operations"]
  node_paths["Safe path handling<br/>[mainfunctions.cpp]"]
  node_directory["Directory listing<br/>[mainfunctions.cpp]"]
  node_fileops["Upload and download<br/>[mainfunctions.cpp]"]
  node_organization["Rename and move<br/>[mainfunctions.cpp]"]
  node_preview["HEIC preview conversion<br/>[mainfunctions.cpp]"]
  node_imagewriter["Image output helper<br/>[stb_image_write.h]"]
end

subgraph group_extras["Trash and insights"]
  node_trash["Trash and restore<br/>[mainfunctions.cpp]"]
  node_storage["Storage reporting<br/>[mainfunctions.cpp]"]
end

node_user(("Remote user"))
node_filesystem[("Server filesystem")]

node_user -->|"uses"| node_ui
node_ui -.->|"requests API"| node_routes
node_routes -->|"registers routes"| node_http
node_routes -->|"serializes results"| node_json
node_routes -->|"validates paths"| node_paths
node_routes -->|"lists entries"| node_directory
node_routes -->|"reads and writes"| node_fileops
node_routes -->|"renames and moves"| node_organization
node_routes -->|"converts previews"| node_preview
node_routes -->|"dispatches trash actions"| node_trash
node_routes -->|"requests usage stats"| node_storage
node_routes -->|"schedules expiry cleanup"| node_trash
node_paths -.->|"resolves paths"| node_filesystem
node_directory -.->|"reads entries"| node_filesystem
node_fileops -.->|"reads and writes"| node_filesystem
node_organization -.->|"moves and renames"| node_filesystem
node_trash -.->|"stores and restores"| node_filesystem
node_storage -.->|"measures usage"| node_filesystem
node_preview -.->|"encodes JPEG"| node_imagewriter

click node_ui "https://github.com/rumjerr/fileserver/blob/main/index.html"
click node_routes "https://github.com/rumjerr/fileserver/blob/main/main.cpp"
click node_http "https://github.com/rumjerr/fileserver/blob/main/httplib.h"
click node_json "https://github.com/rumjerr/fileserver/blob/main/json.hpp"
click node_paths "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_directory "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_fileops "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_organization "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_preview "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_imagewriter "https://github.com/rumjerr/fileserver/blob/main/stb_image_write.h"
click node_trash "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"
click node_storage "https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp"

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_ui,node_user toneBlue
class node_routes,node_http,node_json,node_filesystem toneAmber
class node_paths,node_directory,node_fileops,node_organization,node_preview,node_imagewriter toneMint
class node_trash,node_storage toneRose
```

## Components

### Browser interface

- [File manager UI](https://github.com/rumjerr/fileserver/blob/main/index.html): `index.html`

### HTTP server

- [API routes](https://github.com/rumjerr/fileserver/blob/main/main.cpp): `main.cpp`
- [HTTP server library](https://github.com/rumjerr/fileserver/blob/main/httplib.h): `httplib.h`
- [JSON support](https://github.com/rumjerr/fileserver/blob/main/json.hpp): `json.hpp`

### File operations

- [Safe path handling](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [Directory listing](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [Upload and download](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [Rename and move](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [HEIC preview conversion](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [Image output helper](https://github.com/rumjerr/fileserver/blob/main/stb_image_write.h): `stb_image_write.h`

### Trash and insights

- [Trash and restore](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`
- [Storage reporting](https://github.com/rumjerr/fileserver/blob/main/mainfunctions.cpp): `mainfunctions.cpp`

### Other components

- **Remote user**
- **Server filesystem**

## Connections

- Remote user → File manager UI: uses (evidence: `README.md`)
- File manager UI → API routes: requests API
- API routes → HTTP server library: registers routes (evidence: `main.cpp`)
- API routes → JSON support: serializes results (evidence: `main.cpp`)
- API routes → Safe path handling: validates paths (evidence: `main.cpp`)
- API routes → Directory listing: lists entries (evidence: `main.cpp`)
- API routes → Upload and download: reads and writes (evidence: `main.cpp`)
- API routes → Rename and move: renames and moves (evidence: `main.cpp`)
- API routes → HEIC preview conversion: converts previews (evidence: `main.cpp`)
- API routes → Trash and restore: dispatches trash actions (evidence: `main.cpp`)
- API routes → Storage reporting: requests usage stats (evidence: `main.cpp`)
- API routes → Trash and restore: schedules expiry cleanup (evidence: `main.cpp`)
- Safe path handling → Server filesystem: resolves paths
- Directory listing → Server filesystem: reads entries
- Upload and download → Server filesystem: reads and writes
- Rename and move → Server filesystem: moves and renames
- Trash and restore → Server filesystem: stores and restores
- Storage reporting → Server filesystem: measures usage
- HEIC preview conversion → Image output helper: encodes JPEG (evidence: `mainfunctions.cpp`)
