<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Development on backd</title><link>https://fernandezvara.github.io/backd/docs/development/</link><description>Recent content in Development on backd</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://fernandezvara.github.io/backd/docs/development/index.xml" rel="self" type="application/rss+xml"/><item><title>Architecture</title><link>https://fernandezvara.github.io/backd/docs/development/architecture/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/development/architecture/</guid><description>&lt;p&gt;&lt;code&gt;backd&lt;/code&gt; is a single stateless Go service. Apart from the registry built at startup, all state lives in MongoDB, so several identical instances can run side by side.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;CONFIG_DIR ──load──▶ registry ──▶ provisioner ──▶ MongoDB
 │ ▲
HTTP ──▶ handlers ──────┴──▶ storage.Repository ───┘
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="layers"&gt;Layers&lt;a class="hd-anchor" href="#layers" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Package&lt;/th&gt;
 &lt;th&gt;Role&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/settings&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Environment variables → &lt;code&gt;Settings&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/registry&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Immutable realm → database → collection tree, with realm settings (&lt;code&gt;realm.yaml&lt;/code&gt;), compiled schemas and field index&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/templates&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Embedded starter files written by &lt;code&gt;backd template&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/rules&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Compiles the &lt;code&gt;rules:&lt;/code&gt; of &lt;code&gt;collection.yaml&lt;/code&gt;: expr-lang rules and runs the static checks (guards, roles, fields, &lt;code&gt;now&lt;/code&gt;, read rules as filters)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/auth&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Storage-neutral identity model (users, identities, sessions), password policy, argon2id hashing with a concurrency cap, sign-up, login and session handling; persistence behind &lt;code&gt;auth.Store&lt;/code&gt; (in-memory fake in &lt;code&gt;internal/auth/authtest&lt;/code&gt;)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/query&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Parses the list query language into &lt;code&gt;storage.Condition&lt;/code&gt;s, checking every field and value against the schema&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/storage&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Backend-neutral &lt;code&gt;Repository&lt;/code&gt; interface, &lt;code&gt;Document&lt;/code&gt;/&lt;code&gt;Query&lt;/code&gt;/&lt;code&gt;Page&lt;/code&gt;/&lt;code&gt;Condition&lt;/code&gt;/&lt;code&gt;Filter&lt;/code&gt; types, &lt;code&gt;Fetch&lt;/code&gt; (single reads under a read rule), and the errors &lt;code&gt;ErrNotFound&lt;/code&gt;, &lt;code&gt;ErrVersionMismatch&lt;/code&gt;, &lt;code&gt;ErrConflict&lt;/code&gt; and &lt;code&gt;ErrUnavailable&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/httpapi&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Router, middleware, error envelope, document, &lt;code&gt;/_auth&lt;/code&gt; and &lt;code&gt;/_admin&lt;/code&gt; handlers, CORS&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/jsonnum&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Normalizes JSON numbers to int64 or float64&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;internal/mongodb&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;Everything MongoDB-specific: connection, validator translation, provisioner (including realm system databases), &lt;code&gt;Repository&lt;/code&gt; and &lt;code&gt;auth.Store&lt;/code&gt; implementations&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;No MongoDB driver types cross the &lt;code&gt;storage&lt;/code&gt; interface. Another document store (for example Amazon DocumentDB) can be added as a new implementation without touching handlers or validation.&lt;/p&gt;</description></item><item><title>API contract</title><link>https://fernandezvara.github.io/backd/docs/development/contract/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://fernandezvara.github.io/backd/docs/development/contract/</guid><description>&lt;p&gt;&lt;code&gt;api/openapi.yaml&lt;/code&gt; is the contract of the HTTP API, in OpenAPI 3.1. Clients, such as the &lt;a href="../../clients/js/"&gt;JavaScript client&lt;/a&gt;, are written against it, so the server must never drift from it.&lt;/p&gt;
&lt;h2 id="what-it-covers"&gt;What it covers&lt;a class="hd-anchor" href="#what-it-covers" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Every route: health probes, &lt;code&gt;/_auth&lt;/code&gt;, &lt;code&gt;/_admin&lt;/code&gt; and the generic document routes.&lt;/li&gt;
&lt;li&gt;Every status an operation documents explicitly, plus a &lt;code&gt;default&lt;/code&gt; for errors that can happen anywhere (&lt;code&gt;404&lt;/code&gt; for an unknown realm, &lt;code&gt;413&lt;/code&gt;, &lt;code&gt;415&lt;/code&gt;, &lt;code&gt;500&lt;/code&gt;, &lt;code&gt;503&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Response bodies, including the error envelope and its closed list of &lt;code&gt;code&lt;/code&gt; values.&lt;/li&gt;
&lt;li&gt;Response headers clients rely on: &lt;code&gt;ETag&lt;/code&gt;, &lt;code&gt;Location&lt;/code&gt;, &lt;code&gt;Retry-After&lt;/code&gt;, &lt;code&gt;WWW-Authenticate&lt;/code&gt;, &lt;code&gt;X-Request-ID&lt;/code&gt;, and &lt;code&gt;Cache-Control: no-store&lt;/code&gt; on account data.&lt;/li&gt;
&lt;li&gt;Documents as open objects. Their fields depend on each collection&amp;rsquo;s &lt;code&gt;schema.json&lt;/code&gt;, but &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;_meta&lt;/code&gt; are described exactly.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="how-its-enforced"&gt;How it&amp;rsquo;s enforced&lt;a class="hd-anchor" href="#how-its-enforced" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Two checks keep the spec honest, and both run in CI.&lt;/p&gt;</description></item></channel></rss>