Ask HN: Entire API and DB generator from model definition
Our current process for building these out is to build a swagger definition with a mock service backend in js to unblock upstream clients like web and mobile. From there we go an implement the real API in python/flask with postgres.
It got me thinking that probably 80-90% of all the code written for the real API is boilerplate setting up models, db migrations, routes, controllers, authentication etc.
I am imagining that a fair bit of this could be automated, all you really need is a modal definition, and you could generate all of the above, abstracting all that away from the engineer. Providing hooks for inserts and updates would allow for custom business logic to slot in, and would be all the real code engineers would need to write.
What else am I missing that backend developers would want from a framework (or managed service) like this?
5 comments
[ 4.5 ms ] story [ 25.3 ms ] threadHowever, this approach usually doesn’t work for more “system” level products.
Check out Model-Driven Architecture [1]. Most likely you’ll be able to configure an MDA toolchain to generate the code you want
[1] MDA https://en.wikipedia.org/wiki/Model-driven_architecture
What do you mean by "system" level products?
I would envision this would make sense for microservice style APIs, not so much for client/product facing interfaces like an API tied to a web front end
Usually, the frameworks themselves, “servers,” “engines,” and “drivers” would not be easy to generate with the MDA approach. I imagine, apps and games with highly customized UI/UX would not be a good fit either.
MDA is for “boring” business apps where you would want all your screens look the same unified way. That’s where MDA shines, cuts down coding and QA effort, and allows producing massive products with many hundreds of tables and screens.
If you need help, you can have a free consulting call with me.
https://calendly.com/laurenslang/15min