Article illustration 1

In the landscape of web frameworks dominated by JavaScript ecosystems, a new contender emerges from the functional programming realm: Schematra. This minimalist framework for CHICKEN Scheme—inspired by Ruby's Sinatra—aims to simplify web development while embracing modern tools like htmx and Tailwind CSS. Created as a learning experiment, it's quickly evolving into a promising toolkit for Scheme enthusiasts.

Why Scheme Needs a Minimal Web Framework

Schematra's creator, Rolando Amora, built it to:
- Deepen understanding of Scheme's idioms and capabilities
- Offer an antidote to framework complexity
- Enable modern web patterns without heavy JavaScript dependencies

"Most web frameworks are complex beasts. Schematra aims to be minimal and understandable," notes the project's documentation. Its design prioritizes clarity, making it an ideal canvas for exploring web fundamentals.

Core Features

  • Sinatra-style routing with get/post handlers
  • URL parameter parsing (e.g., /users/:id)
  • Middleware pipeline for cross-cutting concerns
  • REPL-driven development with NREPL integration
  • Chiccup templates for HTML generation
  • Built-in session management
  • SSE (Server-Sent Events) support

A Developer's Playground

(get "/users/:id" 
 (lambda (req params)
   (let ((user-id (alist-ref "id" params)))
     (format "User ID: ~A" user-id))))

Basic route handling in Schematra

The framework shines in interactive development. Launch a server with REPL support:

(schematra-start development?: #t port: 8080 repl-port: 1234)

Developers can then modify routes and handlers in real-time—a nod to Scheme's live-coding heritage.

Middleware Architecture

Schematra's middleware system handles authentication, logging, and sessions:

(define (auth-middleware request params next)
  (if (valid-token? (request-headers request))
      (next)
      '(unauthorized "Access denied")))

Execution flows sequentially: Middleware processes requests before handlers and responses afterward.

Modern Web Compatibility

Schematra embraces contemporary frontend tools:

;; HTMX integration
(get "/clicked"
 (lambda (req params)
   (ccup/html `[p "Button was clicked!"])))

Combined with Tailwind CSS, developers can build reactive UIs without JavaScript build pipelines.

Current Limitations

As an early-stage project, Schematra lacks:
- Production-ready error handling
- Database integrations
- Background job system

Yet it excels as:
1. A Scheme learning tool
2. A prototyping environment
3. An htmx/Tailwind testbed
4. A web framework teaching resource

Future Potential

With plans for WebSocket support and Redis-backed jobs, Schematra could mature into a compelling option for functional web development. Its MIT license and active GitHub repository invite collaboration. As Rolando Amora observes: "It’s perfect for understanding how web frameworks work under the hood"—a philosophy that might just cultivate Scheme’s next-generation web ecosystem.

Source: Schematra GitHub Repository