Readit News logoReadit News
Posted by u/JaFu0815 3 years ago
Ask HN: Hunting for a Framework
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!

compumike · 3 years ago
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.

eagsalazar2 · 3 years ago
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.

ch4s3 · 3 years ago
> 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.

lakomen · 3 years ago
How many concurrent connections can elixir handle on an average 5 year old xeon e3 with 32gb RAM?
Aeolun · 3 years ago
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).

bcjordan · 3 years ago
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.

eagsalazar2 · 3 years ago
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"??
matus_congrady · 3 years ago
I recently created ~25 full-stack example projects using the most recent technologies and frameworks. I believe the following stack is the most productive, yet very scalable (doesn't use "leaky" abstractions).

Frontend:

  - Good, old, Single Page App. I believe that all these SSR/isomorphic rendering frameworks are a lot of times just unnecessary complexity.
  - Vite.js + your preferred framework (Vite supports React/Vue/Svelte, etc).
Backend:

  - Node.js + Typescript.
  - Trpc.io - while it's not "automatic generation of REST endpoints", it's very close. It's very easy to write your endpoints, and the added flexiblity/control is definitely worth the time spent writing them.
  - Trpc also has a built-in support for subscriptions: https://trpc.io/docs/subscriptions
  - Prisma + Postgres. Good, old, proven, flexible SQL database is always a safe bet. And Prisma makes interacting with it an order of magnitude easier.
  - The whole "network layer" is completely and very efficiently handled by Trpc. It also uses React-query under the hood: https://github.com/TanStack/query.
Infrastructure + deployments:

  - I would recommend going for AWS.
  - Frontend (statically built) can be hosted in S3 bucket behind a CDN. You should also properly configure caching headers returned by Cloudfront to make it work with SPA.
  - You can run your TRPC API in AWS Fargate container (behind ALB, or behind HTTP API GW). Alternatively, you can also run it in a lambda function.
  - To make the configuration of your Infrastructure/Packaging/Deployments 97% easier, have a look at
https://stacktape.com

(disclaimer: I'm a founder)

aviavi · 3 years ago
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.

Dead Comment

quechimba · 3 years ago
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.

shortcake27 · 3 years ago
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.
quechimba · 3 years ago
Check it out if you want, https://github.com/mayu-live/framework

It's far from production ready, but it's already working reasonably well.

I tried HotWire but it didn't feel right to me because I'm used to React.

peteforde · 3 years ago
Honestly, it sounds like you're describing Rails without saying Rails.

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

czbond · 3 years ago
^ 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.

josefrichter · 3 years ago
Phoenix LiveView. Some learning curve, but once it clicks, you’ll understand there’s very little reason to use anything else for web apps.
freddref · 3 years ago
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.

xet7 · 3 years ago
> I've often wanted a VB6 equivalent for the web, but open source.

That's Gambas, it can create web apps.

https://gambas.sourceforge.net

Some more links here:

https://github.com/wekan/hx/tree/main/prototypes/ui/gambas

freddref · 3 years ago
Looks old school open source, sourceforge!
readonthegoapp · 3 years ago
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.

freddref · 3 years ago
This looks very nice, I may give it a shot for a side project that I don't really have time for.

For anyone looking, here's installing via pip: https://github.com/anvil-works/anvil-runtime#using-the-stand...

The code is GNU AFFERO GENERAL PUBLIC LICENSE Version 3.

vladsanchez · 3 years ago
Like Borland Delphi!