I have a backend Rails application that is mainly API endpoints and a front-end application that is mainly being built in React.
Consider the following models:
- Panel: is an container element inside a dashboard. It defines dimensions/positions inside the dashboard. It also defines its content using a content_type and a content_id (polymorphic associations).
- Chart / SingleValue / Section: these are all models that can be used as content for the panel.
What I would like to do now is letting the user create a "chart panel" in one step.
I've been wondering for a while now if it is better to:
- Have all the basic CRUD API end-points and manage the panel+chart creation 100% on the front-end. This would mean more complexity on the front-end but fewer API end-points.
- Have an extra API endpoint on the Rails side to create panel+chart/panel+single_value/panel+section (atomic operation). This would mean much less complexity on the front-end but more API end-points.
What would be the ideal approach?