I'm building an application related to donation on streams.
And I have such models as "alert" and "alert-template".
"alert" is a set of different parameters to understand when alert about donation should be displayed.
"alert-template" is a visual config for the "alert" (image, audio, positioning).
At the end, on stream, it should look like this:

enter image description here

And I'm working now on the streamer part, where he can manage these alerts.
I have a page /alerts and on this page I need to request all alerts for the user including alert-template.

In which way should it be done?

  • create a backend that is able to process route like api/alerts?include="alert-template"
  • create a backend focused directly to pages of the frontend application and then route api/frontend/alerts will contain already all needed data including alerts and alert-templates
  • create a backend that just has 2 separate routes for alert and alert-template and somehow handle it in this way

I tried to find any information on the internet about how to handle nested objects in api and tried to understand whether it is normal practice to have them, but unfortunately, there was not much info about it.

1 Answer 1


You can get things to work either way. This question is more about semantics. I like to separate REST APIs from presentation-related APIs, like a Backend-For-Frontend. There is no rule, law, or edict that declares this. This is simply my preference.

A BFF is typically created to aggregate multiple calls to individual REST APIs, and provides a data structure to the client that is easier to consume. This could be in JSON, XML, or HTML format.

This has several advantages:

  • Your REST APIs can evolve independently of your clients. Only the BFF needs to be adapted.
  • The REST endpoints can adhere to REST semantics.
  • Your BFF can evolve independently of your REST APIs, and only the clients need to adapt.
  • Your BFF can adhere to whichever semantics make sense for the client.

Sure, you've got your BFF making REST calls on behalf of the client, but the client's job should be simpler as a result.

So really, my recommendation is "D) None of the above." Keep the REST and BFF separate, and have the BFF call the REST endpoints. The BFF can do any translation it wants for these alerts. You get the best of both worlds at the expense of one service calling another.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.