Routing and the CRUD factory
Route files in Dawnshard are about ten lines long. That is by design, and keeping them that way required putting the convention in place early.
What we built
The routing layer generates a full standard HTTP surface from a service. A route file declares a service, optionally specifies middleware and any operations to suppress, and that is all. Route discovery happens automatically at startup by scanning for route files in both the core and extension directories. No registration, no modification to existing files.
Middleware runs before any handler and resolves what the handler needs: the authenticated actor, validated identifiers, association context. Handlers receive a clean, pre-validated request object and call the service. They do not parse or validate anything themselves.
Audit intent, response formatting, and the middleware pipeline are consistent across every domain automatically.
The problem it solves
Route files that accumulate their own logic are a slow drift problem. A little extra parsing here, a conditional there, and eventually the route layer is doing work that belongs in the service. Keeping routes thin by convention is harder than keeping them thin by structure.
The factory makes the thin convention the easy path. There is nothing to write in a standard route beyond the service reference and whatever operations to exclude.
What overcooking looks like
I normally avoid building abstractions before I have evidence I need them. I broke that rule here.
The routing code was designed as a factory from the start, meaning it was built to produce multiple types of generalised router. In practice we only ever needed the one. A plain function would have been enough. The factory layer on top of it is structure with no job to do.
It annoys me every time I read it, because I know better than that! I think to myself, "what a fucking idiot". However, it causes no material problem and there is nothing to gain from burning more time undoing it. So, it stays until there is a reason to touch that code for something else.
What this unlocks
Adding a new domain means writing a model, a service, and a route file that is close to boilerplate. The route loader picks it up on next start. No other files change.
That is friction reduction more than it is engineering achievement. When the goal is moving quickly on product domains, the fewer decisions a domain author has to make about infrastructure, the better.
What's next
The next post covers how downstream applications like Plan.Make.Trace extend Dawnshard: adding new domains, registering plugins, and contributing capabilities without modifying the core.
Liked this post? Tap the heart to let us know.
Get early access
Be the first to hear about early access, roadmap updates, and exclusive early adopter pricing.
Join the early access list