An open API service indexing awesome lists of open source software.

https://github.com/abogoyavlensky/clojure-stack-lite

๐ŸชถA quick way to start a full-stack Clojure app with Server-side Rendering. Built on SQLite/PostgreSQL, HTMX, AlpineJS and TailwindCSS v4
https://github.com/abogoyavlensky/clojure-stack-lite

alpinejs boilerplate clojure generate htmx project scaffold stack tailwindcss template

Last synced: 3 months ago
JSON representation

๐ŸชถA quick way to start a full-stack Clojure app with Server-side Rendering. Built on SQLite/PostgreSQL, HTMX, AlpineJS and TailwindCSS v4

Awesome Lists containing this project

README

          

# Clojure Stack Lite

A quick way to start a full-stack Clojure app with server-side rendering.
Built on a powerful yet lightweight stack featuring SQLite/PostgreSQL, HTMX, AlpineJS, and TailwindCSS v4.

This template is designed to be lightweight and easy to use, with a focus on rapid development and deployment. Minimal distraction and sane defaults. Everything is streamlined to give you a solid foundation for building modern web applications.

Get started building your new Clojure application in seconds and be productive!

## Usage

1. Create a new Clojure project using Clojure CLI:
```bash
clojure -Ttools install-latest :lib io.github.seancorfield/deps-new :as new
clojure -Tnew create :template io.github.abogoyavlensky/clojure-stack-lite :name myproject
```

> Requires Clojure CLI tools version `1.12.0.1479` or later.

Or alternatively using [neil](https://github.com/babashka/neil):

```bash
brew install babashka/brew/neil
neil new io.github.abogoyavlensky/clojure-stack-lite myproject
```

2. Start development (with [mise](https://mise.jdx.dev/getting-started.html)):

```shell
cd myproject
mise trust && mise install
bb clj-repl
(reset)
```

The server should be available at `http://localhost:8000`.
Check out project's README.md and template documentation for more information on how to use the project.

> [!TIP]
> Edit some details before going to production: label in `Dockerfile`,
domain in `resources/public/manifest.json` and description in `README.md`

## Features

- ๐Ÿ—๏ธ Robust Clojure stack powered by Integrant and Reitit/Ring
- ๐ŸŽจ Lightweight frontend using HTMX, AlpineJS and TailwindCSS v4 (with optional DaisyUI
components)
- ๐Ÿ“ฆ SQLite/PostgreSQL database (you choose)
- ๐Ÿ”„ Zero-downtime deployment via Kamal
- โšก GitHub Actions CI/CD pipeline
- ๐Ÿงช Integration and unit testing setup with coverage
- ๐Ÿ” Linting, formatting and deps version management
- โš™๏ธ deps.edn and Babashka Tasks for efficient project management
- ๐Ÿ“ฑ Basic PWA support out of the box (without service worker)
- ๐Ÿ”’ Optional authentication and registration flow

## Stack

### Backend
- **Integrant**: Component lifecycle management for application
- **Reitit**: Fast data-driven routing
- **Ring/Jetty**: HTTP server adapter
- **Hiccup**: HTML generation from Clojure data structures
- **Malli**: Data validation and specification

### Database

- **SQLite/PostgreSQL**: Choose between file-based SQLite or enterprise-grade PostgreSQL
- **next.jdbc**: JDBC-based database access
- **HoneySQL**: SQL as Clojure data structures
- **Ragtime**: Database migrations

### Frontend
- **HTMX 2**: HTML extensions for AJAX without writing JavaScript
- **AlpineJS 3**: Lightweight JavaScript framework for adding behavior
- **TailwindCSS 4**: Utility-first CSS framework
- [OPTIONAL] **DaisyUI**: A UI Component library (`:daisyui true` option)

### Development
- **Babashka**: Project management with tasks
- **clj-kondo**: Static analyzer and linter
- **cljfmt**: Code formatter
- **eftest/cloverage**: Testing and code coverage

### Deployment
- **Docker**: Containerization
- **Kamal**: Zero-downtime deployments
- **GitHub Actions**: CI/CD workflows

### Features
- Authentication and registration flow (`:auth true` option)
- Login, logout, registration, password reset, password change, account page

## Project structure

The template generates a Clojure project with the following structure:

```
โ”œโ”€โ”€ .clj-kondo/ # Clojure linting configuration
โ”œโ”€โ”€ .github/ # GitHub Actions workflows and configurations
โ”œโ”€โ”€ .kamal/ # Kamal deployment configuration (only used with Kamal)
โ”œโ”€โ”€ db/ # Empty database directory for database files (only used with SQLite)
โ”œโ”€โ”€ dev/ # Development configuration directory
โ”‚ โ””โ”€โ”€ user.clj # User-specific development configuration
โ”œโ”€โ”€ resources/ # Static resources and configuration files
โ”‚ โ”œโ”€โ”€ public/ # Public assets (CSS, JS, images)
โ”‚ โ”œโ”€โ”€ migrations/ # Database migration files
โ”‚ โ”œโ”€โ”€ config.edn # Main configuration file for the application
โ”‚ โ”œโ”€โ”€ config.dev.edn # Development-specific configuration
โ”‚ โ””โ”€โ”€ logback.xml # Logging configuration file
โ”œโ”€โ”€ src/ # Source code directory
โ”‚ โ””โ”€โ”€ {{name}} # Main namespace directory
โ”‚ โ”œโ”€โ”€ core.clj # Application entry point
โ”‚ โ”œโ”€โ”€ db.clj # Database system component and main operations
โ”‚ โ”œโ”€โ”€ handlers.clj # HTTP request handlers
โ”‚ โ”œโ”€โ”€ routes.clj # Route definitions
โ”‚ โ”œโ”€โ”€ server.clj # Server system component
โ”‚ โ””โ”€โ”€ views.clj # HTML templates and components with Hiccup
โ”œโ”€โ”€ test/ # Test files directory
โ”‚ โ””โ”€โ”€ {{name}} # Test namespace directory
โ”‚ โ”œโ”€โ”€ home_test.clj # Example test for home page
โ”‚ โ””โ”€โ”€ test_utils.clj # Test utilities
โ”œโ”€โ”€ .cljfmt.edn # Formatting configuration
โ”œโ”€โ”€ .gitignore # Git ignore rules
โ”œโ”€โ”€ .mise.toml # mise-en-place configuration with system dependencies
โ”œโ”€โ”€ .dockerignore # Docker ignore rules
โ”œโ”€โ”€ bb.edn # Babashka tasks configuration for managing application
โ”œโ”€โ”€ deps.edn # Clojure dependencies and aliases
โ”œโ”€โ”€ Dockerfile # Dockerfile for building the application image
โ”œโ”€โ”€ docker-compose.yaml # Run PostgreSQL database for local development (only used with PostgreSQL)
โ”œโ”€โ”€ LICENSE # License file, AGPLv3 by default, for motivation check: https://plausible.io/blog/open-source-licenses
โ””โ”€โ”€ README.md # Project documentation
```

## Options

The template offers customization options for generating your project:

- `:db` - Choose between SQLite or PostgreSQL for your database (*Default: `:sqlite`*)
- Available values: `:sqlite` or `:postgres`
- `:daisyui` - Include [DaisyUI](https://daisyui.com/), a component library for TailwindCSS (*Default: `false`*)
- Available values: `true`
- `:deploy` - Choose between Kamal and no deployment configuration (*Default:* `:kamal`)
- Available values: `:kamal` or `:none`
- `:auth` - Add authentication and registration flow (*Default: `false`*)
- Available values: `true`

Possible values: `false | true`

Usage example:

```shell
clojure -Tnew create :template io.github.abogoyavlensky/clojure-stack-lite :name myproject :daisyui true
```

## Authentication flow preview

https://github.com/user-attachments/assets/187daef7-d39d-4794-8dd4-2a88b735c826

## Roadmap

- [x] DaisyUI support
- [x] PostgreSQL support
- [x] No deployment option
- [x] Register/Auth flow
- [ ] Sentry support
- [ ] More frontend tool options (TwinSpark, Datastar)
- [ ] Queue support
- [ ] Websocket support

## Links

- [Integrant + Aero](https://lambdaisland.com/blog/2019-12-11-advent-of-parens-11-integrant-in-practice)
- [Start TailwindCSS as part of the app system](https://shagunagrawal.me/posts/multiplayer-board-game-in-clojure/#repl)
- [Auto-reloading Ring/Reitit](https://bogoyavlensky.com/blog/auto-reloading-ring/)
- [Sessions with Ring/Reitit](https://github.com/metosin/reitit/issues/205)
- [Clojure + Kamal](https://bogoyavlensky.com/blog/deploying-full-stack-clojure-app-with-kamal/)
- [CI with Kamal](https://igor.works/blog/evolution-of-github-action-for-kamal)

## Template Development

### Requirements

To work with this template, you need:

1. [mise](https://mise.jdx.dev/) (recommended) or manual installation of:
- Java
- Clojure
- Babashka

### Getting Started

All management tasks:
```shell
bb tasks
The following tasks are available:

test Run tests for the template config
new Create a new project
release Create and push a new git tag based on provided version
```

After you updated the template and ran tests `bb test`, you can create a new project to check if everything works as expected:

```shell
bb new
```
The new project will be created in the `tmpl` directory at the root that is ignored by git.

### Release

Once you are ready to release a new version of the template, bump version in `deps.edn`:

```
:aliases -> :build -> :exec-args -> :version -> "0.1.1
```

and then run the following command:

```shell
bb release
```

A new git tag based on latest version will be created and pushed to the repository.

## License
MIT License
Copyright (c) 2025 Andrey Bogoyavlenskiy