node-hexagonal-api

Implements hexagonal architecture with ports and adapters for TypeScript Node.js backends.

6|Updated May 18, 2026
One-click install
npx skills add https://github.com/mokhtarabadi/cognitive-lead-hq --skill node-hexagonal-api-mokhtarabadi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: node-hexagonal-api
Source: https://github.com/mokhtarabadi/cognitive-lead-hq/tree/main/skill-templates/node-hexagonal-api
Command: npx skills add https://github.com/mokhtarabadi/cognitive-lead-hq --skill node-hexagonal-api-mokhtarabadi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building Node.js backends often leads to tangled code where business logic is coupled to frameworks, databases, and HTTP libraries, making the system hard to test and change. This Skill enforces Hexagonal Architecture (Ports and Adapters) so your core domain stays pure, dependencies point inward, and adapters can be swapped without touching business logic. ## Core Features & Use Cases - Strict Layer Boundaries: Defines a project structure separating core domain, application use cases, inbound/outbound adapters, and a DI composition root, with rules banning framework imports in the core. - Ports via TypeScript Interfaces: Establishes inbound and outbound port contracts (e.g., UserRepository, Clock) with constructor injection, so dependencies fail at composition time rather than in production. - Testing & Governance Guidance: Prescribes vitest unit tests with in-memory port fakes, testcontainers integration tests, UTC datetime governance, and a currency baseline (Node 22, pnpm, zod, prisma). - Use Case: When scaffolding a new TypeScript API, apply this Skill to generate a layered codebase where swapping Postgres for another database only requires writing a new outbound adapter. ## Quick Start Ask the AI to scaffold a new TypeScript Node.js backend using hexagonal architecture with ports, adapters, and a DI container following this skill's structure.

Frequently Asked Questions about node-hexagonal-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Node.js backend with hexagonal architecture?▼

Organize code into src/core (domain entities and port interfaces), src/application (use cases), src/adapters (inbound HTTP and outbound database implementations), and a di/container.ts composition root. Adapters depend on core ports; the core never imports adapters.

What is a port in TypeScript hexagonal architecture?▼

A port is a TypeScript interface defining a contract, such as UserRepository or Clock. Inbound ports describe use cases the application exposes, while outbound ports describe external dependencies the application needs, implemented by swappable adapters.

How do I test use cases without a real database?▼

Write unit tests with vitest using in-memory fakes that implement the outbound port interfaces, using table-driven it.each tests. For adapter-level verification, use testcontainers to run integration tests against real Postgres or Redis instances.

Can I use Prisma with hexagonal architecture?▼

Yes, Prisma belongs in the outbound adapter layer, implementing repository port interfaces. Never leak Prisma models through ports; map them to domain entities inside the adapter, and use prisma migrate rather than db push on shared databases.

Why is new Date() banned in domain code?▼

Direct Date calls make business logic non-deterministic and hard to test. The skill defines a Clock outbound port with a now() method that is injected into use cases, allowing tests to control time and ensuring consistent UTC datetime handling.