I think it’s up to you, and where you are most comfortable deploying the logic.
Drupal is made to be extensible, and via modules it’s pretty straightforward to do custom things. If you build a custom API that the portal invokes… then you’re still going to need to do some customization in Drupal. Less, but still, some. So keep that in mind.
I am not a Drupal or PHP expert, but by following the example of some known good modules I was able to get pretty good at building customizations quickly.