Ask HN: Hunting for a Framework

64 points by JaFu0815 ↗ HN
Hello HN!

My primary background is in desktop development and my knowledge of web development is a little rusty by now. I know about Node.JS, Angular, React, Express and the like and have done a few small projects with these technologies. So far, I have implemented the below requirements for each project myself or copied them from previous projects. Now I am looking for a reasonable fullstack framework with the following requirements:

- A central definition of data schemas. I don't want to define my schema or validation twice, once in the frontend and once in the backend.

- Automatic generation of REST endpoints. I hate boilerplate code and don't want to reimplement Get/GetOne/Add/Update/Delete and Websocket for each data model. Even better would be a GraphQL interface.

- Authorization and Authentication

- No manual HTTP calls for standard cases. I want to define my model at the server and have the data available in an array at the client. As soon as a client inserts a record in his list I want that automatically a POST with the new record is sent to the server, it verifies the model and the authorization and inserts the record into the database. Then the server notifies the other clients about the change using websockets. The other clients see the new data record in their array without having to write a single manual HTTP call or websocket connection.

- Open Source Only. No Firebase or similar.

I've been searching for a while, but haven't found anything that seems reasonable. If I don't find anything I will write a small framework myself. I apologize if I seem lazy and don't want to search myself, but I'm really getting desperate. I want to spend as little time as possible on writing boilerplate and instead write business logic. There are thousands of javascript frameworks out there but none of them seem to handle these simple standard cases very well. They all require manual implementation of CRUD for each model or manual data fetching and subscription. Please make suggestions for frameworks and help me to see through the framework jungle!

69 comments

[ 5.1 ms ] story [ 135 ms ] thread
I'm currently involved in something similar, shoot me an e-mail if you want to learn more

meanwhile, try: Hasura, postgraphile or RedwoodJS

if you want a lower-level framework: tRPC, GraphQL Yoga

recently, there's also grafbase.com

Founder of Grafbase here. We are currently in private beta, but at working closely with the community on our way to public beta. Ping me in our Discord if you want to chat!
Not a framework but I'm tinkering with the following stack:

1. Hasura - DB + Basic APIS

2. Ory.sh for Auth/Authz

3. React on the frontend

4. Windmill.dev for Scheduling/Batch processing/ Background tasks

5. Docker for deployment

6. Fastify + Node JS for glue code (can use Windmill for Glue code too)

I have used Hasura extensively at 2 companies. It's well done and saves a ton of time.

You might also want to look at Retool (and its open-source alternatives). Web dev has become simpler now.

----

If you like code-focused solution: Rails, Laravel and Django are good options.

> 1. Hasura - DB + Basic APIS, 2. Ory.sh for Auth/Authz

Great choices!

3. React on the frontend

Here I'd go with Elm, and a generated GraphL API client. Here an example to play with (which btw also includes ZomboDB for ElasticSearch integration into Postgres)

https://github.com/cies/low-code-backend-dockered

> 4. Windmill.dev

Look awesome, never heard of it. Tnx

> If you like code-focused solution: Rails, Laravel and Django are good options.

I think Kotlin/KTor, while not as full featured, is a much better alternative due to the strong typing discipline.

Wohah, did not know about elm-graphql! I'm a big fan of functional programming and have written minor projects in elm, but the "slowness" of development has always discouraged me from actually doing something big with it. This stack might make this a whole lot better. Will look into it. Thanks
I tried it and it is INSANE how you can just focus on the UX/features and not have to worry about the boilerplate.

This is not just FP, this is "no runtime errors possible" FP.

With Elm-GraphQL your QUERY BUILDER is even fully type safe!

Robust productivity for the masses.

I am loving Hasura so far. However, I am getting stuck with how to best write custom logic on top of this. For example: I have a products table, which Hasura will automatically generate schema for. But now I want to do a custom getProducts GraphQL query to do more advanced filtering (search, sort, ranking etc). What I end up doing it to have a remote schema. And now my clients need to understand two different product types (one generated by Hasura, and one generated by my custom remote schema. Do you have any advice on how to best resolve this?

On top of that, do you typically parse these Hasura Apollo into your client models? Or do you use the fragments directly in UI code since it already support types.

Are any of your Hasura apis used for public APIs? For internal only APIs, hasura is great. But I wanted to craft a public api with a particular schema, but that leads to difficulties because it’s all database driven. It reveals too much internal workings.
I would recommend Django, but it's really only the backend half of what you're looking for.

What you're describing sounds very nice though.

I've often wanted a VB6 equivalent for the web, but open source.

pretty sure anvil is open-source now.

https://anvil.works/

open source.

https://anvil.works/open-source

i should be a paid for how much i recommend looking at them, but i've never used it for anything production.

I'm not fully sure but maybe Blazor (.NET) could suit your needs?

I have no idea what the status of MeteorJS is, but looks like it could fit your requirements.

(comment deleted)
Consider OpenAPI for the first two points - you can define a schema (YAML or JSON) and use it to generate both server & client stubs.

Depending on the language/framework used it'll validate too - e.g. the python backend framework connexion (a thin wrapper around flask) will 500 if you return a non-conforming response, and 400/405/etc. if the request doesn't fit the declared schema, automatically.

You could consider LiveView but you would need to learn Elixir and the Beam.
After looking for enough time, it may be worth it to make some compromises, pick one and try building your application with it.

You may never find “the” framework.

Lately my default has been AspNet Core and C# (or F# if I’m feeling frisky). Not because it’s the ultimate framework for me (although it _is_ very good), but it’s what I learned, thanks to learning on the job.

I remain a microsoft skeptic though. I continue to dabble in other tooling just in case they lock down the framework or tools in the future. I like django, for example.

I am in a similar situation. I have written most backends in AspNet Core, mostly because C# is usually my go-to language. I have looked into Blazor a bit. There are some aspects it does well and writing frontend in C# is very appealing to me, however, the way of datafetching is not the most elegant, as far as I have seen and can judge.
I’ve been using razor pages. For me it takes the abstractions I enjoyed with aspnet MVC, with less of the boilerplate- controllers, etc
Remix, zod, tRPC(if/when API endpoints are needed), Typescript, Prisma. This stack is gorgeous. Same language and type definitions front to back is a game changer.

The realtime aspect of what you are looking for is the hard part. The only options I know of are the remix stack above (you still have to do some extra plumbing), elixir/Phoenix (or other turbo links like options but most aren't fast enough). To do realtime updates natively you need to move to evented data front to back and that is a very big move away from models the way we normally think of them. Check out eventide or resolv.js.

> elixir/Phoenix (or other turbo links like options but most aren't fast enough

Phoenix specifically doesn't work like turbolinks. LiveVIew in Phoenix uses a websocket to transport data, morphdom to patch the dom, and a light process on the server to manage state. It's as fast as the internet connection for insertions into a list. In fact it is quite capable of parallel data loading just like remix, and the server can work share in parallel across as many cores as you have available on the server.

How many concurrent connections can elixir handle on an average 5 year old xeon e3 with 32gb RAM?
Probably a lot depending on your workload. Here's a 2015 article about getting to 2 million concurrent connections[1] with Phoenix channels. They used a bigger rack space box, but it was 7 years ago and Phoenix and Elixir have both improved a lot here. Here's another example of someone hitting a laptop with 840,000 connections[2] on an intel mac with the following specs:

> 2.5 GHz Quad-Core Intel Core i7 16 GB 1600 MHz DDR3

Obviously memory starts to be a constraint for doing anything meaningful, but you can squeeze a lot out of 32gb of ram.

[1]https://phoenixframework.org/blog/the-road-to-2-million-webs...

[2]https://josephmate.github.io/2022-04-14-max-connections/

Aside from replacing Remix with Next.js, this is also what I would recommend.

Remix makes things that were simple hard (apparently with the goal of doing _everything_ on the server again).

create-t3-app is a great starting point for folks going this path. Has optional checkboxes for db/ORM/migrations (prisma.js), auth/sessions (next-auth.js), tailwind CSS, typed client/server communication (trpc).

https://create.t3.gg/

https://github.com/t3-oss/create-t3-app

I hadn't touched much webdev for a few years, the ecosystem / build tooling has gotten a LOT better. It's back to being fun and painless to spin up a new webapp.

A few hours ago, I tried to setup trpc using recommended boilerplate, I also tried fresh default T3 after that.

Both got error, which seems to be due to next/next auth dependency breaking. So it's not that painless I guess.. I found this situation quite often with nextjs example template

T3 author is very responsive though, so my issue resolved quickly

I can speak to a handful of things Remix needs to improve, but "makes things that were simple hard" is a very big generalization. Remix nets out for me big time. I've never been as productive with another framework. Also, remix does SSR but so do a lot of frameworks, is that what you mean when you say "__everything__ on the server again"??
Sadly there is no single good framework for this.

You can better fo with Remix+prisma. You probably don't need REST endpoints just fetch, post using remix.

Honestly, it sounds like you're describing Rails without saying Rails.

Is there a specific reason that you need to have an SPA framework?

^ This. Rails or even some mixup of Laravel with liveview. If OP is needing it for a personal project, just buy a starter template kit in one of these languages.

Do NOT make your own framework, that is a doom loop of death. Lots of smart (and not smart) people have created frameworks for you..... focus on productivity only.

Would RedwoodJS cover what you need?

You put Firebase in with open source only - would you consider an open source Firebase like Supabase? You can host it yourself and it’s open source.

Check out Elixir/Phoenix LiveView tech. It is the only easy system that will push updates to clients easily I can think of. Their twitter clone demo is cool anyhow.
Vapor[0] based on Swift. Advantage of this is that you don't have to evaluate multiple frameworks for Swift and suffer paralysis by analysis. All the Swift community is behind one framework.

The next is Actix[1] based on Rust. There are many frameworks in Rust and most of them have not reached 1.0 And which framework will survive becomes a question.

Other not so well-known is Wt[2] based on C++. This actually is created for programmers who are not web developers. The development experience is similar to desktop app development like Qt.

If that is not acceptable then Django[3], based on Python, is the one that will be good for you.

For the front-end I would recommend Flutter[4]. As much as I dislike getting tied to a single company for whom the framework is not their bread-and-butter, I don't see any other viable options to Flutter that will cover all web, mobile and desktop out of the box.

For databases, I would recommend BedrockDB[5], if you are not averse to SQLite. Or FoundationDB[6], if you want NoSQL. But if you are not concerned about horizontal scalability or okay with self-managing database availability, then PostgreSQL[7] is a very good option.

For push notifications, PushPin[8] is a good option.

[0] https://vapor.codes

[1] https://actix.rs

[2] https://webtoolkit.eu

[3] https://www.djangoproject.com

[4] https://flutter.dev

[5] https://bedrockdb.com

[6] https://www.foundationdb.org

[7] https://postgresql.org

[8] https://pushpin.org

When it comes to Authentication and Authorization, these are both core components of a system but undifferentiated building blocks so wouldn’t recommend building them yourself.

Typically using something like Auth0, Cognito, Firebase Auth, FusionAuth, Clerk or many of the other authentication services will get you a full feature set for user management with little to no work.

On the authorization front consider a similar approach of decoupling the the component out of your codebase where the permissions logic is defined as policy rather than code. I work on Cerbos[1] which is an open-source, decoupled authorization layer for your software which does exactly this.

[1] https://cerbos.dev

I could not disagree more — allowing a third party to own the most crucial data in your app (the users) is a big mistake. I’ll admit to only having experience with Firebase for third-party auth, but in my experience the drawbacks of splitting auth and user related code between two systems soon outweighs the benefits of getting up and running quickly.

Auth code is undifferentiated, but if you have experience building apps it’s also not particularly difficult. I’d recommend either picking an open source solution that you host yourself or just taking a few days to grind it out.

I want to disagree with both of you - the sweet spot is often 3rd-party authN, 1st-party authZ:

* don’t try to implement the hard/annoying bits (strange access detection, account recovery, sending emails, password storage)

* keep ownership of your user list and users’ capabilities

I disagree with all three of you.

It depends on the use case.

Apollo server on Express + Mongo can give you all of the above except "No manual HTTP calls for standard cases.", But I suggest watching a simple guide about those as it need some adjustment (like running yarn task of a watcher to fetch types from server to the client ect.)
Hi, you should check Herbs JS [1]. No frontend, but all the backend requirements (and more) checked.

[1] https://herbsjs.org/

Disclaimer: Herbs JS author here

As wonderful as a fully automated full stack framework would be, you might be hoping for too much magic here. Building distributed systems is fundamentally different to working locally and you can’t escape some of the extra complexity that comes with it.

For example, if you don’t want to make any manual HTTP requests to fetch data then the logical alternative is to fetch it automatically. What should be the trigger for your ideal framework to do that? Without any extra information, the framework can only know you need the data when your other code asks for it. It will have to fetch everything on demand, in real time, and that could be extremely inefficient both in terms of the number of requests you’re making over your HTTP channel and the database queries that will ultimately run on your servers. Even if the framework somehow has perfect caching on the client side and it pushes notifications when cached data needs to be refreshed, there will still be questions around which notifications to push to which clients, because in general the server will have no way to know which data that was requested earlier is still relevant to each client at some later time.

You’d also like updates sent to the back end automatically when you change your front end data structures, and not only that, you’d like them propagated out to other clients automatically as well. How would your ideal framework manage what is now shared mutable state? For example, maybe there are constraints in your data model and you need transactional behaviour that updates multiple data points at once to avoid violating those constraints. In general, the framework can’t know when you’ve finished making a set of related changes that should be batched up and sent back to the server, unless you tell it explicitly. And when you do, how would your ideal framework resolve conflicting updates if multiple clients are sending incompatible changes around the same time? What happens if communication links break down and you have to deal with the CAP Theorem? There are no universal “right answers” to any of these questions, and the behaviour you want will often be highly specific to an individual application and its particular data model.

I fear the reason you haven’t found what you’re hoping for is that no framework exists that can magic away all these practical questions about building a distributed system. Even specifying the required behaviour in a realistic application is a non-trivial problem, never mind implementing that specification once you’ve decided what it should be.

So for whatever it’s worth, my advice would be to lower your expectations a little. It’s very reasonable to want a single source of truth for your data models and to generate the types and the simple cases for REST/GraphQL endpoints, DB queries, HTTP request wrappers on the client, API documentation, etc. It’s also very reasonable to want some standard mechanism for authentication and authorisation checks, possibly using middleware in your own code or other facilities provided by any cloud hosting service you’re using, that can be applied on top of the above. But maybe look for a starting point that can handle a lot of the boilerplate for you and leave you free to concentrate on the more difficult questions, rather than hoping to achieve everything you described out of the box.

I'm working on a framework in Ruby that uses Haml for templating. It is inspired by React and has a VDOM, but it's 100% server side and DOM-patches are streamed to the browser as state updates on the server. Callback handlers are just POST-requests and they are set up like this:

   ruby:
     def self.get_initial_state(initial_count: 0, **) = {
       count: initial_count
     }

     def handle_click
       update do |state|
         { count: state[:count] }
       end
     end

   %div
     %p Current count: #{state[:count]}
     %button(onclick=handle_click) Increment
I don't know if anyone would be interested in using anything like this.
I’m pretty sure there will be interest in this. I like working with FE frameworks but a lot of Rubyists don’t. Ideally many devs just want to work with haml/slim/erb and have an interactive UI without any writing any JS. Your example is really nice because it avoids an entire layer of FE state management / synchronisation. Not sure how much overlap there is with Hotwire as I haven’t really looked into it yet.
Phoenix LiveView. Some learning curve, but once it clicks, you’ll understand there’s very little reason to use anything else for web apps.
I think...Rails is what you're looking for.

Reactivity is not an issue anymore with the HOTWIRE stack in rails or there's the even better StimulusReflex gem that you can use for reactivity and realtime features.

Ruby on Rails https://rubyonrails.org/ seems to meet all of these requirements:

- ActiveRecord is wonderful for data schemas: https://guides.rubyonrails.org/active_record_migrations.html

- ActiveRecord form validations is excellent and defined only on the model

- Scaffolds automatically generate create/read/update/delete endpoints: https://guides.rubyonrails.org/v3.2/getting_started.html#get...

- Websocket-driven updates provided by Hotwire / Turbo Streams: https://turbo.hotwired.dev/handbook/introduction

- Authorization and Authentication by Devise: https://github.com/heartcombo/devise

HAML is wonderful as a templating language as well.

T3 stack: https://create.t3.gg/ https://github.com/t3-oss/create-t3-app

It's Next.js, Typescript, TailwindCSS, Prisma, NextAuth, tRPC.

> I know about Node.JS, Angular, React, Express

You already know just JS. Stick with JS framework, not these Rails suggestions. Next.js is by far the biggest JS framework (ChatGPT page? half the recent YC co's? Next.js), the rest are the niceties around it to get to a full solution.

> A central definition of data schemas. I don't want to define my schema or validation twice, once in the frontend and once in the backend.

T3 stack uses Prisma, a JS/TS "ORM". Your data schema will live in a .prisma file.

> Automatic generation of REST endpoints. I hate boilerplate code and don't want to reimplement Get/GetOne/Add/Update/Delete and Websocket for each data model. Even better would be a GraphQL interface.

Includes tRPC setup. Give the automated tRPC endpoints a whirl. It's not auto-gen get/delete/etc. (like Django/Rails models) on the server, but the endpoint you create on server very quickly will auto-gen the func call available on the frontend.

> Authorization and Authentication

Includes NextAuth.js setup