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
Node.js18.x20.x or 22.x LTS recommended
npm9.xInstalled with Node.js
Git--Used for cloning the project code

Step 1: Clone the Project ​

bash
git clone https://github.com/Zero-wyc/ZViewer.git
cd ZViewer

Step 2: Install Dependencies ​

The project uses npm workspaces. Install all dependencies from the root directory:

bash
npm install

This will automatically install all dependencies for the backend/ and frontend/ workspaces.

Step 3: Start the Development Servers ​

bash
npm run dev

This uses concurrently to start both the frontend and backend development servers at the same time.

Start Separately ​

bash
npm run dev:backend    # Backend http://localhost:3333
npm run dev:frontend   # Frontend http://localhost:5174

When developing the frontend, Vite proxies requests to the backend by default (requests to /api, /socket.io, /live are automatically forwarded to localhost:3333), so no additional VITE_API_URL configuration is needed.

Development Ports ​

ServiceAddressDescription
Frontend Dev Serverhttp://localhost:5174Vite dev server with HMR hot reload
Backend Dev Serverhttp://localhost:3333Express + TypeScript with hot reload
RTMP Push Stream3334OBS streaming port
HTTP-FLV Pull Stream3335Live stream playback

Common Scripts ​

CommandDescription
npm run devStart both frontend and backend dev services in parallel
npm run dev:backendStart backend only
npm run dev:frontendStart frontend only
npm run buildBuild both frontend and backend
npm run build:allFull single-file compilation (generates dist/ executable)
npm run lintRun code linting
npm run startCross-platform start (forwards to start-prod.* script)

Project Structure Overview ​

ZViewer/
├── backend/          # Express backend (TypeScript + TypeORM + sql.js)
├── frontend/         # React frontend (Vite + Tailwind CSS)
├── scripts/          # Utility scripts (certificates/build/start)
├── docker/           # Docker entry point
├── packaging/        # Startup script templates
└── dist/             # Build output

Database ​

  • Default: SQLite (config/dev.sqlite), sql.js wasm implementation
  • Optional: PostgreSQL (requires DATABASE_URL configuration)

Utility Scripts ​

ScriptDescription
scripts/generate-cert.jsSSL certificate generation (self-signed / Let's Encrypt)
scripts/acme-client.jsACME v2 HTTP-01 client
scripts/build-exe.jsBackend single-file compilation
scripts/start.jsCross-platform start forwarding

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