Solution
Hub for the CLI and host tooling. This doc explains what the solution is, how it’s organized, the technology choices, and how the app works at a high level.
What It Is
- Opinionated, zero-config build tool and project scaffolder.
- Full-stack by default: frontend (HTML/CSS/TS) + Node API server.
- Single CLI drives workflows: init, build, watch, test, publish, generators.
- Minimal dependencies; pipelines are orchestrated via C# and pnpm is the default package manager for generated workspaces.
Organization
- CLI: Command entrypoint and help text. Wires DI and invokes workflows.
- Engine: Core logic and pipelines.
- Workflows: Orchestrations for init, build, watch, test, publish, add-page, add-test.
- Workers: Per-area units: FrontendWorker, BackendWorker, SharedWorker.
- Pipelines: HTML, CSS, JS compilers/bundlers and diagnostics.
- Services: DevService, WatchService, ChangeService.
- Servers: Static web server (ASP.NET Core) + Node API host.
- Templates: Embedded project template (frontend/backend/shared/types).
- Workspace: Centralized paths and workspace utilities.
- Worker contracts & DI:
IWorkflowWorker(common) andIFrontendWorker(addsAddPageAsync). DI registers all workers asIWorkflowWorker; workflows injectIEnumerable<IWorkflowWorker>and filter by project mode.
- Tester: xUnit harness validating CLI workflows end-to-end.
- Sandbox: Docker Compose setup to run a published frontend (nginx) and the template API server.
- Utilities: Repo helper scripts (
utilities/scripts/*for format, build, seed deploy).
Technology
- Language/Runtime: C# (.NET 9 for CLI), TypeScript for template code.
- Dev Web Server: ASP.NET Core minimal app serves
build/with SSE for reload. - API Server: Node.js runs compiled
src/backend/index.ts(viatsc). - Build System: Custom C# pipelines for HTML, CSS, JS.
- TypeScript:
tsc --buildusing embeddedbase.tsconfig.json. - CSS: Import resolution, optional CSS Modules in publish, prefixing, minify.
- JS: ESM-only module graph, tree-shake + minify in publish.
- TypeScript:
- Change Detection:
FileSystemWatcher+ buffered change queue; restarts API server on server code changes; notifies browser via SSE. - Caching/URLs: Clean URLs, API proxy (
/api/*→ Node), cache headers for dev/prod.
How It Works
- Init (
webstir init [options] [directory])- Creates a full-stack project (or frontend/backend-only) from embedded templates.
- Layout:
src/frontend/app,src/frontend/pages/<page>,src/backend,src/shared,types/.
- Build (
webstir build)- Compiles TS, processes CSS imports, merges page HTML with
app.htmlintobuild/.
- Compiles TS, processes CSS imports, merges page HTML with
- Watch (
webstir watch) — default- Runs an initial build and tests, starts the web server and Node API server, then watches
src/**. - On change: incrementally rebuilds the affected area, restarts Node for backend changes, and signals browsers to reload via SSE.
- Runs an initial build and tests, starts the web server and Node API server, then watches
- Test (
webstir test)
- Builds, ensures the configured test provider (defaults to
@webstir-io/webstir-testing) is installed, then executes the Webstir test host to run compiled frontend and backend suites; reports pass/fail summary.
- Publish (
webstir publish)- Produces optimized assets in
dist/per page: timestampedindex.<ts>.css/jswritten alongsidemanifest.json. - HTML is minified and references are rewritten using the per-page manifest; source maps and comments are removed.
- Produces optimized assets in
- Generators
webstir add-page <name>scaffoldsindex.html|css|tsundersrc/frontend/pages/<name>/.webstir add-test <name-or-path>scaffolds a.test.tsunder the closesttests/folder.
Conventions & Structure
- Base HTML:
src/frontend/app/app.htmlmust contain a<main>; page fragments merge into it. - Pages:
src/frontend/pages/<page>/index.html|css|ts(publish supports<page>/index.module.css). - App assets:
src/frontend/app/*copied as-is (e.g.,refresh.js). - Shared types:
src/shared/(consumed by both frontend and backend). - Backend:
src/backend/index.tscompiled tobuild/backend/index.jsand run by Node. - Outputs:
- Dev:
build/frontend/**,build/backend/**with readable output and refresh support. - Prod:
dist/frontend/pages/<page>/index.<timestamp>.{css|js}, HTML with rewritten links, per-pagemanifest.json.
- Dev:
CLI Summary
init [--client-only|--server-only] [--project-name|-p <name>] [directory]build [--clean]watch(alias: no command)testpublishadd-page <name>add-test <name-or-path>help [command]
See also: CLI reference
Related Docs
- Docs index — overview
- Templates — templates
- Testing — tests and orchestrator testing guide
- Workspace & paths — workspace
- CLI reference — cli reference
Scope & Non-Goals
- Keep defaults simple and predictable; prefer conventions over configuration.
- Avoid complex plugin systems and heavy third-party build chains.
- Focus on end-to-end workflows (init → build → watch/test → publish).