Skip to content
/ playfast Public template

An opinionated production-ready PlayFramework template that makes you productive.

License

Notifications You must be signed in to change notification settings

tanin47/playfast

Repository files navigation

PlayFast: Production-ready PlayFramework Template

PlayFast is an omakase-style production-ready PlayFramework template that makes you productive.

You can see the demo here: https://play.nanakorn.com

It comes with libraries and code conventions that help you get started quickly and be productive. Setting up all these components and conventions would take from hours to weeks. You can clone the repository, run it locally, run tests, and deploy a working version within minutes.

How to use

  1. Clone the repository with: git clone https://github.com/tanin47/playframework-template
  2. Install jdk, scala, and sbt. SDKMAN is recommended for managing multiple JDKs, and GraalVM 21.0.7 for JVM.
  • sdk install java 21.0.7-graal -y
  • sdk install scala 3.3.5
  • sdk install sbt 1.11.1
  1. Install node and npm. NVM is recommended for managing multiple Node versions.
  • nvm install 22, nvm alias default 22, and nvm use 22
  1. Install Postgres.
  • Using Homebrew is recommended. Run brew install postgresql
  • Start Postgres with brew services restart postgresql
  1. Run npm install in order to install all npm packages.
  2. Run cd setup && ./setup_db.sh in order to set up the postgres database.
  • You may need to adjust the credentials setup_db.sh to be able to connect to your local Postgres.
  1. Open 3 terminal windows:
  • Run sbt run for Play server (Hot-Reloading enabled).
  • Run npm run hmr for JS/CSS/Svelte (Hot-Reloading enabled).
  • Run sbt 'runMain background.JobRunrMain dev' for background processing. No Hot-Reloading.
  1. Visit http://localhost:9000
  2. sbt test to run all tests.
  3. To publish a production Docker image for deployment: sbt stage docker:publish

Features

Here are the main features:

  1. Modern JavaScripts framework integration (Svelte + TailwindCSS + DaisyUI) with Hot-Module Reloading (HMR) and Typescript support for local dev.
  2. Deployment pipeline to Dokploy, which should be easily adaptable to Render.com and Heroku.
  3. Postgres integration that supports Enum.
  4. JobRunr, the background job framework, is installed with a job example.
  5. Test frameworks with browser testing.
  6. Pre-configured scalafmt and scalafix.
  7. (not done yet) Github Actions configuration with sharded tests.

It also includes multiple code conventions that I've used over the years like:

  1. Processing a JSON data in POST request and propagating validation errors.
  2. Passing the data between frontend and backend in a semi-strong typed manner.
  3. Accessing a database and avoid the N+1 queries using the hydration pattern.

Other small features:

  • Support mocking time in test
  • Always redirect to https.
  • Backdoor, a database management tool, is installed.
  • Logging is setup to log every request.

Request a feature or have a question?

Please file an issue if you would like PlayFast to expand to support a library and framework that you want or if you have any question.

About

An opinionated production-ready PlayFramework template that makes you productive.

Resources

License

Stars

Watchers

Forks