# unixfile/dirview architecture

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

- Interactive diagram: https://gitdiagram.com/unixfile/dirview
- Repository: https://github.com/unixfile/dirview

## Overview

dirview serves local directories and fetched forge repositories as linked browser pages. The main reader workflow is to start `drvu`, route a browser request to a served tree, and render its files; code, search, and history provide parallel reading features. Separate workflows cover server and lock management, online-repository fetching, and PDF output. The graph combines README-documented capabilities with sampled routing and syntax-helper details; several subsystem links are dashed where implementation excerpts were not available.

Main entry points: [`server.go`](https://github.com/unixfile/dirview/blob/master/server.go) (HTTP server), [`page.go`](https://github.com/unixfile/dirview/blob/master/page.go) (Page routing), [`serve.go`](https://github.com/unixfile/dirview/blob/master/serve.go) (Server lifecycle), [`syntax.go`](https://github.com/unixfile/dirview/blob/master/syntax.go) (Code pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and servers"]
  node_localcmd["Local command<br/>[main.go]"]
  node_publiccmd["Public command<br/>[main.go]"]
  node_options["CLI options<br/>[args.go]"]
  node_lifecycle["Server lifecycle<br/>[serve.go]"]
  node_locks[("Locks and registry<br/>[registry.go]")]
  node_httpserver["HTTP server<br/>[server.go]"]
  node_tree["Served tree<br/>[server.go]"]
  node_guards["Safety guards<br/>[guard.go]"]
end

subgraph group_reading["Pages and navigation"]
  node_page["Page routing<br/>[page.go]"]
  node_treepage["Tree listings<br/>[treepage.go]"]
  node_render["Page rendering<br/>[render.go]"]
  node_links["Linked pages<br/>[links.go]"]
  node_live["Live reload<br/>[live.go]"]
  node_pdf["PDF export<br/>[pdf.go]"]
end

subgraph group_code["Code understanding"]
  node_codepages["Code pages<br/>[syntax.go]"]
  node_syntaxhelper["Syntax helper<br/>[main.go]"]
  node_scope["Code scopes<br/>[scope.go]"]
end

subgraph group_history["History and search"]
  node_search["Search<br/>[search.go]"]
  node_git["Git history<br/>[git.go]"]
  node_historypage["History pages<br/>[historypage.go]"]
  node_semantic["Semantic diffs<br/>[semantic.go]"]
  node_feed["History feeds<br/>[feed.go]"]
end

subgraph group_online["Online repositories"]
  node_web["Online repo service<br/>[web.go]"]
  node_forge["Forge fetching<br/>[webclone.go]"]
end

node_reader(("Reader"))

node_reader -->|"starts local"| node_localcmd
node_reader -->|"starts public"| node_publiccmd
node_localcmd -.->|"parses options"| node_options
node_publiccmd -.->|"parses options"| node_options
node_options -.->|"configures serving"| node_lifecycle
node_lifecycle -->|"registers trees"| node_locks
node_lifecycle -.->|"starts server"| node_httpserver
node_httpserver -->|"routes requests"| node_tree
node_httpserver -->|"wraps handlers"| node_guards
node_reader -.->|"requests pages"| node_httpserver
node_httpserver -.->|"dispatches pages"| node_page
node_page -.->|"shows listings"| node_treepage
node_page -->|"renders pages"| node_render
node_treepage -->|"links files"| node_links
node_httpserver -->|"serves reload"| node_live
node_page -->|"shows code"| node_codepages
node_codepages -->|"parses syntax"| node_syntaxhelper
node_codepages -->|"shows scopes"| node_scope
node_tree -->|"searches files"| node_search
node_tree -->|"reads history"| node_git
node_git -->|"provides revisions"| node_historypage
node_historypage -->|"shows semantic diffs"| node_semantic
node_historypage -->|"offers feeds"| node_feed
node_reader -->|"opens online repo"| node_web
node_web -->|"fetches repositories"| node_forge
node_web -->|"serves fetched repos"| node_httpserver
node_page -->|"exports PDF"| node_pdf

click node_localcmd "https://github.com/unixfile/dirview/blob/master/cmd/local/main.go"
click node_publiccmd "https://github.com/unixfile/dirview/blob/master/cmd/public/main.go"
click node_options "https://github.com/unixfile/dirview/blob/master/args.go"
click node_lifecycle "https://github.com/unixfile/dirview/blob/master/serve.go"
click node_locks "https://github.com/unixfile/dirview/blob/master/registry.go"
click node_httpserver "https://github.com/unixfile/dirview/blob/master/server.go"
click node_tree "https://github.com/unixfile/dirview/blob/master/server.go"
click node_guards "https://github.com/unixfile/dirview/blob/master/guard.go"
click node_page "https://github.com/unixfile/dirview/blob/master/page.go"
click node_treepage "https://github.com/unixfile/dirview/blob/master/treepage.go"
click node_render "https://github.com/unixfile/dirview/blob/master/render.go"
click node_links "https://github.com/unixfile/dirview/blob/master/links.go"
click node_live "https://github.com/unixfile/dirview/blob/master/live.go"
click node_codepages "https://github.com/unixfile/dirview/blob/master/syntax.go"
click node_syntaxhelper "https://github.com/unixfile/dirview/blob/master/syntax/main.go"
click node_scope "https://github.com/unixfile/dirview/blob/master/scope.go"
click node_search "https://github.com/unixfile/dirview/blob/master/search.go"
click node_git "https://github.com/unixfile/dirview/blob/master/git.go"
click node_historypage "https://github.com/unixfile/dirview/blob/master/historypage.go"
click node_semantic "https://github.com/unixfile/dirview/blob/master/semantic.go"
click node_feed "https://github.com/unixfile/dirview/blob/master/feed.go"
click node_web "https://github.com/unixfile/dirview/blob/master/web.go"
click node_forge "https://github.com/unixfile/dirview/blob/master/webclone.go"
click node_pdf "https://github.com/unixfile/dirview/blob/master/pdf.go"

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_localcmd,node_publiccmd,node_options,node_lifecycle,node_locks,node_httpserver,node_tree,node_guards toneBlue
class node_page,node_treepage,node_render,node_links,node_live,node_pdf toneAmber
class node_codepages,node_syntaxhelper,node_scope toneMint
class node_search,node_git,node_historypage,node_semantic,node_feed toneRose
class node_web,node_forge,node_reader toneIndigo
```

## Components

### Runtime and servers

- [Local command](https://github.com/unixfile/dirview/blob/master/cmd/local/main.go): `cmd/local/main.go`
- [Public command](https://github.com/unixfile/dirview/blob/master/cmd/public/main.go): `cmd/public/main.go`
- [CLI options](https://github.com/unixfile/dirview/blob/master/args.go): `args.go`
- [Server lifecycle](https://github.com/unixfile/dirview/blob/master/serve.go): `serve.go`
- [Locks and registry](https://github.com/unixfile/dirview/blob/master/registry.go): `registry.go`
- [HTTP server](https://github.com/unixfile/dirview/blob/master/server.go): `server.go`
- [Served tree](https://github.com/unixfile/dirview/blob/master/server.go): `server.go`
- [Safety guards](https://github.com/unixfile/dirview/blob/master/guard.go): `guard.go`

### Pages and navigation

- [Page routing](https://github.com/unixfile/dirview/blob/master/page.go): `page.go`
- [Tree listings](https://github.com/unixfile/dirview/blob/master/treepage.go): `treepage.go`
- [Page rendering](https://github.com/unixfile/dirview/blob/master/render.go): `render.go`
- [Linked pages](https://github.com/unixfile/dirview/blob/master/links.go): `links.go`
- [Live reload](https://github.com/unixfile/dirview/blob/master/live.go): `live.go`
- [PDF export](https://github.com/unixfile/dirview/blob/master/pdf.go): `pdf.go`

### Code understanding

- [Code pages](https://github.com/unixfile/dirview/blob/master/syntax.go): `syntax.go`
- [Syntax helper](https://github.com/unixfile/dirview/blob/master/syntax/main.go): `syntax/main.go`
- [Code scopes](https://github.com/unixfile/dirview/blob/master/scope.go): `scope.go`

### History and search

- [Search](https://github.com/unixfile/dirview/blob/master/search.go): `search.go`
- [Git history](https://github.com/unixfile/dirview/blob/master/git.go): `git.go`
- [History pages](https://github.com/unixfile/dirview/blob/master/historypage.go): `historypage.go`
- [Semantic diffs](https://github.com/unixfile/dirview/blob/master/semantic.go): `semantic.go`
- [History feeds](https://github.com/unixfile/dirview/blob/master/feed.go): `feed.go`

### Online repositories

- [Online repo service](https://github.com/unixfile/dirview/blob/master/web.go): `web.go`
- [Forge fetching](https://github.com/unixfile/dirview/blob/master/webclone.go): `webclone.go`

### Other components

- **Reader**

## Connections

- Reader → Local command: starts local
- Reader → Public command: starts public
- Local command → CLI options: parses options
- Public command → CLI options: parses options
- CLI options → Server lifecycle: configures serving
- Server lifecycle → Locks and registry: registers trees (evidence: `serve.go`)
- Server lifecycle → HTTP server: starts server
- HTTP server → Served tree: routes requests (evidence: `server.go`)
- HTTP server → Safety guards: wraps handlers (evidence: `server.go`)
- Reader → HTTP server: requests pages
- HTTP server → Page routing: dispatches pages
- Page routing → Tree listings: shows listings
- Page routing → Page rendering: renders pages
- Tree listings → Linked pages: links files
- HTTP server → Live reload: serves reload (evidence: `server.go`)
- Page routing → Code pages: shows code
- Code pages → Syntax helper: parses syntax (evidence: `syntax/main.go`)
- Code pages → Code scopes: shows scopes
- Served tree → Search: searches files
- Served tree → Git history: reads history
- Git history → History pages: provides revisions
- History pages → Semantic diffs: shows semantic diffs
- History pages → History feeds: offers feeds
- Reader → Online repo service: opens online repo
- Online repo service → Forge fetching: fetches repositories (evidence: `web.go`)
- Online repo service → HTTP server: serves fetched repos (evidence: `web.go`)
- Page routing → PDF export: exports PDF
