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 🙏

© 2025 – Pkg Stats / Ryan Hefner

business-as-code

v0.2.1

Published

Define, launch, experiment, iterate, and grow your business entirely in code

Readme

business-as-code

npm version License: MIT

Define, launch, experiment, iterate, and grow your business entirely in code

Overview

business-as-code provides a schema-first approach to defining business entities. Write your business model in MDX, YAML, or JSON, and use it across different platforms.

business-as-code (portable schema layer)
       ↓
   ┌───┴───┐
   ↓       ↓
Startups.Studio    Platform.do
(AI startups)      (Enterprise)

This is the schema definition layer - it defines what your business entities look like. It works alongside runtime packages like agents.do, workflows.do, and humans.do which handle the actual business operations.

Installation

npm install business-as-code
# or
pnpm add business-as-code

Quick Start

Use the Default Business Schema

The package includes a comprehensive default schema with 40+ business entities across 9 domains:

import { defaultBusinessSchema, getAllNouns } from 'business-as-code'

// Get all nouns from the default business schema
const nouns = getAllNouns(defaultBusinessSchema)
console.log(`${nouns.length} nouns loaded`)

// Access specific noun schemas directly
import { Customers, Products, Invoices, Projects, Teams } from 'business-as-code'

Define Custom Business in MDX

MDX provides the most expressive way to define business entities with JSX-like syntax:

import { loadFromMDX, mergeSchemas, defaultBusinessSchema } from 'business-as-code'

const mdx = `
<Business name="My SaaS">
  <Noun name="Tenant" group="Admin">
    <Name text required />
    <Subdomain text unique />
    <Plan status="free|pro|enterprise" />
    <Owner user />
  </Noun>

  <Noun name="Feature" group="Product">
    <Name text required />
    <Description rich />
    <Tier status="free|pro|enterprise" />
    <Enabled boolean />
  </Noun>
</Business>
`

const customSchema = await loadFromMDX(mdx)
const fullSchema = mergeSchemas(defaultBusinessSchema, customSchema)

Define Custom Business in YAML

YAML is ideal for configuration files and version control:

import { loadFromYAML } from 'business-as-code'

const yaml = `
name: My SaaS
version: 1.0.0

domains:
  admin:
    - name: Tenant
      titleField: name
      fields:
        name: text required
        subdomain: text unique
        plan: status:free|pro|enterprise
        owner: ref:users

  product:
    - name: Feature
      titleField: name
      fields:
        name: text required
        description: rich
        tier: status:free|pro|enterprise
        enabled: boolean
`

const schema = loadFromYAML(yaml)

Define Custom Business in JSON

JSON works well for programmatic generation and API responses:

import { loadFromJSON } from 'business-as-code'

const json = {
  name: "My SaaS",
  version: "1.0.0",
  domains: {
    admin: [{
      name: "Tenant",
      titleField: "name",
      fields: {
        name: "text required",
        subdomain: "text unique",
        plan: "status:free|pro|enterprise"
      }
    }]
  }
}

const schema = loadFromJSON(JSON.stringify(json))

Domains

The default business schema includes these domains:

| Domain | Nouns | Description | |--------|-------|-------------| | Admin | Users, Orgs, ServiceAccounts | System administration | | Business | Businesses, Goals, Metrics, Teams, Processes | Core business entities | | Product | Products, Services, Offers, Prices, Features | Product catalog | | Success | Customers, Contacts, Subscriptions | Customer success | | Sales | Deals, Quotes, Proposals | Sales pipeline | | Marketing | Leads, Brands, Domains, Competitors | Marketing & branding | | Work | Projects, Tasks, Issues, Workflows, Roles, Agents | Work management | | Financial | Invoices, Payments, Refunds, ChartOfAccounts, JournalEntries | Accounting | | Communications | Channels, Messages, Sequences, Templates, Posts | Messaging |

Field Types

Primitive Types

| Type | Description | Example | |------|-------------|---------| | text | Single-line text | name: text | | rich | Rich text / markdown | description: rich | | number | Numeric value | count: number | | boolean | True/false checkbox | isActive: boolean | | date | Date picker | createdAt: date |

Semantic Types (with validation)

| Type | Description | Example | |------|-------------|---------| | email | Email address | email: email | | url | Valid URL | website: url | | phone | Phone number | phone: phone | | slug | URL-safe slug | slug: slug |

Business Types

| Type | Description | Example | |------|-------------|---------| | money | Currency amount | price: money | | score | 0-100 value | health: score | | status:a\|b\|c | Select options | status: status:active\|inactive |

Relationship Types

| Type | Description | Example | |------|-------------|---------| | ref:collection | Reference to another noun | customer: ref:customers | | user | Reference to users | owner: user |

Modifiers

| Modifier | Description | Example | |----------|-------------|---------| | required | Field must have value | name: text required | | unique | Value must be unique | slug: text unique |

API Reference

Schema Functions

import {
  defaultBusinessSchema,  // The complete default schema
  getAllNouns,           // Get all nouns as flat array
  getDomainNouns,        // Get nouns for a specific domain
  getDomains,            // Get list of all domain names
  findNounBySlug,        // Find a noun by its slug
  mergeSchemas,          // Merge two schemas together
  validateSchema,        // Validate a schema structure
  createMinimalSchema,   // Create empty schema scaffold
} from 'business-as-code'

Loaders

import {
  load,           // Auto-detect format and load
  loadFromMDX,    // Load from MDX source
  loadFromYAML,   // Load from YAML source
  loadFromJSON,   // Load from JSON source
  loadNoun,       // Load a single noun definition
  loadNouns,      // Load multiple noun definitions
} from 'business-as-code'

Serializers

import {
  serialize,      // Serialize schema to YAML or JSON
  toYAML,         // Serialize to YAML string
  toJSON,         // Serialize to JSON string
  serializeNoun,  // Serialize single noun
  nounToYAML,     // Noun to YAML
  nounToJSON,     // Noun to JSON
} from 'business-as-code'

Types

import type {
  BusinessSchema,    // Complete business schema
  BusinessDomain,    // Domain name type
  NounSchema,        // Individual noun definition
  FieldSchema,       // Field definition
  FieldType,         // Field type union
  LoaderOptions,     // Options for loaders
  LoadResult,        // Result from load operations
} from 'business-as-code'

Integration

business-as-code provides the schema layer that integrates with the broader .do ecosystem:

License

MIT