jazzy

Productive, developer-friendly web framework for Nim. Write less code, build more features.

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.5.5
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-11-21 14:04

Authors

  • canermastan

Installation

nimble install jazzy
choosenim install jazzy
git clone https://github.com/canermastan/jazzy-framework

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
jazzy ✓ ✓ ✓ - - - - - - -

Dependencies

Package Version Optional
nim >= 2.2.4 No
mummy >= 0.4.0 No
nimcrypto >= 0.5.4 No
tiny_sqlite >= 0.2.0 No
async_postgres >= 0.3.0 & < 0.4.0 No

Source

Repository https://github.com/canermastan/jazzy-framework
Homepage https://github.com/canermastan/jazzy-framework
Registry Source nimble_official

README

🎷 Jazzy Framework

Write Less Code, Build More Features.

The high-performance, batteries-included web framework for Nim.

Nim 2.2.4+ Version MIT License

Why Jazzy? • Power Snippet • Quick Start • Features in Depth • Documentation


Why Jazzy?

When building a web application, piecing together third-party libraries, wiring up middleware, and hand-crafting database or auth infrastructure is a massive time sink.

Jazzy Framework is a batteries-included web framework designed for maximum developer productivity. From authentication and declarative validation to a fluent database query builder and the Melody template engine, everything you need to ship production web apps comes built right in. Powered by the multi-threaded Mummy HTTP server under the hood, Jazzy delivers blazing-fast performance without sacrificing developer experience.

🖥️ Building Desktop Apps? Check out Jazzy Desktop — build cross-platform desktop applications powered by Jazzy Framework & React / Vue / Svelte under the hood!


EVERYTHING YOU NEED TO SHIP IT

  • ⚡ Lightning Fast Core: Multi-threaded Mummy HTTP engine under the hood for maximum throughput.
  • 🛡️ Built-in Auth & Security: Out-of-the-box JWT Authentication, Basic Auth, Rate Limiting, and CORS protection.
  • 💾 Database Toolkit: Await-first SQLite and PostgreSQL query builder, transactional migrations, and an optional typed ORM.
  • ✅ Declarative Validation: Expressive validation rules that automatically return 422 Unprocessable Entity on failure.
  • 🎨 Melody Template Engine: Nim-native HTML rendering engine with zero allocations, layout inheritance, and hot-reload.
  • ⚙️ Zero Setup & Dev UI: Automatic .env loading and a built-in /dev-ui dashboard for real-time monitoring during development.

💡 Developer Mode UI: When running in dev mode (Jazzy.serve(8080)), navigate to http://localhost:8080/dev-ui in your browser to inspect routes, request logs, and memory cache in real time.


THE POWER SNIPPET

Validating input, persisting to the database, and returning a structured response — all in a single clean handler:

proc createTodo*(ctx: Context) {.async.} =
  # 1. VALIDATE (Automatic 422 JSON response on failure)
  let data = ctx.validate(%*{
    "title": "required|min:3",
    "priority": "int|between:1,5"
  })

  # 2. DATABASE (Fluent API)
  let id = await DB.table("todos").insert(%*{
    "title": data["title"].getStr,
    "priority": data["priority"].getInt,
    "completed": 0
  })

  # 3. RESPONSE
  ctx.status(201).json(%*{"id": id, "status": "created"})

QUICK START

1. Install

nimble install jazzy

2. Create app.nim

import jazzy

Route.get("/", proc(ctx: Context) {.async.} =
  ctx.text("Hello Jazzy!")
)

Jazzy.serve(8080)

3. Run It

nim c -r app.nim

FEATURES IN DEPTH

1. Context-First Architecture (ctx)

Every handler receives a thread-safe Context object managing the request and response lifecycle: * Input Gathering: ctx.input("key") (Automatically searches query params, JSON body, and form payloads). * Auth & Sessions: ctx.login(userNode), ctx.logout(), ctx.check(). * Response Helpers: ctx.json(...), ctx.text(...), ctx.html(...), ctx.render(...).

2. Melody Template Engine (Nim Syntax)

A zero-allocation, clean HTML rendering engine with native Nim syntax and layout inheritance:

<!-- views/layouts/app.html (Parent Layout) -->
<!DOCTYPE html>
<html>
<body>
  @include "partials/navbar"
  <main>
    @yield "content"
  </main>
</body>
</html>
<!-- views/home.html (Child View) -->
@extends "layouts/app"

@section "content"
  <h1>Welcome, {{ $user.name }}!</h1>

  @if user.isAdmin
    <p>Admin Dashboard</p>
  @else
    <p>User Dashboard</p>
  @endif

  <ul>
    @for item in todos
      <li>{{ $item.title }}</li>
    @endfor
  </ul>
@endsection

3. Database, Migrations & ORM

Await-first query builder. SQLite is the zero-config default; PostgreSQL uses a native async pool:

# Fetching Data
let users = await DB.table("users").where("active", true).get()

# Conditions and mutation results
let active = await DB.table("users")
  .whereIn("id", [1, 2, 3])
  .whereNotNull("email")
  .get()
let changed = await DB.table("users").where("id", 1).update(%*{"active": false})

# Return inserted/updated columns on either driver
let user = await DB.table("users").returning("id", "email").insert(%*{
  "email": "ada@example.com"
})

# Schema setup
await createTable("users")
  .increments("id")
  .string("email", nullable = false)
  .unique("email")
  .execute()
# SQLite (default)
DB_CONNECTION=sqlite
DB_DATABASE=database.sqlite

# PostgreSQL
# DB_CONNECTION=postgres
# DATABASE_URL=postgresql://user:password@localhost:5432/app

Jazzy quotes builder identifiers, so table and column names such as order are safe. Raw SQL accepts portable ? placeholders on both drivers; in PostgreSQL raw SQL, write ?? for a literal question mark (for example the JSON ? operator).

Use versioned, transactional migrations for schema changes:

jazzy make:migration create_users
jazzy migrate
jazzy migrate:status
jazzy migrate:rollback
jazzy migrate --step
jazzy migrate --pretend
jazzy migrate:fresh

Migration files live only in src/migrations/. Jazzy self-generates its compiled runner under ignored .jazzy/, so projects have no registry or migrate.nim file to maintain. migrate:fresh, migrate:reset, and all database-changing migration commands require --force when APP_ENV=production.

For explicit demo/reference data, use jazzy make:seeder demo_users and jazzy db:seed; jazzy migrate:fresh --seed recreates a local database and runs the seeders.

The optional ORM uses the same configured database and pool as DB.table():

model User:
  table "users"
  id int64
  displayName string, column = "display_name"
  bio Option[string]
  timestamps()

let user = await User.patch(1, %*{"displayName": "Ada"})
let users = await User.whereNotNull("displayName").get()

Models also support hasOne, hasMany, belongsTo, belongsToMany, nested batch loading (User.with("posts.comments")), pivot attach/detach/sync, typed factories, enum/DateTime fields, dirty tracking, and lifecycle hooks.

Existing projects can preview the await-first upgrade before changing files:

jazzy upgrade db-async
jazzy upgrade db-async --apply
jazzy upgrade db-async --check

The upgrader changes direct calls inside .async. procedures and reports ambiguous synchronous call sites with their file and line number.

4. Routing & Middleware Guards

Route.groupPath("/admin", @[authGuard, cors()]):
  Route.get("/dashboard", handleDashboard)

5. Memory Cache

Thread-safe in-memory cache shared across all Mummy worker threads:

ctx.cache.put("stats", data, ttl = 3600)


🔍 View More Code Examples (Controllers, Middleware, Redirects...)
#### Controller / Handler Example (`isNull` Helper)
proc showProfile*(ctx: Context) {.async.} =
  let userId = ctx.param("id")
  let user = await DB.table("users").where("id", userId).first()

  # Using Jazzy's built-in isNull helper
  if user.isNull():
    ctx.status(404).json(%*{"error": "User not found"})
    return

  ctx.render("profile", %*{"user": user})
#### Custom Middleware
let customHeaderMiddleware* = Middleware(
  name: "CustomHeader",
  handler: proc(ctx: Context, next: HandlerProc) {.async.} =
    ctx.header("X-Framework", "Jazzy")

    # Crucial: Always call next(ctx) to continue the middleware chain
    await next(ctx)
)
#### Redirects & Custom Response Headers
proc handleOldUrl*(ctx: Context) =
  # 302 Redirect
  ctx.redirect("/new-url")

proc handleDownload*(ctx: Context) =
  # Custom response headers and raw payload
  ctx.header("Content-Type", "application/pdf")
  ctx.text("PDF Binary Content")

DOCUMENTATION

📖 For full documentation, guides, and comprehensive API references: 👉 Jazzy Framework Documentation


⭐️ Star History

Star History Chart

Built with ❤️ and Nim  ·  MIT License