Skip to content

Path-IoCSpring has Beans, Nest has Providers, Path-IoC has Mesh

Honoring Spring's foundational philosophy in native TypeScript. Zero decorators, zero reflection metadata, microsecond cold starts, and lock-free Kahn DAG topology.

Path-IoC Logo
Spring has Beans · Nest has Providers · Path-IoC has Mesh

Three Generations of IoC: Async Initialization & Assembly Prerequisite

Real-World Architecture: Module A (remoteConfig) performs an async HTTP handshake on startup to fetch encrypted configuration, exposing a pure synchronous function isEnabled(feature). Module B (orderService) must synchronously invoke Module A's function during its own instantiation to enable or disable features (Module B has an unnegotiable initialization prerequisite on Module A).

spring/AppConfig.javaSpring · Classic @Bean Factory Pattern
java
// Spring: Relies on OS threads to block the startup thread until remote config is fetched
@Configuration
public class AppConfig {

  @Bean
  public RemoteConfig remoteConfig() {
    RemoteConfig config = new RemoteConfig();
    config.initFromRemote(secretKey); // Blocks the current thread until config is ready
    return config;
  }

  @Bean
  public OrderService orderService(RemoteConfig remoteConfig) {
    // Module B synchronously invokes Module A during container wiring
    boolean enableDiscount = remoteConfig.isEnabled("vip_discount");
    return new OrderService(enableDiscount);
  }
}
nestjs/app.module.tsNestJS · Decorator Collapse & useFactory Regression
typescript
// Pain Point: Class constructors cannot await! Using onModuleInit causes race condition silent bugs.
// The OOP @Injectable() class syntax collapses and is forced to regress into verbose useFactory dictionaries:
@Module({
  providers: [
    {
      provide: 'REMOTE_CONFIG',
      useFactory: async () => {
        const config = await fetchRemoteConfig(process.env.SECRET_KEY);
        return { isEnabled: (feature: string) => config[feature] ?? false };
      }
    },
    {
      provide: 'ORDER_SERVICE',
      useFactory: (config: RemoteConfig) => {
        // Module B must write glue code and manually manage string tokens in the fragile inject array
        const enableDiscount = config.isEnabled('vip_discount');
        return new OrderService(enableDiscount);
      },
      inject: ['REMOTE_CONFIG']
    }
  ]
})
export class AppModule {}
src/modules/ (remoteConfig & orderService)Path-IoC · Native Async DAG & Zero-Race Assembly
typescript
// Module A (src/modules/remoteConfig/index.ts): Native async function initialization, returns sync methods
export const main = async () => {
  const config = await fetchRemoteConfig(process.env.SECRET_KEY);
  return {
    isEnabled(feature: string) { return config[feature] ?? false; } // Data ready in closure, pure sync!
  };
};

// Module B (src/modules/orderService/index.ts): Declare short-name dependency, consume synchronously
export const dependencies = ["remoteConfig"];

export const main = (container: ModularContainer) => {
  const { remoteConfig } = container;
  // Topological engine guarantees: remoteConfig's async task is 100% resolved before waking up orderService!
  const enableDiscount = remoteConfig.isEnabled("vip_discount");

  return {
    createOrder(item: string) {
      return { item, price: enableDiscount ? 80 : 100 };
    }
  };
};
Performance Benchmark

Hardware-Verified Benchmarks (Apple M5 / Node 24)

View Detailed Methodology →
50-Node Instantiation
21.2 µs
Microsecond-level direct container resolution. Zero request-time latency in serverless runtimes.
500-Node Graph Compilation
1.72 ms
Single cold-boot Kahn cycle validation, then 100% cached across high-frequency requests.
Core Engine Footprint
8.8 KB
Pure ES module closures. Zero external dependencies and zero reflect-metadata overhead.
Production SaaS Boilerplate

Build Global Edge Products with Path-IoC Pro

Full-stack commercial starter kit integrating Cloudflare Workers, Hono, React 19, Path-IoC, Tailwind CSS, Stripe Global Payments, and D1 Database. Launch your SaaS in days instead of months.

Released under the MIT License.