Description
The portfolio module (src/investment/portfolio/) is the most complex domain module with 7 entities, 6 services, 7 DTOs, algorithms, and ML models. However:
- It has its own
guards/ directory that may duplicate or conflict with common/guard/.
- Error handling is not domain-specific — financial operations (rebalancing, optimization) should return structured error responses.
- The 7 entities are all registered globally in
app.module.ts rather than being encapsulated via TypeOrmModule.forFeature() in PortfolioModule.
Direction
- Audit
src/investment/portfolio/guards/ — merge unique guard logic into common/guard/, then delete the local guards directory.
- Add
TypeOrmModule.forFeature([...entities]) to PortfolioModule and remove portfolio entities from the global app.module.ts entity list.
- Create domain-specific exception classes (
InsufficientBalanceException, OptimizationFailedException, etc.) in src/investment/portfolio/exceptions/.
- Ensure all DTOs use
class-validator decorators and are validated by the global ValidationPipe.
Definition of Done
- Portfolio module is self-contained: owns its entities, guards, and exceptions.
- No portfolio-specific entities in the global TypeORM config.
Acceptance Criteria
Description
The portfolio module (
src/investment/portfolio/) is the most complex domain module with 7 entities, 6 services, 7 DTOs, algorithms, and ML models. However:guards/directory that may duplicate or conflict withcommon/guard/.app.module.tsrather than being encapsulated viaTypeOrmModule.forFeature()inPortfolioModule.Direction
src/investment/portfolio/guards/— merge unique guard logic intocommon/guard/, then delete the local guards directory.TypeOrmModule.forFeature([...entities])toPortfolioModuleand remove portfolio entities from the globalapp.module.tsentity list.InsufficientBalanceException,OptimizationFailedException, etc.) insrc/investment/portfolio/exceptions/.class-validatordecorators and are validated by the globalValidationPipe.Definition of Done
Acceptance Criteria
PortfolioModuleusesTypeOrmModule.forFeature()for all 7 portfolio entitiesapp.module.tsglobal entity listsrc/investment/portfolio/guards/directory is removed; any unique logic moved tocommon/guard/class-validatordecoratorsnpm run buildsucceedstest/portfolio/)