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

catsys

v1.0.3

Published

Category-theoretic system design framework for scalable, modular systems using mathematical foundations

Readme

CatSys: Category-Theoretic System Design Framework

License: GPL-3.0 npm version TypeScript

📦 npm package | 🐙 GitHub repository

CatSys is a robust framework for building scalable, modular systems using category theory principles. It provides mathematical guarantees for system correctness through 12 foundational laws.

Key Features

  • Mathematical Foundations: Built on category theory principles ensuring system correctness
  • Type-Safe: Written in TypeScript with comprehensive type definitions
  • Modular Architecture: Clean separation of domain logic from infrastructure
  • Event Sourcing & CQRS: Built-in support with mathematical guarantees
  • Property-Based Testing: Automated verification of category theory laws
  • Infrastructure Independence: Swap implementations without changing business logic
  • Observability: Built-in metrics and tracing that compose correctly

Quick Start

npm install catsys
import { DomainSpec, createGenericService, adapters } from 'catsys';

// Define your domain
class CounterSpec extends DomainSpec {
  constructor() {
    super();
    this.initialState = { count: 0 };
  }

  decide(state, command) {
    if (command.kind === 'Increment') {
      return [{ kind: 'Incremented', amount: command.amount }];
    }
    return [];
  }

  evolve(state, event) {
    if (event.kind === 'Incremented') {
      return { count: state.count + event.amount };
    }
    return state;
  }
}

// Create service with in-memory adapters
const service = createGenericService(
  new CounterSpec(),
  { count: 0 },
  {
    sql: adapters.inMemorySql(),
    bus: adapters.inMemoryBus()
  }
);

// Use the service
await service.handle({ count: 0 }, { kind: 'Increment', amount: 5 });

Core Concepts

Category Theory Laws

CatSys enforces 12 mathematical laws that guarantee system correctness:

  1. Purity: Domain logic is pure and deterministic
  2. Functoriality: Implementation preserves composition
  3. Observability: Metrics and traces compose correctly
  4. CQRS Commutativity: Read models are consistent
  5. Outbox Pattern: Reliable event publishing
  6. Push/Pull Equivalence: UI state convergence
  7. Replay Determinism: Event sourcing correctness
  8. Idempotence: Safe command retries
  9. Causality: Event ordering preservation
  10. Monoidal Aggregation: Correct analytics
  11. Pullback Correctness: Safe data joins
  12. Schema Evolution: Safe upgrades

Architecture

CatSys uses a ports and adapters architecture with:

  • Domain Layer: Pure business logic (Set category)
  • Application Layer: Infrastructure integration (Kleisli category)
  • Infrastructure Layer: Concrete implementations
  • Composition Root: Dependency injection point

Type System

type Command = { kind: string, ... }
type Event = { kind: string, ... }
type State = any
type View = any
type Raw = any

interface DomainSpec {
  decide(state: State, command: Command): Event[]
  evolve(state: State, event: Event): State
  project(view: View, event: Event): View
  // ... other methods
}

Testing

CatSys includes comprehensive testing tools:

// Property-based testing
spec.verifyLaws();

// Unit testing
test('increment', async () => {
  const result = await service.handle(
    { count: 0 },
    { kind: 'Increment', amount: 1 }
  );
  expect(result).toEqual({ count: 1 });
});

Documentation

Examples

See the examples directory for:

  • Video streaming service
  • Document management system
  • Multi-tenant architecture
  • Blue/green deployments
  • Event sourcing patterns

Security

CatSys takes security seriously:

  • No eval() or dynamic code execution
  • No sensitive data in logs/metrics
  • Secure by default adapters
  • Input validation at boundaries
  • Safe schema evolution

License

GPL-3.0 - see LICENSE for details.

Support