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

codepurify

v0.1.1

Published

Semantic metadata inference engine + template compiler for generating architecture artifacts from typed domain configs

Readme

Codepurify

Semantic metadata inference engine + template compiler for generating architecture artifacts from typed domain configs.


What is Codepurify?

  • semantic metadata DSL
  • normalized manifest compiler
  • inference engine
  • template-driven code generator

You define facts about your domain.

Codepurify infers:

  • query capabilities
  • mutation semantics
  • relation groups
  • workflows
  • validation groups
  • reusable template contexts

Templates decide final architecture output.


Core Philosophy

Configs define facts
        ↓
Inference engine derives semantics
        ↓
Normalized context is generated
        ↓
Handlebars templates render output

Codepurify does not hardcode:

  • NestJS
  • TypeORM
  • FastAPI
  • GraphQL
  • React
  • REST
  • DTO patterns
  • folder structures

All architecture styles are implemented through templates.


Features

  • Strongly typed TypeScript configs
  • Semantic metadata inference
  • Handlebars-based generation
  • Framework agnostic
  • Runtime metadata compilation
  • Query/mutation capability inference
  • Typed enum transitions/workflows
  • Semantic validation rule AST
  • Relation graph inference
  • JSON-safe normalized manifests
  • Extensible template ecosystem

Example Use Cases

Generate:

  • DTOs
  • ORM entities
  • repositories
  • GraphQL schemas
  • Zod schemas
  • Pydantic models
  • React forms
  • OpenAPI specs
  • validation layers
  • constants
  • metadata registries
  • query builders
  • admin panels
  • SDKs

from a single semantic source of truth.


Installation

npm install @codepurify/core

Quick Example

Entity Config

import { EntityConfigBase, stringField, enumField, query, mutation, transition } from '@codepurify/core';

export default class UserEntityConfig extends EntityConfigBase {
  key = 'user';

  fields = this.defineFields({
    email: stringField({
      length: 255,

      query: query().select().defaultSelect().search().sort().build(),

      mutation: mutation().apiWritable().build(),
    }),

    status: enumField(['active', 'suspended', 'deleted'] as const, {
      default: 'active',
    }),
  });

  transitions = [
    transition({
      field: () => this.fields.status,

      initial: this.fields.status.values.active,

      terminal: [this.fields.status.values.deleted],

      transitions: {
        [this.fields.status.values.active]: [this.fields.status.values.suspended, this.fields.status.values.deleted],

        [this.fields.status.values.suspended]: [this.fields.status.values.active, this.fields.status.values.deleted],

        [this.fields.status.values.deleted]: [],
      },
    }),
  ];

  templates = ['dto.create', 'dto.update', 'typeorm.entity', 'schema.zod'] as const;
}

Semantic Inference

Codepurify automatically infers semantic groups from metadata.

You never manually define groups.

For example:

query().select().defaultSelect().search().build();

automatically contributes the field into:

entity.fields.query.select
entity.fields.query.default_select
entity.fields.query.search

Likewise:

mutation().apiWritable().immutableAfterCreate().build();

automatically contributes the field into:

entity.fields.mutation.api_create
entity.fields.mutation.immutable_after_create

Handlebars Templates

Codepurify uses Handlebars for rendering generated artifacts.

Templates receive a normalized semantic context.


Example Template

dto.create.hbs

export class Create{{entity.pascal_case_key}}Dto {
{{#each entity.fields.mutation.api_create}}
  {{snake_case_key}}!:
  {{typescript_type}};
{{/each}}
}

Example Generated Output

export class CreateUserDto {
  email!: string;
  status!: UserStatus;
}

Template Context

All exposed template variables are normalized to snake_case.

Example context:

{
  "entity": {
    "key": "user",

    "pascal_case_key": "User",

    "fields": {
      "all": [],

      "strings": [],

      "enums": [],

      "query": {
        "select": [],
        "default_select": [],
        "search": [],
        "sort": []
      },

      "mutation": {
        "api_create": [],
        "api_update": [],
        "immutable": [],
        "generated": []
      }
    },

    "relations": {
      "all": []
    },

    "checks": {
      "all": []
    },

    "indexes": {
      "all": []
    }
  }
}

Query Builder

Semantic query capabilities are defined fluently.

query().select().defaultSelect().sort().search().build();

Mutation Builder

Mutation semantics describe API/system behavior.

mutation().apiWritable().immutableAfterCreate().build();

Supported semantics include:

  • api writable
  • system writable
  • readonly
  • immutable
  • immutable after create
  • generated
  • computed
  • persisted

Relations

Relations are fully typed semantic metadata.

relationField(this, AppEntityConfig, {
  relation: {
    kind: 'one_to_many',

    remote_field: () => new AppEntityConfig().fields.ownerId,

    cascade: true,
  },

  query: {
    select: true,
  },
});

Semantic Validation Rules

Checks are represented as semantic ASTs.

No raw SQL.

checks = [
  {
    name: 'email_not_empty',

    rule: field(() => this.fields.email).notEmpty(),
  },
];

Workflows / Transitions

Transitions are defined independently from enum fields.

transition({
  field: () => this.fields.status,

  initial: this.fields.status.values.active,

  terminal: [this.fields.status.values.deleted],

  transitions: {
    active: ['suspended', 'deleted'],
    suspended: ['active', 'deleted'],
    deleted: [],
  },
});

Compiler Pipeline

TypeScript Configs
        ↓
Runtime Metadata Extraction
        ↓
Semantic Inference Engine
        ↓
Normalized Manifest
        ↓
Handlebars Template Compilation
        ↓
Generated Source Code

Design Goals

Codepurify SHOULD:

  • infer semantic groups automatically
  • remain architecture agnostic
  • support multiple output ecosystems
  • expose normalized template context
  • prioritize metadata semantics over implementation details

Codepurify SHOULD NOT:

  • hardcode framework architecture
  • assume NestJS patterns
  • assume ORM implementations
  • force a specific folder structure
  • expose raw database concerns directly

Long-Term Vision

Codepurify aims to become a universal semantic metadata compiler capable of generating:

  • backend architectures
  • frontend forms
  • APIs
  • SDKs
  • validation layers
  • schemas
  • admin systems
  • documentation
  • infrastructure metadata

from a single semantic domain definition.


Example Future Ecosystem

@codepurify/core
@codepurify/compiler
@codepurify/runtime
@codepurify/templates
@codepurify/typeorm
@codepurify/graphql
@codepurify/zod
@codepurify/react-form
@codepurify/openapi
@codepurify/fastapi

License

MIT