Skip to content

Repository files navigation

min-node-app-template

A comprehensive Node.js application template with CLI, Web, and MCP (Model Context Protocol) support

CI License: MIT

This template provides a modern, production-ready foundation for building Node.js applications with multiple interfaces (CLI, Web, and AI agent integration).

✨ Features

  • 🎯 Unified CLI - Single executable with three modes: CLI, Web, and MCP
  • πŸ—οΈ Monorepo structure with pnpm workspaces
  • πŸ“¦ TypeScript with strict mode
  • 🎨 Biome for lightning-fast linting and formatting
  • πŸ“¦ Rolldown for optimized CLI bundling
  • πŸ§ͺ Vitest for unit testing
  • πŸ€– MCP support for AI agent integration
  • πŸ”„ CI/CD with GitHub Actions
  • 🐳 Devcontainer ready
  • πŸ”’ Dependabot configured

πŸ“¦ Package Structure

This monorepo contains:

  • @template/core - Core business logic and shared utilities
  • @template/cli - Unified CLI with three modes:
    • CLI mode - Command-line interface with Commander.js
    • Web mode - Express REST API server
    • MCP mode - Model Context Protocol server for AI agents
  • @template/web - Web UI components (Preact, used by CLI web mode)
  • @template/mcp - MCP server implementation (used by CLI mcp mode)

πŸš€ Quick Start

Using This Template

  1. Click "Use this template" on GitHub
  2. Clone your new repository
  3. Update package names in all package.json files
  4. Update repository URLs
  5. Update README with your project details

Development Setup

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Lint and format
pnpm lint
pnpm format

Running the Unified CLI

The CLI supports three modes:

CLI Mode (Default Commands)

cd packages/cli
pnpm build

# Basic commands
node dist/index.js greet "World"
node dist/index.js info
node dist/index.js --help

Web Mode

# Start web server with REST API
node dist/index.js web --port 3000

# Or use bundled version
node dist/bundled.js web

MCP Mode

# Start MCP server for AI agent integration
node dist/index.js mcp

# Or use bundled version
node dist/bundled.js mcp

Building the Bundle

cd packages/cli
pnpm build:bundle

# Creates a single bundled executable at dist/bundled.js
# This includes all three modes in one file

πŸ—οΈ Project Structure

min-node-app-template/
β”œβ”€β”€ .devcontainer/          # Dev container configuration
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/          # CI/CD pipelines
β”‚   β”‚   β”œβ”€β”€ ci.yml         # Continuous Integration
β”‚   β”‚   └── release.yml    # Release pipeline
β”‚   └── dependabot.yml     # Dependency updates
β”œβ”€β”€ docs/                   # Documentation
β”‚   β”œβ”€β”€ README.md          # Documentation index
β”‚   β”œβ”€β”€ design.md          # Architecture & design
β”‚   └── development.md     # Development guide
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ core/              # Core package
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ test/
β”‚   β”‚   └── package.json
β”‚   β”œβ”€β”€ cli/               # CLI package
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ test/
β”‚   β”‚   β”œβ”€β”€ scripts/       # Build scripts
β”‚   β”‚   └── package.json
β”‚   β”œβ”€β”€ web/               # Web package
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ server.ts  # Express server
β”‚   β”‚   β”‚   └── client/    # Preact UI
β”‚   β”‚   β”œβ”€β”€ test/
β”‚   β”‚   └── package.json
β”‚   └── mcp/               # MCP package
β”‚       β”œβ”€β”€ src/
β”‚       β”œβ”€β”€ test/
β”‚       └── package.json
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .biomeignore
β”œβ”€β”€ biome.json             # Linting & formatting
β”œβ”€β”€ package.json           # Root package
β”œβ”€β”€ pnpm-workspace.yaml    # Workspace config
β”œβ”€β”€ tsconfig.base.json     # Base TypeScript config
β”œβ”€β”€ AGENTS.md              # AI agent guidelines
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
└── README.md

πŸ› οΈ Tech Stack

  • Language: TypeScript 5.x
  • Package Manager: pnpm 10.x
  • Build Tool: TypeScript Compiler (tsc)
  • Bundlers:
    • Rolldown (CLI single-file bundle)
    • Vite (Web frontend)
  • Testing: Vitest
  • Linting/Formatting: Biome
  • CLI Framework: Commander.js
  • Web Framework: Express + Preact
  • AI Integration: Model Context Protocol SDK

πŸ“š Documentation

πŸ”§ Configuration

GitHub Secrets

For CI/CD to work properly, configure these secrets:

  • NPM_TOKEN - For publishing packages to npm
  • GITHUB_TOKEN - Automatically provided by GitHub

Customization

  1. Package Names: Update name in all package.json files
  2. Repository URLs: Update repository.url in all package.json files
  3. License: Update LICENSE file if needed
  4. Styling: Customize Biome rules in biome.json
  5. Build: Adjust TypeScript config in tsconfig.base.json

πŸ§ͺ Testing

# Run all tests
pnpm test

# Run tests in watch mode
pnpm test -- --watch

# Run tests with coverage
pnpm test -- --coverage

# Test specific package
cd packages/core
pnpm test

πŸ“¦ Building

# Build all packages
pnpm build

# Build CLI bundle
cd packages/cli
pnpm build:bundle

# Build web for production
cd packages/web
pnpm build

πŸš€ Publishing

The template includes automated publishing via GitHub Actions:

  1. Update version in packages/cli/package.json
  2. Update CHANGELOG.md
  3. Commit changes
  4. Create and push tag: git tag v1.0.0 && git push origin v1.0.0
  5. GitHub Actions will automatically publish to npm

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

πŸ“ License

MIT License - see LICENSE for details

πŸ”— Links

πŸ’‘ Template Philosophy

This template is designed for:

  • Developers who want a solid foundation for Node.js projects
  • Projects that need multiple interfaces (CLI, Web, AI)
  • Teams that value type safety and developer experience
  • Applications that benefit from monorepo structure
  • Projects requiring AI agent integration via MCP

Built with ❀️ using modern TypeScript tooling

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages