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

cl-architecture

v1.0.0

Published

CL-Architecture CLI - A strict, production-ready backend architecture standard for Node.js/TypeScript

Downloads

102

Readme

CL-Architecture CLI

A strict, production-ready backend architecture standard for Node.js/TypeScript.

Installation

npm install -g cl-architecture

Or use directly with npx:

npx cl-architecture init

What is CL-Architecture?

CL-Architecture (Core-Line Architecture) is a backend architecture standard, not a framework. It enforces strict separation of concerns, clear data flow, and production-ready patterns.

Core-Line Request Flow

Request
  → Route (context only)
  → Port (controller)
  → Flow (business logic)
  → Source (DB / external)
  → Flow
  → Response DTO
  → Global response handler
  → Response

No shortcuts. No cross-layer calls. No mixed responsibilities.

CLI Commands

Initialize a New Project

npx cl init
npx cl init --name my-backend
npx cl init -y  # Skip prompts, use defaults

Create a Module

npx cl create module user
npx cl create module auth
npx cl create module product -y  # Skip prompts

Interactive prompts:

  • Include validation? (Y/n)
  • Include input DTO? (Y/n)
  • Include response DTO? (Y/n)
  • Include source/repository? (Y/n)
  • Include tests? (Y/n)
  • Include DI bindings? (Y/n)
  • Include logger hooks? (Y/n)

Generated Structure

src/
├── pulse/          # Logger, errors, events
├── orbit/          # Config, env, constants
├── gateway/        # App start, DI wiring, HTTP utilities
├── modules/        # Feature modules
│   └── user/
│       ├── port/   # Controllers, routes
│       ├── flow/   # Business logic
│       ├── source/ # DB, external APIs
│       ├── shape/  # Domain entities
│       ├── bridge/ # DTOs, mappers
│       └── rule/   # Validation
├── framework/      # Express setup
└── test/           # Test utilities

Layers Explained

| Layer | Responsibility | |-------|---------------| | Port | Controllers, input handling | | Flow | Business logic only | | Source | DB, cache, external services | | Shape | Domain models, entities | | Bridge | DTOs, mappers | | Rule | Validation rules | | Pulse | Logger, errors, events | | Orbit | Config, env, constants | | Gateway | App start + DI wiring |

Architecture Rules

Controllers (Port)

  • ✅ Read request
  • ✅ Call Flow
  • ✅ Return standardized response
  • ❌ No business logic
  • ❌ No DB logic
  • ❌ No try/catch (use asyncHandler)

Business Logic (Flow)

  • ✅ Business logic only
  • ✅ Depends on interfaces
  • ❌ No req/res access
  • ❌ No concrete class instantiation
  • ❌ No direct DB calls

Data Access (Source)

  • ✅ DB / external logic only
  • ✅ Implements interfaces
  • ❌ No business logic
  • ❌ No HTTP concerns

DTOs (Bridge)

  • Input DTO: Request validation
  • Flow DTO: Clean business input
  • Response DTO: Safe API output

Flow never touches req.body. Response DTOs are the only API output.

Validation (Rule)

  • Validation runs BEFORE Flow
  • Flow assumes data is clean
  • Uses Zod schemas

Example Generated Code

Controller (Port)

export class UserPort {
  constructor(private readonly userFlow: IUserFlow) {}

  getById = asyncHandler(async (req: Request, res: Response) => {
    const { id } = req.params;
    const result = await this.userFlow.getById(id);
    if (!result) throw new NotFoundError('User');
    return success(res, toUserResponse(result));
  });
}

Business Logic (Flow)

export class UserFlow implements IUserFlow {
  constructor(private readonly userSource: IUserSource) {}

  async create(dto: UserFlowDto): Promise<UserEntity> {
    const entity = createUserEntity(dto);
    return this.userSource.create(entity);
  }
}

Validation (Rule)

export const createUserSchema = z.object({
  email: z.string().email(),
  password: z.string().min(8),
});

export const validate = (type: SchemaType) => {
  return (req, res, next) => {
    const result = schemas[type].safeParse(req.body);
    if (!result.success) throw new ValidationError('Validation failed', errors);
    req.body = result.data;
    next();
  };
};

What CL-Architecture Is NOT

  • ❌ Not a framework
  • ❌ Not magic decorators
  • ❌ Not beginner MVC
  • ❌ Not a silver bullet

When to Use

Best for:

  • Medium to large projects
  • Long-term backends
  • Team-based development
  • Production systems

Not for:

  • Small scripts
  • Quick hacks
  • One-file APIs

License

MIT