Best Practices for SPA calling multiple APIs?

Viewed 1740

My team is trying to figure out the best architecture for the problem below. I'd like to be able to find any existing recommendations for our situation, but it's difficult to search.

  • We have an application A with a SPA, ASP.NET WebAPI backend, and a database.

  • We have another in-house WebAPI B for storing and serving files and application-agnostic metadata. B has its own database. This API belongs to our team too, but is meant to eventually be consumed by other applications.

A has a table of A-specific document metadata. These records represent attachments of files to other things in A and contain the IDs of the document records in B

To list attachments for a given item, A frontend gets A document records, then uses the result of the call to A to fetch the rest of the metadata (filename, size, etc) from B


We had an idea to eliminate the second call by duplicating the data returned from an upload to B in A's metadata.

So, my questions are:

  1. Is there any reason not to duplicate the data?
  2. I've had trouble googling it so far—I feel like I'm missing jargon or some term that will get me what I need. Is there a name for this specific architecture topic that will aid me in my searches?

Thanks

2 Answers

I think we can speak of micro service.

For data duplication that's depending how you want to treat it. Your data must always be up to date?

If it's a kind of data, you can duplicate the data into A backend. E.g: A row in invoice

Otherwise, from A backend you call B backend to merge data and you send to your clients (frontend) only useful information.

Your clients must know only one endpoint.

Because, if you have 3 clients (e.g .: website, mobile app, tab app) which have the same feature. Tomorrow, B changes, you have to check your frontend code everywhere.

Whereas, if only A knows B, you change the connection into A. Generally, it's transparent for your clients

Some reads: http://microservices.io/patterns/data/event-sourcing

Related