#web-apps #applications #framework #building #web-framework #old-school #quokka

macro quokka-macros

A new framework for building old-school fullstack web applications

1 unstable release

new 0.0.0 Feb 20, 2025

#313 in #building


Used in quokka

MIT license

13KB
223 lines

Some parts (mostly documentation) are not yet fully ready, but for everyone curious enough there should be enough resources and examples to figure out a rough idea of what this framework should be or become!


Quokka

Quokka Icon

This framework is pretty opinionated and focuses on ergonomics and simplicity with providing and option to easily provide bundles which can be plugged into every application to extend it.

Why another web framework?

In Rust we already have quiet some framework which also come with some opinionated APIs, but they all fail at some point due to personal preferences like the choice of the database handling, templating or outdated dependencies.

As an opinionated library this should should provide another approach to an old-school way of building web applications with a decent flexibility in the backend and frontend.

"Core" libraries

While these are not all the dependencies, of cause, this list should guide you to a hint at what kind of technology you have to expect while working with this library.

As "core" libraries these will get special attention in terms of updates. I might miss some patch versions, but all minor versions and all bigger patch versions should be taken on the way ensuring an always up-to-date experience with all stable features (that said, I will not update to rc versions).

Library Usage Notes
axum Providing routing and a variety of extractors and response types
handlebars HTML Templating
sqlx Database access
grass Styling with Sass/SCSS
rust-embed Providing resources to the applicating. Embeds them into the application for production deployments and loads them from disk for develpment.
clap Providing the argument parsing for commands

Features

Feature Description
Configuration Configure modules and bundles using a toml file. Config files can be merged. Multiple config files can be passed in using the CONFIG_PATH environment variable. Multiple files can be separated with a :.
Templating Allows templating using the handlebars templating language. Templates can be registered as from a static string or a rust-embed struct. They can are hot-reloaded for debug releases
Styling Allows styling HTML using SASS/SCSS. The styles will be hot-reloaded as being rust-embed structs.
Scripting Provide scripts from a rust-embed source. Hot reload is supported as the rust-embed supports it.
Database Provides two connections for reading and writing to databases.
Resources Provides a static assets for the web application. They will be served with Cache-Control through the /resources endpoint. Also they support hot reloading as of rust-embed.
Template helpers There are helpers in place for serving static templates, templates that are being enriched with data and templates templates that submit a form and store/process the data.
Session Provide a mechanic for handling sessions using cookies
Simplified Database Access There are helpers in place for creating entity repositories. Mapping data to Entity structs is done using the sqlx::FromRow trait.
Bundles (aka Pouches) They provide a way to bundle all the functionallity of an application or library with routes, templates and other logic.
Commands Allows to register command handlers and calling them from an extra binary.
Mailing A state for configuring and sending emails using the mail_send trait.

What is a Bundle?

A bundle is a library which can be plugged into the library to extend the application by whatever function it provides. Similar to what "mods" do to games.

The bundle should not necessary require changes to the "State" object to keep the effort of integrating them low. (although requiring an altered state is not strictly discouraged. Especially for more complex bundles this might be the only way to get properly integrate and extend them from other bundles).

Dependencies

~0.6–1MB
~23K SLoC