Skip to content

Align investment/portfolio Module — Isolate Guards, DTOs, and Error Handling #10

Description

@grantfox-oss

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

  1. Audit src/investment/portfolio/guards/ — merge unique guard logic into common/guard/, then delete the local guards directory.
  2. Add TypeOrmModule.forFeature([...entities]) to PortfolioModule and remove portfolio entities from the global app.module.ts entity list.
  3. Create domain-specific exception classes (InsufficientBalanceException, OptimizationFailedException, etc.) in src/investment/portfolio/exceptions/.
  4. 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

  • PortfolioModule uses TypeOrmModule.forFeature() for all 7 portfolio entities
  • Portfolio entities are removed from app.module.ts global entity list
  • src/investment/portfolio/guards/ directory is removed; any unique logic moved to common/guard/
  • At least 2 domain-specific exception classes exist and are used in portfolio services
  • All portfolio DTOs have class-validator decorators
  • npm run build succeeds
  • Portfolio tests pass (test/portfolio/)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions