andaime: A fast, modular, memory-safe web framework (FastAPI ergonomics in D)

Leonardo T A leotada523 at gmail.com
Tue Oct 20 02:37:31 UTC 2026


Hello everyone,

I'm excited to announce the initial release of **andaime** 
(Portuguese for *scaffolding*), a modern micro web framework for 
D where your handler function's signature *is* its HTTP contract.

- **GitHub**: https://github.com/leotada/andaime
- **DUB**: https://code.dlang.org/packages/andaime (requires DMD 
 >= 2.112.0 / LDC >= 1.42.0)
- **Language Edition**: 2025, safe-by-default (`@safe` + 
`-preview=dip1000`)

---

### Why another web framework?

D has great servers (like vibe.d), but I wanted an experience 
inspired by modern Python (FastAPI) and Rust (Axum), built from 
the ground up to exploit D's unique compile-time superpowers 
without sacrificing compile speed or memory footprint:

1. **Zero Runtime Reflection**: Route extraction, request body 
validation, JSON serialization/deserialization, and OpenAPI 3 
generation are all evaluated at compile time using `__traits` and 
shallow `static foreach`, with readable one-line `static assert`
messages when a handler signature doesn't match its route.
2. **Sub-400ms Compile Times**: Core modules (`http`, `web`, 
`engine`) avoid heavy Phobos imports (`std.regex`, 
`std.algorithm`, `std.json`, `std.format`) in the main pipeline.
3. **Low RSS & Fiber-per-Request**: One worker per core (`epoll`, 
with experimental `kqueue` and `WSAPoll` backends) and 
lightweight fibers (~15-30 MB RSS with 1,000 concurrent 
connections), with a zero-allocation GC-free hot path after 
warmup (~95k req/s
unpipelined, ~444k req/s pipelined on 1 core).
4. **Built-in Protocols & Modularity**: Small core (`import 
andaime;`) with HTTP/1.1, HTTP/2 (`h2spec` 146/146), TLS, SSE, 
and WebSockets. Optional decoupled subpackages: background jobs & 
cron (`andaime:jobs`, `andaime:pgjobs`), async PostgreSQL 
(`andaime:pg`),
crypto (`andaime:crypto`), and an optional scaffolding CLI 
(`andaime:cli`). Zero build-time C library dependencies (`libpq`, 
OpenSSL, `zlib` are loaded via `dlopen` when used).

### Quick Example

```d
@safe:
import andaime;

struct NewUser
{
     @minLength(2) @maxLength(60) string name;
     @inRange(0, 150) int age;
     Optional!string email;
}

struct User { long id; string name; int age; Optional!string 
email; }

// Handler signature is the HTTP contract:
@status(201)
User createUser(JsonBody!NewUser body_)
{
     // Invalid JSON or constraint failures return 422 before your 
code runs
     return User(1, body_.name, body_.age, body_.email);
}

App buildApp()
{
     auto app = new App;
     app.post!("/users", createUser);
     app.serveOpenApi(OpenApiInfo("Users API", "1.0.0")); // /docs 
with Swagger UI
     return app;
}

void main()
{
     serve(&buildApp, 8080);
}
```

---
### Behind the Scenes: The Agentic Engineering Methodology

A unique aspect of andaime's development is that it was 
co-developed using agentic programming under human architectural 
governance.

The project was treated as a rigorous systems-engineering 
experiment:

• Strict Specification Guardrails (AGENTS.md): The repository 
maintains an explicit architectural contract outlining memory 
models, safety boundaries (@safe facades around C bindings), 
dependency directions, and anti-patterns.
• Continuous Automated Verification: The code was subjected to a 
comprehensive harness (tools/check.sh):
     • Fuzzing with ASan / libFuzzer on the zero-copy HTTP/1.1 
parser, HTTP/2 session, WebSocket frames, and JSON reader.
     • Interoperability tests with Python websockets, python-h2, 
curl, Caddy, and h2spec.
     • Regression testing ensuring the hot path remains GC 
allocation-free (tests/alloc).
     • Strict compiler compliance with D Language Edition 2025 and 
-preview=dip1000 on both DMD and LDC.
Takeaway on D for Agentic Development: D turned out to be an 
incredible language for agentic workflows. Its expressive type 
system, DbI (Design by Introspection), fast compile times, and 
custom one-line static assert diagnostics provided fast, 
unambiguous feedback loops that made autonomous refactoring and 
testing remarkably reliable compared to dynamically typed or 
slow-compiling environments.

---
### Status & Feedback

The framework is currently pre-1.0 and is already being 
battle-tested on real-world workloads (including migrating a 
~100-endpoint Python/Sanic backend to D).

I would love to hear your feedback on the ergonomics, compile 
times, and design!

• Documentation: https://github.com/leotada/andaime/tree/main/docs
• License: MIT




More information about the Digitalmars-d-announce mailing list