mardi 12 décembre 2017

Where should data processing and transformation happen?

I'm using Angular 4 as my front-end framework and basically just asp net core as an API for the client to get data from and occasionally post data.

I'm making a dashboard to display some statistical data. The data that I have in the database is not directly usable for this dashboard as it needs to be transformed and further processed. I'm not returning the model entity to the API but a View Model which is basically the same as the model entity with some ids removed etc.

What I have right now is that my Angular DashboardComponent is using a DataService to construct a HTTP GET request which points to my already existing API endpoint GetOrders. This will get all orders from the database and return it to the DataService and eventually the DashboardComponent which then needs to extract data and do a whole lot of processing and transformation so the data is ready to be given to Google Chartsand meaningful charts can be generated. Then the user can choose to see another chart on the dashboard which then is not enough to just have the Orders but another entity must also be retrieved from the database, so repeating above API call using a different end point.

My question boils down to:

  • Is it best to do all of the processing and transformation on the server side and return data to the client which is almost ready to be presented, or is it fine to leave the client with this task?
  • In case of server side processing and transformation, should I construct it in such a way that I have API endpoints that corresponds to the type of data that I want to show in the dashboard? So, selecting for example "Orders in the last 3 months in the UK" would send a request to an API endpoint that specifically takes parameters such as country and period?
  • Maybe the data should already be in the shape I can use for the dashboard via some sort of datawarehouse? Is this the way to go with this?

In general I'm looking for some design patterns on this or just best practices, but haven't really been able to find something.

Aucun commentaire:

Enregistrer un commentaire