How should I structure NestJS services when one endpoint needs to update multiple entities (e.g., InvestorProfile and TaxProfile)?
10:21 12 Nov 2025

I’m working on a NestJS + TypeORM backend and ran into an architectural question as my codebase evolved.

Initially, I had a simple setup:

  • InvestorProfileController handles PATCH /investor-profile

  • InvestorProfileService updates the InvestorProfile entity

Later, I introduced a new entity and service called TaxProfile (with its own table), and some of the fields that used to live in InvestorProfile were moved there.
Now, when the client calls PATCH /investor-profile, the system also needs to update related fields in TaxProfile.

At the moment, my controller calls both services, which feels like “spaghetti.” For example:

@Patch('investor-profile')
async update(@Req() req, @Body() dto: UpdateInvestorProfileDto) {
  await this.investorProfileService.update(req.user.id, dto);
  await this.taxProfileService.update(req.user.id, dto.tax);
}

This works, but it doesn’t feel like good design—there’s logic spread between two services, and the controller now coordinates multiple domains.

What’s the best practice for handling this kind of cross-entity update in NestJS?

I'm also curious what other frameworks like ruby on rails do in these situations where the domain you're working on evolves. Thanks!

ruby-on-rails rest oop architecture nestjs