npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capdiag

v1.0.1

Published

Generates Class Diagrams from SAP CAP (NodeJS) projects.

Downloads

298

Readme

capdiag

Generates class diagrams from SAP CAP (Node.js) projects. Reads your CDS model and writes diagram files in Mermaid or PlantUML format.

Requirements

Node.js >= 20.0.0

Installation

npm install -g capdiag

Usage

Run inside a CAP project directory (where package.json and your CDS files live):

capdiag [options]

CLI Options

| Option | Alias | Default | Description | |--------|-------|---------|-------------| | --type | -t | mermaid | Diagram format. Choices: mermaid, plantUML. Overridden per diagram by the config file. | | --config | | | Path to a configuration file. If omitted, capdiag looks for .capdiag.json in the current directory. | | --dir | -D | diagrams | Directory in which to write the generated diagram files. Created automatically if it does not exist. | | --modelRoot | -m | . | Root directory of the CDS model. All CDS files within it are loaded. Useful when running capdiag from outside the CAP project directory. | | --asMarkdown | -md | true | Wrap Mermaid output in a ```mermaid code block, ready to embed in Markdown files. Ignored for other diagram types. | | --help | -h | | Show help. |

Configuration File

The configuration file is a JSON object. Each key is an output filename and its value is a diagram configuration object controlling what that diagram contains.

{
  "overview.md": {
    "title": "My Service Overview",
    "includes": ["my.namespace.*"],
    "excludes": ["my.namespace.InternalEntity"],
    "noFields": false,
    "includeAssociationsToExcludedTargets": false
  },
  "admin.md": {
    "title": "Admin Entities",
    "includes": ["admin.*"]
  }
}

Output files are written to the directory specified by --dir (default: diagrams/).

If no config file is found, capdiag generates a single file all.md containing all entities with default settings.

Diagram Configuration Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | title | string | — | Title rendered at the top of the diagram. | | includes | string[] | — | Whitelist of entity name patterns to include. Supports * as a wildcard. If omitted, all entities are included. | | excludes | string[] | — | Blacklist of entity name patterns to exclude. Supports * as a wildcard. Applied after includes. | | noFields | boolean | false | When true, entity fields are omitted — only class names and associations are rendered. | | includeAssociationsToExcludedTargets | boolean | false | When true, associations pointing to entities that are not in the diagram are still rendered. |

Pattern Syntax

includes and excludes entries are glob-style patterns matched against fully qualified entity names:

  • my.namespace.Entity — exact match
  • my.namespace.* — all entities in the namespace
  • * — all entities

Examples

Minimal — all entities, default settings

Run without a config file:

capdiag

Generates diagrams/all.md as a Mermaid class diagram.

PlantUML output

capdiag --type plantUML

Custom output directory

capdiag --dir docs/diagrams

Multiple diagrams from one config

.capdiag.json:

{
  "public.md": {
    "title": "Public API",
    "includes": ["public.*"],
    "noFields": false
  },
  "internal.md": {
    "title": "Internal Model",
    "excludes": ["public.*"],
    "includeAssociationsToExcludedTargets": true
  }
}
capdiag

Generates diagrams/public.md and diagrams/internal.md.

Samples

See samples/README.md for ready-to-use configuration files based on the SAP CAP sample projects.