Skip to content

Features & Implementation Roadmap

TDI2 follows Spring Boot conventions for familiar enterprise patterns. This guide covers implemented features, roadmap items, and production readiness assessment.

📋 Architecture Context: See ADR-005: Spring Boot Conventions for why TDI2 adopts Spring Boot patterns.

TDI2 addresses fundamental scalability issues in React’s original architecture. React was designed as a declarative UI library for small to medium applications. However, as complexity and size increase, different requirements emerge: modularity, exchangeability, testing, and environment-based configuration gain importance. The idiomatic React model (Props, Context, Hooks) no longer scales systematically in these scenarios.

Hard Coupling Through Direct Imports: Components reference services directly via import, eliminating exchangeability.

Props Drilling and Manual Composition: Data and function passing across multiple component levels creates structural dependencies and redundancy.

No Central Lifecycle or Dependency Management: React offers no native way to centrally register, profile, or scope services.

Testing and Mocking Fragmentation: Mocks must be manually injected or replaced through global store adjustments.

No Environment or Profile Concept: React lacks service-based environment configuration (Test vs Prod) at the architecture level.

  • Compile-Time Resolver for dependencies
  • TypeScript Metadata utilization for automatic injection
  • Hooks as Injectable Interface (useService)
  • Profile and Scoping Support for environment configuration
  • OpenTelemetry, Logging, Linting and Debugging support (planned)
  • Build-Time Resolution instead of runtime for maximum performance
Application Layer
├── Controller Components
│ └── useService(InvoiceService)
├── UI Components
│ └── Presentational only
Domain Layer
├── Interfaces (e.g. InvoiceService)
├── Logic (e.g. DefaultInvoiceService)
Infrastructure Layer
├── HttpAdapters
├── Mock Implementations
  • Enterprise React Applications with high complexity
  • Teams requiring exchangeable infrastructure
  • Projects with multiple environments and profiles
  • Applications with strict testing and logging requirements
FeatureDescriptionImplementation StatusSpring Boot Equivalent
@ServiceService registration decorator✅ Complete@Service, @Component
@InjectDependency injection decorator✅ Complete@Autowired
Compile-Time DI ResolverBuild-time dependency resolution✅ CompleteN/A (TDI2 innovation)
TypeScript MetadataAutomatic injection via TS types✅ CompleteN/A (TDI2 innovation)
useService HookInjectable service interface for React✅ CompleteN/A (React-specific)
Interface ResolutionAutomatic interface → implementation mapping✅ CompleteType-based autowiring
ContainerDI container with lifecycle management✅ CompleteApplicationContext

These features were recently completed and are now production ready:

FeatureDescriptionImplementation StatusSpring Boot Equivalent
@PostConstructPost-construction lifecycle hook via onInit✅ Complete@PostConstruct
@PreDestroyPre-destruction lifecycle hook via onDestroy✅ Complete@PreDestroy
@ProfileEnvironment/profile-based service activation✅ Complete@Profile
@ConfigurationConfiguration class decorator✅ Complete@Configuration
@BeanBean definition decorator✅ Complete@Bean
Lifecycle HooksonMount/onUnmount for component lifecycle✅ CompleteN/A (React-specific)
FeatureDescriptionImplementation StatusSpring Boot Equivalent
@DiTestDI testing framework equivalent✅ Complete@ExtendWith(SpringExtension.class)
@MockBeanMock bean for testing✅ Complete@MockBean
Testing UtilitiesAdvanced mock and test container utilities✅ Complete@TestConfiguration

📋 Future Enhancements (Future Releases)

Section titled “📋 Future Enhancements (Future Releases)”
FeatureDescriptionImplementation StatusPriorityETA
ESLint PluginRule verification for DI patterns❌ Research phaseLowQ1 2025
OpenTelemetry IntegrationDistributed tracing support❌ Research phaseLowQ1 2025
DevTools IntegrationBrowser debugging interface❌ Research phaseMediumQ1 2025
SSR CompatibilityServer-side rendering support❌ Research phaseHighQ2 2025
Hot Module ReplacementHMR support for services❌ Research phaseMediumQ2 2025
// Basic service registration
@Service()
export class ProductService implements ProductServiceInterface {
state = { products: [] as Product[] };
}
// With explicit scope
@Service()
@Scope("singleton") // Default behavior
export class ConfigService {
// Single instance across application
}
@Service()
@Scope("transient") // New instance each injection
export class RequestLogger {
// Fresh instance for each component
}
// Interface-based injection (recommended)
@Service()
export class OrderService {
constructor(
@Inject() private paymentService: PaymentServiceInterface,
@Inject() private emailService: EmailServiceInterface,
@Inject() private logger?: LoggerServiceInterface // Optional dependency
) {}
}
// Functional component injection
function CheckoutFlow({
orderService,
paymentService
}: {
orderService: Inject<OrderServiceInterface>;
paymentService: Inject<PaymentServiceInterface>;
}) {
// Services automatically injected via build-time transformation
}

Current Status: ✅ Complete - Implemented via onInit interface

@Service()
export class DatabaseService {
private connection: Connection | null = null;
@PostConstruct
async initialize(): Promise<void> {
// Called after all dependencies injected
this.connection = await createConnection(this.config);
console.log('Database connection established');
}
constructor(
@Inject() private config: DatabaseConfig
) {}
}

Implementation Plan:

  • Phase 1: Container calls @PostConstruct methods after instantiation
  • Phase 2: Support async initialization with dependency ordering
  • Phase 3: Error handling and initialization retry logic

Current Status: ✅ Complete - Implemented via onDestroy interface

@Service()
export class CacheService {
private cache = new Map();
@PreDestroy
async cleanup(): Promise<void> {
// Called before service destruction
this.cache.clear();
await this.flushPendingWrites();
console.log('Cache service cleaned up');
}
}

Implementation Plan:

  • Phase 1: Container calls @PreDestroy on application shutdown
  • Phase 2: React component unmount cleanup integration
  • Phase 3: Graceful shutdown with timeout handling

Current Status: ✅ Complete - Full profile filtering and environment-based activation

@Service()
@Profile("development")
export class MockEmailService implements EmailServiceInterface {
sendEmail(to: string, message: string): Promise<void> {
console.log(`Mock email to ${to}: ${message}`);
return Promise.resolve();
}
}
@Service()
@Profile("production")
export class SmtpEmailService implements EmailServiceInterface {
sendEmail(to: string, message: string): Promise<void> {
return this.smtpClient.send({ to, body: message });
}
}
// Multiple profile support
@Service()
@Profile(["staging", "production"])
export class RedisCache implements CacheServiceInterface {
// Only active in staging or production
}

Implementation Plan:

  • Phase 1: Environment-based profile activation (NODE_ENV)
  • Phase 2: Custom profile configuration and runtime switching
  • Phase 3: Conditional profiles with expressions

Current Implementation:

@Configuration()
export class DatabaseConfiguration {
@Bean()
@Profile("development")
createDevDatabase(): DatabaseConnection {
return new SqliteConnection('dev.db');
}
@Bean()
@Profile("production")
createProdDatabase(
@Inject() config: EnvironmentConfig
): DatabaseConnection {
return new PostgresConnection({
host: config.DB_HOST,
port: config.DB_PORT,
database: config.DB_NAME
});
}
@Bean()
createConnectionPool(
@Inject() database: DatabaseConnection
): ConnectionPool {
return new ConnectionPool(database, { maxConnections: 20 });
}
}

Benefits:

  • External library integration without wrapping
  • Environment-specific bean creation
  • Method-level dependency injection
  • Factory pattern support

Core DI Functionality:

  • Service registration and dependency injection
  • Interface-based resolution
  • Singleton and transient scopes
  • Type-safe container operations
  • React component transformation
  • Testing framework integration

Code Reduction Impact:

  • 90-95% reduction in AST transformation boilerplate
  • 80-85% reduction in manual dependency wiring
  • 70-75% reduction in prop drilling code

Performance Characteristics:

  • O(1) service lookup via compile-time resolution
  • Zero runtime reflection overhead
  • Tree-shakable service registration
  • Memory efficient singleton management

🚧 Production Blockers (Address Before Enterprise Use)

Section titled “🚧 Production Blockers (Address Before Enterprise Use)”

Recently Resolved Production Blockers:

  1. Lifecycle Management ✅ Complete

    • Resolution: @PostConstruct/@PreDestroy implemented via onInit/onDestroy interfaces
    • Status: Production ready with full async support
  2. Configuration Management ✅ Complete

    • Resolution: @Configuration and @Bean decorators fully implemented
    • Status: Factory patterns and method-level injection working
  3. Testing Framework ✅ Complete

    • Resolution: Full testing utilities with @DiTest and @MockBean equivalents
    • Status: Production ready testing infrastructure

Nice-to-Have Enhancements:

  • Enhanced debugging and introspection tools
  • React DevTools integration
  • Advanced scoping models (request, tree, component)
  • Server-side rendering support
  • Automatic code-splitting integration
  1. @PostConstruct runtime support ✅ Complete

    • Container calls lifecycle methods after instantiation
    • Async initialization support
    • Error handling for initialization failures
  2. @PreDestroy runtime support ✅ Complete

    • Application shutdown lifecycle
    • Component unmount cleanup integration
    • Graceful shutdown with timeout
  3. @Configuration and @Bean support ✅ Complete

    • Configuration class processing
    • Method-level dependency injection
    • Factory pattern support
  1. @Profile runtime implementation ✅ Complete

    • Environment-based activation
    • Multi-profile support
    • Runtime profile switching
  2. Testing framework ✅ Complete

    • @DiTest equivalent functionality
    • @MockBean implementation
    • Advanced mocking utilities
    • Integration test helpers

Next Sprint (Advanced Features - 2-3 weeks)

Section titled “Next Sprint (Advanced Features - 2-3 weeks)”
  1. Tree-scoped providers

    • React tree integration
    • Provider boundary management
    • Multi-tenant service isolation
  2. SSR preparation

    • Request-scoped containers
    • Server/client state synchronization
    • Hydration safety measures

Current codebase uses sophisticated TypeScript AST manipulation:

  • 800+ lines reduced to 50-100 lines with optimized libraries
  • ts-query + ts-morph recommended for 90% code reduction
  • jscodeshift as fallback for complex transformations
  • Singleton management with lazy instantiation
  • Circular dependency detection with clear error messages
  • Interface-based tokens prevent naming collisions
  • Compile-time validation catches configuration errors
  • Functional component transformation at build time
  • useSnapshot integration for reactive state updates
  • StrictMode compatibility with idempotent factories
  • Hot reload support with development mode optimization

Phase 1: Start with new features using TDI2 patterns

// New feature uses TDI2
@Service()
export class NewFeatureService {
// Implementation with DI patterns
}
// Existing components unchanged
function ExistingComponent() {
// Keep current patterns during transition
}

Phase 2: Gradually refactor complex components

// Before: Complex component with multiple concerns
function ComplexComponent() {
const [users, setUsers] = useState([]);
const [loading, setLoading] = useState(false);
// ... 50+ lines of state management
}
// After: Simple template with service injection
function ComplexComponent({ userService }: { userService: Inject<UserServiceInterface> }) {
const { users, loading } = userService.state;
return <UserList users={users} loading={loading} />;
}

Phase 3: Enterprise-wide adoption with team training and guidelines

  1. Start Small: Begin with isolated features or new components
  2. Team Training: Ensure developers understand DI patterns and service design
  3. Testing Strategy: Implement comprehensive service and integration testing
  4. Performance Monitoring: Track bundle size and runtime performance impacts
  5. Gradual Rollout: Phase adoption across team and application areas
  6. Documentation: Maintain clear service interfaces and usage examples

The current implementation provides a solid foundation for enterprise React applications, with the lifecycle management features completing the production readiness requirements.

TDI2 aims for the structural reorganization of reactive architectures, without undermining React’s declarative foundation. The approach is deliberately systematic, not idiomatic – as a bridge between conventional frontend and architecture-driven software development.

This systematic approach addresses the gap between React’s component-centric model and enterprise-scale application requirements, providing a foundation for scalable, testable, and maintainable React applications that align with established software engineering principles.