# siddharthmnn/rewindfs architecture

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

- Interactive diagram: https://gitdiagram.com/siddharthmnn/rewindfs
- Repository: https://github.com/siddharthmnn/rewindfs

## Overview

rewindfs monitors files and captures timestamped snapshots, then exposes snapshot history, lookup, comparison, statistics, restore, and deleted-file recovery through a REST server. SQLite persists snapshot metadata and content; hashing supports deduplication. The README describes a dashboard and its statistics/file-listing views, though its JavaScript behavior was not sampled. The watcher-to-snapshot call and several server/storage calls are visible in source; other feature links reflect README documentation.

Main entry points: [`internal/api/server.go`](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/server.go) (HTTP server), [`internal/api/snapshots.go`](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/snapshots.go) (Snapshot creation), [`internal/models/snapshot.go`](https://github.com/siddharthmnn/rewindfs/blob/main/internal/models/snapshot.go) (Snapshot model), [`internal/storage/sqlite.go`](https://github.com/siddharthmnn/rewindfs/blob/main/internal/storage/sqlite.go) (SQLite storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and versioning"]
  node_runtime["Application startup<br/>[main.go]"]
  node_watcher["Filesystem watcher<br/>[watcher.go]"]
  node_snapshot["Snapshot creation<br/>[snapshots.go]"]
  node_hash["Content hashing<br/>[hash.go]"]
  node_model["Snapshot model<br/>[snapshot.go]"]
end

subgraph group_api["REST API"]
  node_server["HTTP server<br/>[server.go]"]
  node_lookup["Snapshot lookup<br/>[lookup_handlers.go]"]
  node_history["History queries"]
  node_stats["Stats and files<br/>[stats_handlers.go]"]
  node_storage_adapter["Snapshot loading<br/>[storage.go]"]
end

subgraph group_persistence["Persistence and comparison"]
  node_sqlite[("SQLite storage<br/>[sqlite.go]")]
  node_diff["Snapshot comparison<br/>[diff.go]"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard["Web dashboard<br/>[index.html]"]
end

node_filesystem(("Monitored files"))
node_client(("API client"))

node_runtime -->|"starts"| node_watcher
node_runtime -->|"starts"| node_server
node_filesystem -->|"file changes"| node_watcher
node_watcher -->|"creates snapshot"| node_snapshot
node_snapshot -->|"hashes content"| node_hash
node_snapshot -->|"persists snapshot"| node_sqlite
node_snapshot -->|"builds"| node_model
node_server -->|"initializes"| node_sqlite
node_server -->|"loads snapshots"| node_storage_adapter
node_storage_adapter -->|"reads snapshots"| node_sqlite
node_server -->|"creates snapshot"| node_snapshot
node_server -->|"deletes snapshot"| node_sqlite
node_server -->|"compares content"| node_diff
node_server -->|"restores or recovers"| node_filesystem
node_server -->|"registers routes"| node_lookup
node_server -->|"registers routes"| node_history
node_server -->|"registers routes"| node_stats
node_client -->|"HTTP requests"| node_server
node_server -->|"serves page"| node_dashboard
node_dashboard -.->|"requests dashboard data"| node_server
node_lookup -->|"returns snapshots"| node_model
node_history -->|"reads snapshot history"| node_model
node_stats -->|"summarizes snapshots"| node_model

click node_runtime "https://github.com/siddharthmnn/rewindfs/blob/main/main.go"
click node_watcher "https://github.com/siddharthmnn/rewindfs/blob/main/internal/vfs/watcher.go"
click node_snapshot "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/snapshots.go"
click node_hash "https://github.com/siddharthmnn/rewindfs/blob/main/internal/storage/hash.go"
click node_model "https://github.com/siddharthmnn/rewindfs/blob/main/internal/models/snapshot.go"
click node_server "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/server.go"
click node_lookup "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/lookup_handlers.go"
click node_history "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/history_handlers.go"
click node_stats "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/stats_handlers.go"
click node_storage_adapter "https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/storage.go"
click node_sqlite "https://github.com/siddharthmnn/rewindfs/blob/main/internal/storage/sqlite.go"
click node_diff "https://github.com/siddharthmnn/rewindfs/blob/main/internal/diff/diff.go"
click node_dashboard "https://github.com/siddharthmnn/rewindfs/blob/main/frontend/index.html"

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_runtime,node_watcher,node_snapshot,node_hash,node_model,node_client toneBlue
class node_server,node_lookup,node_history,node_stats,node_storage_adapter toneAmber
class node_sqlite,node_diff toneMint
class node_dashboard toneRose
class node_filesystem toneIndigo
```

## Components

### Capture and versioning

- [Application startup](https://github.com/siddharthmnn/rewindfs/blob/main/main.go): `main.go`
- [Filesystem watcher](https://github.com/siddharthmnn/rewindfs/blob/main/internal/vfs/watcher.go): `internal/vfs/watcher.go`
- [Snapshot creation](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/snapshots.go): `internal/api/snapshots.go`
- [Content hashing](https://github.com/siddharthmnn/rewindfs/blob/main/internal/storage/hash.go): `internal/storage/hash.go`
- [Snapshot model](https://github.com/siddharthmnn/rewindfs/blob/main/internal/models/snapshot.go): `internal/models/snapshot.go`

### REST API

- [HTTP server](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/server.go): `internal/api/server.go`
- [Snapshot lookup](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/lookup_handlers.go): `internal/api/lookup_handlers.go`
- [History queries](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/history_handlers.go): `internal/api/history_handlers.go`
- [Stats and files](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/stats_handlers.go): `internal/api/stats_handlers.go`
- [Snapshot loading](https://github.com/siddharthmnn/rewindfs/blob/main/internal/api/storage.go): `internal/api/storage.go`

### Persistence and comparison

- [SQLite storage](https://github.com/siddharthmnn/rewindfs/blob/main/internal/storage/sqlite.go): `internal/storage/sqlite.go`
- [Snapshot comparison](https://github.com/siddharthmnn/rewindfs/blob/main/internal/diff/diff.go): `internal/diff/diff.go`

### Dashboard

- [Web dashboard](https://github.com/siddharthmnn/rewindfs/blob/main/frontend/index.html): `frontend/index.html`

### Other components

- **Monitored files**
- **API client**

## Connections

- Application startup → Filesystem watcher: starts
- Application startup → HTTP server: starts
- Monitored files → Filesystem watcher: file changes
- Filesystem watcher → Snapshot creation: creates snapshot
- Snapshot creation → Content hashing: hashes content
- Snapshot creation → SQLite storage: persists snapshot
- Snapshot creation → Snapshot model: builds
- HTTP server → SQLite storage: initializes
- HTTP server → Snapshot loading: loads snapshots
- Snapshot loading → SQLite storage: reads snapshots
- HTTP server → Snapshot creation: creates snapshot
- HTTP server → SQLite storage: deletes snapshot
- HTTP server → Snapshot comparison: compares content
- HTTP server → Monitored files: restores or recovers
- HTTP server → Snapshot lookup: registers routes
- HTTP server → History queries: registers routes
- HTTP server → Stats and files: registers routes
- API client → HTTP server: HTTP requests
- HTTP server → Web dashboard: serves page
- Web dashboard → HTTP server: requests dashboard data
- Snapshot lookup → Snapshot model: returns snapshots
- History queries → Snapshot model: reads snapshot history
- Stats and files → Snapshot model: summarizes snapshots
