october
october is a hosted backend for client-side apps. You describe your data in one EDN schema: entities, typed fields, relationships, constraints, and who may read and write what. october turns it into a database and a GraphQL API with queries, mutations and live queries, and it checks the constraints and permissions on every request. Your app is static HTML and JavaScript that talks to that API.
Each app is a tenant on an october server, with its own data, users and
schema, served under https://<server>/t/<slug>/.
This guide takes you from nothing to a working app. Every october server
serves these pages at https://<server>/docs/. For a coding agent, each
page is also served as raw Markdown (https://<server>/docs/schema.md), and
https://<server>/llms.txt lists them.
| Page | Contents |
|---|---|
| schema.md | the schema language, permissions, and schema changes |
| api.md | the URLs, sign-in, GraphQL, history, errors, cost limits, live queries, hosting |
| client.md | the JavaScript client, @october1/client |
| cli.md | the october CLI and the admin API |
| prompt.md | a prompt for your coding agent: it signs you up and builds the app |
Your data is yours: october export SLUG downloads a tenant's schema and
all its data in a plain, documented format you can read without october
(see cli.md).
What you need
- the server's URL: the hosted october, used throughout this guide, is
https://october.sombra.so - an email address the server lets sign in, or an admin token for the
server. On a server with open sign-up, any address works: the first
code emailed to it makes your admin account. Where sign-up is by invite,
the address is the invited one (if you joined the waitlist and were
accepted, the email you got says so, and it is the address you joined
with). You sign in with a code emailed to it and get an admin token,
which administers the tenants you create (up to a limit, 5 by default)
and any you are granted; other tenants don't exist for it.
october loginsays which kind of server it is. - Babashka (
bb), which theoctoberCLI runs on; your server serves the CLI itself (step 1). - a text editor: your app is one
schema.ednfile
1. Install the CLI and log in
curl -fsSL https://october.sombra.so/cli/october -o october && chmod +x october
That saves the script as october in the current directory: run it as
./october, or move it to a directory on your PATH to type just
october, as the examples below do. See cli.md.
$ october login --url https://october.sombra.so --email you@example.com
If you@example.com may sign in, a code is on its way there (it expires in 10 minutes).
Enter the code: 418093
Logged in to https://october.sombra.so as you@example.com (laptop); saved to /home/you/.config/october/cli.edn
You administer no tenants yet; create one with: october init SLUG
On a server with open sign-up any address gets a code, and its first one
makes your admin account. Where sign-up is by invite, the address needs
an invite (one without gets the same answer and no code). Or log in with an admin token for the
server: october login --url URL --token TOKEN (see
cli.md).
october whoami shows the tenants your token administers at any time.
2. Write a schema
Create schema.edn. This one is a shared shopping-list app: users own
lists, share them with others, and everyone on a list can edit its items.
{:entities
{:$users {:attrs {:display-name {:type :string :optional? true :min 1 :max 40 :trim? true}
:findable {:type :boolean :optional? true}}
;; users are closed by default: you see yourself, people you share a
;; list with, and those who chose to be findable (to be added to one)
:permissions {:view [(or-join [?e ?user]
(self? ?e ?user)
(shares-list? ?e ?user)
(and (authenticated? ?user) [?e :$users/findable true]))]}}
:lists {:attrs {:title {:type :string :min 1 :max 100 :trim? true :indexed? true}
:owner {:type :ref :to :$users :required? true
:default :auth/user :reverse :owned-lists}
:members {:type :ref :to :$users :many? true :reverse :shared-lists}}
:permissions {:view [(on-list? ?e ?user)]
:create [(authenticated? ?user) (list-owner? ?e ?user)]
:update [(list-owner? ?e ?user)]
:delete [(list-owner? ?e ?user)]}}
:items {:attrs {:text {:type :string :min 1 :max 500 :trim? true}
:done {:type :boolean :optional? true}
:list {:type :ref :to :lists :required? true :reverse :items}}
:permissions {:view [(on-item-list? ?e ?user)]
:create [(on-item-list? ?e ?user)]
:update [(on-item-list? ?e ?user)]
:delete [(on-item-list? ?e ?user)]}}}
:rules [[(list-owner? ?l ?u) [?l :lists/owner ?u]]
[(on-list? ?l ?u) [?l :lists/owner ?u]]
[(on-list? ?l ?u) [?l :lists/members ?u]]
[(on-item-list? ?i ?u) [?i :items/list ?l] (on-list? ?l ?u)]
[(shares-list? ?a ?b) (on-list? ?l ?a) (on-list? ?l ?b)]]}
schema.md explains every key, and has a fuller version of this schema.
3. Create the tenant
$ october init shop --demo
Created tenant shop with schema.edn; its API is /t/shop/graphql (in demo mode)
(If schema.edn doesn't exist yet, init writes a starter schema there
first.)
--demo starts the tenant in demo mode: a sign-in code comes back in the
response instead of by email, so you can sign in straight away (step 6).
Anyone can then sign in as anyone, so turn it off with october demo shop off before you have real users.
4. Change the schema: plan, then push
Edit schema.edn, for example add :note {:type :string :optional? true}
to the :items attrs. Check it: october check lists every error in the
file at once, or says it is valid (see
cli.md). Then see what would change:
$ october plan shop
Plan bf3a5141784c -> 18040fa9b5bd
Add:
items/note
Apply it (push shows the plan again, then applies):
$ october push shop --yes
Plan bf3a5141784c -> 18040fa9b5bd
Add:
items/note
Applied 18040fa9b5bd to shop
Adding things is always safe. Changing a type or removing a field is refused or needs a flag; see schema.md.
Look at what the server generated:
curl https://october.sombra.so/t/shop/schema.graphql
5. Allow your frontend's origin
A page on another origin (your dev server on http://localhost:5173, a
static host) can call the tenant once its origin is allowed. Allow it
with the CLI:
october origins shop --add http://localhost:5173 --add https://app.example.com
october then answers CORS for those origins on every API path of
/t/shop/, preflights included. Details:
api.md.
6. Sign a user in from the browser
The client, @october1/client, handles tokens, safe retries and live
streams. A static page can load it from your server, as here, or install it
with npm install @october1/client:
<script type="module">
import {init} from 'https://october.sombra.so/october-client.js';
// your page's origin must be allowed (step 5)
const db = init({url: 'https://october.sombra.so', tenant: 'shop'});
const email = 'ada@example.com';
const {demoCode} = await db.auth.sendMagicCode({email});
// demoCode is there only in demo mode; otherwise the user types the code
// from their email.
const code = demoCode ?? prompt('The code from your email');
await db.auth.signInWithMagicCode({email, code});
</script>
The client keeps the sign-in (a short-lived access token and its refresh
token) in localStorage and renews it on its own. See
client.md.
7. Query and mutate
const {createList} = await db.mutate(
'mutation ($t: String!) { createList(input: {title: $t}) { id title } }',
{t: 'From the browser'});
// {"id": "97aa650f-...", "title": "From the browser"}
const {lists} = await db.query('{ lists(first: 10) { items { id title items(first: 50) { items { text done } } } } }');
// {"items": [{"id": "97aa650f-...", "title": "From the browser", "items": {"items": []}}]}
Every list is paginated: first is required, and pageInfo.endCursor
goes into after for the next page. A refused request throws an
OctoberError, with a code such as VALIDATION_FAILED or FORBIDDEN, and
every write can be retried without writing twice. See
client.md and
api.md.
Every entity also has its history (who changed what, and when) and
can be read as it was with asOf: see api.md.
8. Subscribe live
const q = '{ lists(first: 10) { items { title } } }';
const stop = db.subscribe(q, {}, ({data, mine}) => {
render(data); // mine === false: someone else changed it
});
The first result is the current one. A new one arrives whenever a write changes the result, and the client reconnects a stream that drops. See client.md. To work over plain HTTP instead, see api.md and api.md.
Running october on your own machine
You don't need this for anything above: your app can run on localhost
against the server from the start (step 5).
If you run your own october, october dev starts a local copy with
schema.edn as your app's tenant. It needs Java 21 or newer and an
october.jar, from a checkout of october or from your own server. The
hosted server doesn't serve the jar. See cli.md.
Known issues
- Sign-in codes are emailed only on tenants whose sign-in email is on
(see api.md): on the hosted service, sign-in
email is on for new apps, within daily limits. Elsewhere, outside
demo mode, they aren't emailed (
send_magic_codeanswers"delivered": false). A server with no mailer writes them to its log; one with a mailer never does. Demo mode is per tenant and off by default: create your tenant withoctober init SLUG --demo, or turn it on withoctober demo SLUG on.