# rockhillz/nodecore-kit architecture

> Architecture diagram of the GitHub repository rockhillz/nodecore-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rockhillz/nodecore-kit
- Repository: https://github.com/rockhillz/nodecore-kit

## Overview

#### Purpose and Public Surface
`nodecore-kit` is a TypeScript backend SDK for Node.js services, packaging reusable infrastructure clients, security primitives, transport utilities, and framework-independent helpers. Consumers import its unified public API from `src/index.ts`; domain-level barrels expose subsystem APIs through `src/core/index.ts`, `src/adapters/index.ts`, `src/security/index.ts`, and `src/transport/index.ts`.

#### Layering and Dependency Boundaries
The architecture is explicitly layered: pure core utilities are the foundation; security, adapters, and transport build above them without becoming an application runtime. Adapters receive configuration through constructors rather than reading environment variables, preserving testability and allowing each consuming service to own deployment configuration.
- `src/core/index.ts`
- `src/adapters/types.ts`
- `src/index.ts`

#### Core Foundation
Core supplies shared types, error classes, validation, async control primitives, object/string transformations, and UUID handling. These are the dependency-safe building blocks used across higher-level modules; they should not depend on infrastructure or HTTP frameworks.
- `src/core/types.ts`
- `src/core/error.ts`
- `src/core/async.ts`
- `src/core/uuid.ts`

#### External-Service Adapters
Adapter classes encapsulate operational integrations and lifecycle behavior: Redis caching/data operations, AWS SQS enqueue/long-poll consumption with stopping/DLQ behavior, S3 object operations and signing, scheduled jobs, and pluggable mail delivery. This is the main boundary between application code and external infrastructure.
- `src/adapters/redis.ts`
- `src/adapters/sqs.ts`
- `src/adapters/s3.ts`
- `src/adapters/cron.ts`
- `src/adapters/mailers.ts`

#### Observability and Provider Abstraction
Logging is injectable rather than globally fixed: adapter-facing logger types support `console`-compatible or custom implementations, while Winston provides the included structured logger implementation. Mail delivery likewise separates the `Mailer` façade from SMTP, Resend, and SendGrid providers, enabling runtime provider replacement/fallback.
- `src/adapters/types.ts`
- `src/adapters/loggers/winston.ts`
- `src/adapters/mailers.ts`

#### Security Services
Security is isolated into dedicated services: password hashing and secure token/HMAC/fingerprinting operations, JWT encoding/verification and expiry inspection, plus symmetric encryption/decryption. Callers supply secrets/keys, keeping secret sourcing outside the library.
- `src/security/hash.ts`
- `src/security/jwt.ts`
- `src/security/encrypt.ts`

#### HTTP and Express Integration
Transport provides a typed fetch-based request wrapper with timeout/retry and pagination support, independent of server framework. Express integration is optional and limited to Joi request middleware and direct validation, creating a clear boundary between reusable validation semantics and Express request/response handling.
- `src/transport/http.ts`
- `src/transport/express/express-middleware.ts`
- `src/transport/express/joiValidator.ts`

#### Runtime and Infrastructure
The package targets Node.js with TypeScript compilation. Material external systems are Redis; AWS SQS and S3; SMTP/Nodemailer, Resend, and SendGrid; and Winston file/console logging. It is a library, not a standalone server: consuming services instantiate adapters, register cron/queue consumers, wire optional Express middleware, and own startup/shutdown signal handling.

Main entry points: [`src/index.ts`](https://github.com/rockhillz/nodecore-kit/blob/main/src/index.ts) (Unified exports), [`src/core/index.ts`](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/index.ts) (Core exports), [`src/adapters/redis.ts`](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/redis.ts) (Redis, SQS, S3 and cron), [`src/adapters/types.ts`](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/types.ts) (Adapter contracts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_public_api["Unified exports<br/>package entrypoint<br/>[index.ts]"]
end

subgraph group_core["Core Foundation"]
  node_core_barrel["Core exports<br/>barrel<br/>[index.ts]"]
  node_core_types["Types and errors<br/>core primitives<br/>[types.ts]"]
  node_core_async["Async control<br/>core utility<br/>[async.ts]"]
  node_core_uuid["UUID handling<br/>core utility<br/>[uuid.ts]"]
  node_core_error["Error classes<br/>core utility<br/>[error.ts]"]
end

subgraph group_adapters["Infrastructure Adapters"]
  node_adapter_types["Adapter contracts<br/>types and logger contracts<br/>[types.ts]"]
  node_infra_adapters["Redis, SQS, S3 and cron<br/>adapter suite<br/>[redis.ts]"]
  node_mailer["Mailer façade and providers<br/>mail adapter<br/>[mailers.ts]"]
  node_winston["Winston logger<br/>logger implementation<br/>[winston.ts]"]
end

subgraph group_security["Security"]
  node_security_services["Hash, JWT and encryption<br/>security services<br/>[hash.ts]"]
end

subgraph group_transport["Transport"]
  node_http_client["HTTP client<br/>fetch transport<br/>[http.ts]"]
  node_express_middleware["Express validation middleware<br/>optional Express integration"]
  node_joi_validator["Joi validator<br/>validation adapter<br/>[joiValidator.ts]"]
end

node_consumer{{"Consuming Node.js service<br/>library consumer"}}
node_aws_services[("Redis and AWS<br/>external infrastructure")]
node_mail_providers{{"Mail providers<br/>external services"}}

node_consumer -->|"imports"| node_public_api
node_consumer -->|"supplies config and logger"| node_adapter_types
node_consumer -->|"supplies secrets"| node_security_services
node_consumer -.->|"optionally wires"| node_express_middleware
node_public_api -->|"exports"| node_core_barrel
node_public_api -->|"exports"| node_infra_adapters
node_public_api -->|"exports"| node_security_services
node_public_api -->|"exports"| node_http_client
node_core_barrel -->|"exports"| node_core_types
node_core_barrel -->|"exports"| node_core_async
node_core_barrel -->|"exports"| node_core_uuid
node_core_barrel -->|"exports"| node_core_error
node_infra_adapters -->|"uses contracts"| node_adapter_types
node_infra_adapters -->|"uses async control"| node_core_async
node_infra_adapters -->|"operates"| node_aws_services
node_mailer -->|"uses contracts"| node_adapter_types
node_mailer -->|"delivers through"| node_mail_providers
node_winston -->|"implements logger"| node_adapter_types
node_security_services -->|"uses errors"| node_core_error
node_http_client -->|"uses retry control"| node_core_async
node_express_middleware -->|"delegates validation"| node_joi_validator
node_joi_validator -->|"returns validation errors"| node_core_error

click node_public_api "https://github.com/rockhillz/nodecore-kit/blob/main/src/index.ts"
click node_core_barrel "https://github.com/rockhillz/nodecore-kit/blob/main/src/core/index.ts"
click node_core_types "https://github.com/rockhillz/nodecore-kit/blob/main/src/core/types.ts"
click node_core_async "https://github.com/rockhillz/nodecore-kit/blob/main/src/core/async.ts"
click node_core_uuid "https://github.com/rockhillz/nodecore-kit/blob/main/src/core/uuid.ts"
click node_core_error "https://github.com/rockhillz/nodecore-kit/blob/main/src/core/error.ts"
click node_adapter_types "https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/types.ts"
click node_infra_adapters "https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/redis.ts"
click node_mailer "https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/mailers.ts"
click node_winston "https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/loggers/winston.ts"
click node_security_services "https://github.com/rockhillz/nodecore-kit/blob/main/src/security/hash.ts"
click node_http_client "https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/http.ts"
click node_express_middleware "https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/express/express-middleware.ts"
click node_joi_validator "https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/express/joiValidator.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api toneBlue
class node_core_barrel,node_core_types,node_core_async,node_core_uuid,node_core_error toneAmber
class node_adapter_types,node_infra_adapters,node_mailer,node_winston toneMint
class node_security_services toneRose
class node_http_client,node_express_middleware,node_joi_validator toneIndigo
class node_consumer,node_aws_services,node_mail_providers toneNeutral
```

## Components

### Public API

- [Unified exports](https://github.com/rockhillz/nodecore-kit/blob/main/src/index.ts): package entrypoint · `src/index.ts`

### Core Foundation

Framework- and infrastructure-independent building blocks.

- [Core exports](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/index.ts): barrel · `src/core/index.ts`
- [Types and errors](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/types.ts): core primitives · `src/core/types.ts`
- [Async control](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/async.ts): core utility · `src/core/async.ts`
- [UUID handling](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/uuid.ts): core utility · `src/core/uuid.ts`
- [Error classes](https://github.com/rockhillz/nodecore-kit/blob/main/src/core/error.ts): core utility · `src/core/error.ts`

### Infrastructure Adapters

Constructor-configured integrations for consuming services.

- [Adapter contracts](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/types.ts): types and logger contracts · Supports injectable configuration and logging. · `src/adapters/types.ts`
- [Redis, SQS, S3 and cron](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/redis.ts): adapter suite · Caching, queue consumption, object operations, and scheduled jobs. · `src/adapters/redis.ts`
- [Mailer façade and providers](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/mailers.ts): mail adapter · Selects SMTP, Resend, or SendGrid delivery providers. · `src/adapters/mailers.ts`
- [Winston logger](https://github.com/rockhillz/nodecore-kit/blob/main/src/adapters/loggers/winston.ts): logger implementation · `src/adapters/loggers/winston.ts`

### Security

- [Hash, JWT and encryption](https://github.com/rockhillz/nodecore-kit/blob/main/src/security/hash.ts): security services · Caller-supplied secrets support hashing, tokens, JWTs, and encryption. · `src/security/hash.ts`

### Transport

- [HTTP client](https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/http.ts): fetch transport · Typed requests with timeout, retry, and pagination. · `src/transport/http.ts`
- [Express validation middleware](https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/express/express-middleware.ts): optional Express integration · `src/transport/express/express-middleware.ts`
- [Joi validator](https://github.com/rockhillz/nodecore-kit/blob/main/src/transport/express/joiValidator.ts): validation adapter · `src/transport/express/joiValidator.ts`

### Other components

- **Consuming Node.js service**: library consumer · Owns configuration, lifecycle, and secret sourcing.
- **Redis and AWS**: external infrastructure · Redis plus AWS SQS and S3.
- **Mail providers**: external services · SMTP/Nodemailer, Resend, and SendGrid.

## Connections

- Consuming Node.js service → Unified exports: imports
- Consuming Node.js service → Adapter contracts: supplies config and logger
- Consuming Node.js service → Hash, JWT and encryption: supplies secrets
- Consuming Node.js service → Express validation middleware: optionally wires
- Unified exports → Core exports: exports
- Unified exports → Redis, SQS, S3 and cron: exports
- Unified exports → Hash, JWT and encryption: exports
- Unified exports → HTTP client: exports
- Core exports → Types and errors: exports
- Core exports → Async control: exports
- Core exports → UUID handling: exports
- Core exports → Error classes: exports
- Redis, SQS, S3 and cron → Adapter contracts: uses contracts
- Redis, SQS, S3 and cron → Async control: uses async control
- Redis, SQS, S3 and cron → Redis and AWS: operates
- Mailer façade and providers → Adapter contracts: uses contracts
- Mailer façade and providers → Mail providers: delivers through
- Winston logger → Adapter contracts: implements logger
- Hash, JWT and encryption → Error classes: uses errors
- HTTP client → Async control: uses retry control
- Express validation middleware → Joi validator: delegates validation
- Joi validator → Error classes: returns validation errors
