scala-webapp-template
scala-webapp-template copied to clipboard
WebApp template V2
Intro
This ticket details the aspirational work for v2, there are many pieces that need experiments to decide whether to include them or not.
This webapp template can become a key component for the Scala ecosystem, given that it targets pragmatism over perfectionism, it is ideal for people that are interested in getting started with web applications in Scala/Scala.js, preferring to practice with real-world projects.
Right now, this webapp template has been used in 10+ projects from Wiringbits and 1 project from a developer coming from php background
Improvements
While the template is in a usable state, there are many potential improvements that can help with adoption, like:
- Scala 3 support
- API improvements (auto-generate api client, simplify swagger integration)
- Frontend improvements (docs, utilities, mui5, module-splitting, remove scalajs-bundler)
- Admin app improvements (docs, migrate to slinky, extract react-admin backend module)
Let's dive into these improvements.
1. Scala 3
Scala 3 support is likely the most important item from the list, Scala 3 is considerably simpler to get started than Scala 2, attracting people to Scala is one of our goals, and, Scala 3 support a key piece.
While PlayFramework is likely the biggest blocker on this topic (see https://github.com/playframework/playframework/issues/11260), we can try an hybrid approach where the controllers layer stays on Scala 2.13 and everything else is moved to Scala 3. There is already an example project taking this approach (https://github.com/DevInsideYou/play-scala3-zio) which we can use as inspiration, also, wiringbits-webapp-utils uses the same approach, also, webapp-utils is already published to Scala 3.
2. API improvements
The API layer is a key piece for this template, unfortunately, it is filled with considerable boilerplate which can be annoying for devs trying to use this template (ref 1, ref 2).
The swagger integration is far from ideal and it has many known issues (ref).
There is a chance that we can leverage existing tools like tapir which uses a declarative way to define endpoints, tapir is able to generate the backend routes + the frontend api client. Tapir is also capable of generate OpenAPI specs which can reduce considerable boilerplate from the template (endpoints4s is worth exploring too).
If for any reason Tapir integration isn't simple, we can explore alternative tools.
3. Frontend improvements
Frontend suffers from lack of documentation, we have some helper utilities that are barely documented, for example:
There are other potential utilities to be included, like a component for submitting data to an API, which should have a similar behavior than AsyncComponent
.
Besides this, frontend is using mui3 which is more than 3 years old (ref) while switching to mui5 is now possible (ref), upgrading seems ideal, unfortunately, mui5 is only supported on Scala 3.
Another improvement would be to start using the module splitting feature introduced by Scala.js 1.3.0 (ref), which could reduce the time required to load the app.
At last, scalajs-bundler isn't a loved piece from the Scala.js community, we could explore the possibility to migrate out of it to an alternative like Vite (ref).
4. Admin app improvements
The Admin module is powered by react-admin + a custom backend that exposes the necessary APIs from a postgres database. This custom backend could be easily extracted from the webapp-utils library into its own library, simplifying its evolution.
Right now, the Admin app lacks proper documentation, and, the template example is very basic, which does not demonstrate the module capabilities.
There is another disadvantage from the Admin app, it uses scalajs-react instead of Slinky, while scalajs-react is a very nice library for Scala developers, Slinky is considerably better for onboarding non-Scala developers, we are interested in migrating the few facades into Slinky.
We once gave react-admin a go and IIRC the team didn't really love it too much.
@schrepfler can you please detail what are the disadvantages you found? Also, do you know any alternatives?
Hi @AlexITC , I'm intrigued by this project for the upcoming GSoC. Although I don't have prior experience with Scala, I have considerable expertise in developing mobile and web applications using JS. I was wondering if it would be feasible for me to take on this project even though I am not familiar with Scala.
Hi @AlexITC. I mailed you my document I think it reach to you But I also want to mention my details here. I am utkarsh kumar From IIT Kharagpur 3rd year student and I want to contribute to this project I mailed you my full working process in the coming days. Please once go through my mail.
@Spnetic-5 please follow up by email.
@schrepfler can you please detail what are the disadvantages you found? Also, do you know any alternatives?
Unfortunately I don't this happened 3-4 years ago and that company no longer exists.
I'm glad to share:
- Thanks to @akseliristola , the template is finally in Scala3 as well as using Mui5.
- Thanks to @KapStorm , we have removed the annoying API/Swagger boilerplate by integrating Tapir.