# ggufviewer.cpp

Standalone GGUF model inspector with embedded web UI.

Single binary, no dependencies beyond a C++17 compiler. Scans a directory
for `.gguf` files and serves a Svelte web interface for browsing metadata,
tensors, heatmaps, histograms, and tokenizer vocabulary.

## Build

```bash
# Linux / macOS
./buildall.sh

# Windows
buildall.cmd
```

## Usage

```bash
./build/gguf-viewer --root /path/to/models
```

Open `http://localhost:8080` in a browser.

## WebUI development

The web UI is built with Svelte 5, TypeScript, and Vite. The production
build is inlined into a single `index.html`, gzipped, and embedded into
the C++ binary via `xxd.cmake`.

```bash
# first time setup
cd tools/webui && npm install

# dev server (proxies /api to C++ server on :8080)
npm run dev

# production build (outputs tools/public/index.html.gz)
npm run build
```

After `npm run build`, rebuild the C++ binary to embed the new UI.

## Architecture

```
ggufviewer.cpp/
  CMakeLists.txt           root build (cmake 3.14+, C++17)
  vendor/
    cpp-httplib/           HTTP server (MIT, same as llama.cpp)
    nlohmann/              JSON (MIT, same header-only lib as llama.cpp)
  src/
    viewer-gguf.h          standalone GGUF format parser
    viewer-io.h            mmap + dequantization dispatch
    viewer-tensor.h        layout, tiles, stats, histogram
    viewer-http.h          REST API routes (JSON for metadata, binary for tensors)
  tools/
    gguf-viewer.cpp        main binary (CLI + server + webui)
    version.cmake          git hash embedding
    xxd.cmake              binary to C array
    public/
      index.html.gz        committed gzipped SPA
    webui/
      src/                 Svelte 5 + TypeScript sources
      vite.config.ts       Vite + singlefile + gzip plugin
```

## License

MIT
