Skip to the page

First principles

Chapter 1 of 11

Napalm’s origin

Napalm is a compiler for distributed infrastructure. Write your data model, access rules and queries once, and Napalm compiles a complete backend on PostgreSQL 18.

Building a backend usually means wiring together separate services for sign-in, database queries, background jobs, search and live updates. You copy permission checks across every service by hand, and one missed check exposes another person’s data.

Try it

Napalm replaces that stack with one schema file and four saved queries. Run one command to create a working notes app and set up the project.

Terminal
napalm new notes-app notes
The starter app includes sign-in, live note lists, file uploads and search.

Four jobs in one system#

Every backend answers four questions, and typical stacks wire a separate service to each. Napalm answers all four from one schema.

A typical stackNapalm
Who is calling?A typical stackExternal sign-in serviceNapalmSign-in built into every project
What is allowed?A typical stackChecks repeated in each routeNapalmAccess rules declared on each type
What changed?A typical stackSeparate queue or polling jobNapalmOrdered change log of every saved write
Who responds?A typical stackCustom workers and socket serversNapalmLive queries, webhooks and jobs after each save

Mobile apps, background workers, analytics warehouses, training pipelines and AI agents all read those same records. Keeping rules inside route code forces you to rewrite every check for every new caller.

A compiler for distributed infrastructure#

Most backend bugs come from splitting ownership across tools. Databases hold rows, routes check permissions, presigners guard files, vector stores rank embeddings, queues hold jobs and socket servers push updates. Napalm keeps every rule in one schema and compiles your backend the way a language compiler builds a program.

A compilerNapalm
A compilerReads source filesNapalmReads your schema and saved query files
A compilerCatches type errors before a runNapalmChecks every query against the schema and access rules on push
A compilerEmits machine instructionsNapalmCompiles each query and its matching rules into one SQL statement
A compilerRuns on target hardwareNapalmRuns across engines, replicas, shards, storage and agent endpoints

One compiled path from schema to shard

Requests enter through the project endpoint, compile with matching access policies inside an engine, commit synchronously across primary and replica, and serve bookmarked reads from caught-up replicas.

PostgreSQL 18 enforces one source of truth. Every EdgeQL expression carries a static type and cardinality without SQL NULLs, and Napalm runs the compiled queries across engines, replicas, shards and object storage.

One question across every caller#

The chapters ahead follow the notes app you just created. Two users named Ada and Ben save private notes and files, edit together across web and mobile screens, trigger background jobs and warehouse syncs, invite customer organizations and train custom models.

Ada’s AI agent is the sharpest test. Ada wants an assistant to read her notes, tidy titles and add follow-ups while she travels. A database password would expose Ben’s notes too, and a broad API key would expose every route.

People on web and mobile

Built-in sign-in sessions bind global caller to the verified user identity on every request.

Services and pipelines

Branch-scoped ndb_… service keys authenticate workers, schedules and warehouse syncs under explicit rules.

AI agents and copilots

Approved OAuth consent and expiring grants keep every agent tool call inside exact row access.

Every chapter tests one question on a new caller. Can people, services, pipelines and agents share one database under access rules you write once?

Six design rules keep one schema consistent across every caller, machine and failure.

Type a word or two to search every docs page.