Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebApp template V2 #307

Open
AlexITC opened this issue Feb 2, 2023 · 7 comments
Open

WebApp template V2 #307

AlexITC opened this issue Feb 2, 2023 · 7 comments

Comments

@AlexITC
Copy link
Contributor

AlexITC commented Feb 2, 2023

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:

  1. Scala 3 support
  2. API improvements (auto-generate api client, simplify swagger integration)
  3. Frontend improvements (docs, utilities, mui5, module-splitting, remove scalajs-bundler)
  4. 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 playframework/playframework#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.

@AlexITC AlexITC pinned this issue Feb 6, 2023
@schrepfler
Copy link

We once gave react-admin a go and IIRC the team didn't really love it too much.

@AlexITC
Copy link
Contributor Author

AlexITC commented Feb 10, 2023

@schrepfler can you please detail what are the disadvantages you found? Also, do you know any alternatives?

@Spnetic-5

This comment was marked as off-topic.

@rajeck1234

This comment was marked as off-topic.

@AlexITC

This comment was marked as off-topic.

@schrepfler
Copy link

@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.

@AlexITC
Copy link
Contributor Author

AlexITC commented Sep 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants