Skip to content

Local Development ​

This document is intended for developers who want to set up a local ZViewer development environment.


Environment Requirements ​

ToolMinimum VersionNotes
Go1.26Backend and desktop shell
Node.js22.x LTSFrontend build and scripts
npm10.xInstalled with Node.js
Git--Used for cloning the project code

On Windows, Git Bash is needed to run backend-go/scripts/*.sh.

Step 1: Clone and Install ​

bash
git clone https://github.com/Zero-wyc/ZViewer.git
cd ZViewer
npm install          # npm workspaces, installed from the root
npm run db:init      # create an empty database with root / root

Step 2: Start Development ​

bash
npm run dev              # backend (hot reload) + frontend together
npm run dev:backend      # backend only; rebuilds and swaps the process on change
npm run dev:backend:once # compile once, no watcher
npm run dev:frontend     # frontend only, http://localhost:5174

Vite proxies /api, /socket.io, /signal and /live to localhost:3333, so no VITE_API_URL configuration is needed.

Development Ports ​

ServiceAddressDescription
Frontend Dev Serverhttp://localhost:5174Vite dev server with HMR
Backend Dev Serverhttp://localhost:3333Go backend
RTMP Push Stream3334OBS streaming port
Media UDP / TCP3333/udp, 3337Voice and sharing media

Common Scripts ​

CommandDescription
npm run devStart both ends
npm run buildBuild backend and frontend
npm run build:allDistribution build (dist/win, dist/linux)
npm run db:init / db:upgrade / db:backupCreate / migrate / hot-backup the database
npm run lint:go / test:gogofmt -l + go vet / go test ./...
npm run lint / npm test -w frontendeslint / frontend unit tests
npm run test:regressionFull Go regression suite
npm run startStart the production build

Project Structure Overview ​

ZViewer/
├── backend-go/       # Go backend
│   ├── cmd/zviewer-server/   # assembly entry point
│   └── internal/             # api / room / bilibili / proxy / share / piik / ncm / nms / db
├── frontend/         # React frontend (Vite + Tailwind CSS)
├── desktop/          # Wails v2 desktop shell + ui/
├── scripts/          # hot reload, artifact build, launchers
├── packaging/        # startup script templates
├── docker/           # Docker entry point
├── build-all.js      # distribution build
└── dist/             # build output

Database ​

  • One engine: SQLite (config/dev.sqlite), pure Go driver, WAL by default.
  • Schema source of truth: backend-go/internal/db/schema.sql, applied by --init-db only; the startup path verifies the schema and never creates tables.
  • Backups: --backup-db (VACUUM INTO). With WAL on, copying the main file alone loses the latest transactions.

Utility Scripts ​

ScriptDescription
scripts/build-backend.jsCompile the Go backend into dist/ (single entry point)
scripts/dev-backend.jsDevelopment hot reload
scripts/start.jsCross-platform start forwarding
`packaging/start-*.ps1sh`

This project is licensed under CC BY-NC-SA.