DEV Community

Discussion on: Does every backend need to be an API?

Collapse
 
andreidascalu profile image
Andrei Dascalu

Well, every frontend needs storage and a way to interact with that storage. That said:

  • if you only have a SPA, then you need to ask yourself what are your storage requirements? Does local storage (with the risk of disappearing) satisfy those requirements?
  • an API is an interface to call some functions. What's customarily called REST API is more of a standard to interact with a web service that in turn deals with some sort of persistence.
  • if you've already settled on postgreSQL for storage, then probably yes, unless you go for MVC you'll probably end up with an API of sorts.
  • MVC is the all in one pattern (think any MVC framework, rails, laravel, symfony, etc - you only have one project). What you mention in the first paragraph sounds more like MVVM, like Angular frontend (or react or whatever).
  • also, not all webservices come with APIs, not all APIs need to be REST (the vast majority aren't, they can be RESTful at most, or REST-like since strictly abiding by REST is way too much overhead)
  • CRUDs never cover all the interactions with data. It's a fairly pointless distinction that's rarely useful in and all by itself.

I believe that @zakwillis is correct.
In addition I would add that regardless how you interact with your data, the result will be an API. It may not manage a webservice, but will still be an API.

Collapse
 
zakwillis profile image
zakwillis

Hi, I think that whilst we have very different angles of attack - we agree.

Awesome.