TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-kit-redis-postgres-pgpool-docker/llms.txt
Use this file to discover all available pages before exploring further.
ioc object — exported as the default from src/lib/index.ts — is the single access point for every service in the persistence layer. It bundles all 35 services (3 base, 16 cache, 16 DB) into one plain JavaScript object, resolved through di-kit dependency injection. After the module is first imported, ioc is also attached to globalThis.ioc, so adapter code in setup.ts and any downstream file can reference services without an explicit re-import.
Service Categories
The 35 services are organised into three groups that mirror the architecture of the persistence layer.Base Services (3)
Infrastructure primitives consumed by every other service.
loggerServicepostgresServiceredisService
Cache Services (16)
Redis-backed id-lookup caches, one per domain entity.
candleCacheServicesignalCacheServicescheduleCacheServicestrategyCacheServiceriskCacheServicepartialCacheServicebreakevenCacheServicestorageCacheServicenotificationCacheServicelogCacheServicemeasureCacheServiceintervalCacheServicememoryCacheServicerecentCacheServicestateCacheServicesessionCacheService
DB Services (16)
TypeORM repository wrappers, one per domain entity.
candleDbServicesignalDbServicescheduleDbServicestrategyDbServiceriskDbServicepartialDbServicebreakevenDbServicestorageDbServicenotificationDbServicelogDbServicemeasureDbServiceintervalDbServicememoryDbServicerecentDbServicestateDbServicesessionDbService
Importing and Using ioc
Import the module once at your entry point. All services are synchronously available on the returned object; infrastructure connections are initialised lazily on first use through each service’s waitForInit() method.
Global Access via globalThis
After
src/lib/index.ts is imported for the first time, the ioc object is
also available as globalThis.ioc. This lets adapter implementations in
setup.ts call ioc.postgresService, ioc.signalDbService, and so on
without adding an import statement to every file.src/lib/index.ts:
DI Internals
The container is built on three primitives produced bycreateActivator("pro") from di-kit (src/lib/core/di.ts):
Registration (provide)
Every service is registered in
src/lib/core/provide.ts using provide(token, factory). The factory is a zero-argument function that constructs the service instance:Injection tokens (TYPES)
Each service has a unique
Symbol defined in src/lib/core/types.ts. Symbols act as type-safe injection tokens that prevent accidental token collisions:Resolution (inject)
Each property of
ioc is resolved with inject<T>(token). Resolution is lazy: the factory runs the first time the property is accessed:LoggerService
Every service holds areadonly loggerService = inject<LoggerService>(TYPES.loggerService) field. Out of the box LoggerService is a no-op wrapper — all four methods (log, debug, info, warn) discard their arguments. Wire in a real logger by calling setLogger once at startup:
TypeScript Types
Full TypeScript types forioc and every service class are exported from types.d.ts at the repository root. The declaration file is shipped with the package so consuming projects get complete type information without installing additional dependencies.