This is a small demo project showcasing an integration between
- ZIO HTTP
- ScalaTags
- htmx
Welcome to Neon Pages: an extremely minimal CRM where you can keep a database of people with name, email, phone number or other data. You can add, remove, edit and search for people in the web app, and bulk-edit/bulk-delete.
This is a single-page application (SPA) built with ZIO, ScalaTags and htmx.
This demo project has a main class in Main.scala, so you can run the project by
sbt run
Fork or clone this repo and in an SBT console do
~compile
and SBT will pick up your changes as you develop. The server will have to be restarted.
This application is built with
- a SQLite store, which can be replaced by Postgres or some other database
- Quill for type-safe queries
- ZIO for managing effects
- ZIO HTTP for server endpoints
- ScalaTags for server-side rendering (SSR)
- htmx, a JavaScript library which manages classic single-page application (SPA) flows and backend calls via custom HTML attributes
The "architecture" of the application is layered using ZLayers:
- in
dbwe have layers for the Quill data sources repositoriesis layer for type-safe CRUD operations we're interested in, created with Quill, based on thedblayerservicesis a layer dedicated to business logic, usually with one or more actions fromrepositoriescontrollersis a layer for HTTP endpoints and request/response handling logic, usually delegating to one or moreservices- on top of that,
viewsis the Scala representation of the web pages (with ScalaTags and htmx attributes), which we serve directly
Besides the classical layers, we have a domain for the data types and errors we're using in the app, and a config layer which can fetch configuration from application.conf. The application also contains a Flyway service for migrations.
