Advanced Modular Library Design
Design modular TypeScript libraries using HexDI principles: compile-time dependency validation, feature-first organization, and clean API boundaries.
Introduction
This skill provides architectural guidance for building robust, scalable, and modular TypeScript libraries. By leveraging the HexDI framework, it assists developers in defining strict package boundaries and ensuring type-safe dependency injection at compile-time, effectively eliminating common runtime injection failures. The skill is designed for software architects and senior engineers working in complex monorepos or enterprise-grade TypeScript environments who need to maintain clean, decoupled codebases with high levels of testability and maintainability.
-
Implements compile-time validation of dependency graphs to ensure that service contracts (ports) are satisfied before the application runtime.
-
Promotes a feature-first organizational structure using ports, adapters, and containers to enforce clear module boundaries and reduce circular dependencies.
-
Provides strategies for managing service lifetimes, including singleton, scoped, and transient modes, suitable for diverse requirements like HTTP request contexts or shared infrastructure resources.
-
Facilitates the use of immutable builder patterns for graph composition, enabling easy branching and environment-specific configuration for testing or staging environments.
-
Supports advanced integration patterns for React and Hono, allowing for seamless state injection and dependency resolution within UI or server-side logic.
-
Input: Project architectural requirements, service interface definitions, or existing monolith refactoring tasks.
-
Output: Structured architectural plans, dependency graph configurations, or refactored code patterns adhering to HexDI principles.
-
Practical constraint: Requires TypeScript 5.0+ and a clear understanding of hexagonal architecture principles to be most effective.
-
Users should focus on defining ports first to establish stable contracts, followed by creating adapters to implement logic, and finally composing graphs using the GraphBuilder for type-safe resolution.
-
Best used when transitioning from global state or loose coupling to a strictly validated DI system, or when designing shared library packages in a monorepo to prevent leakage of internal implementation details.
Repository Stats
- Stars
- 8
- Forks
- 0
- Open Issues
- 0
- Language
- TypeScript
- Default Branch
- main
- Sync Status
- Idle
- Last Synced
- May 3, 2026, 10:13 PM