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.
- Clone the repository with:
git clone https://github.com/tanin47/playframework-template - 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 -ysdk install scala 3.3.5sdk install sbt 1.11.1
- Install node and npm. NVM is recommended for managing multiple Node versions.
nvm install 22,nvm alias default 22, andnvm use 22
- Install Postgres.
- Using Homebrew is recommended. Run
brew install postgresql - Start Postgres with
brew services restart postgresql
- Run
npm installin order to install all npm packages. - Run
cd setup && ./setup_db.shin order to set up the postgres database.
- You may need to adjust the credentials
setup_db.shto be able to connect to your local Postgres.
- Open 3 terminal windows:
- Run
sbt runfor Play server (Hot-Reloading enabled). - Run
npm run hmrfor JS/CSS/Svelte (Hot-Reloading enabled). - Run
sbt 'runMain background.JobRunrMain dev'for background processing. No Hot-Reloading.
- Visit http://localhost:9000
sbt testto run all tests.- To publish a production Docker image for deployment:
sbt stage docker:publish
Here are the main features:
- Modern JavaScripts framework integration (Svelte + TailwindCSS + DaisyUI) with Hot-Module Reloading (HMR) and Typescript support for local dev.
- Deployment pipeline to Dokploy, which should be easily adaptable to Render.com and Heroku.
- Postgres integration that supports Enum.
- JobRunr, the background job framework, is installed with a job example.
- Test frameworks with browser testing.
- Pre-configured scalafmt and scalafix.
- (not done yet) Github Actions configuration with sharded tests.
It also includes multiple code conventions that I've used over the years like:
- Processing a JSON data in POST request and propagating validation errors.
- Passing the data between frontend and backend in a semi-strong typed manner.
- 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.
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.