_OpenSource Web4 agent & app starter kit_

# Sign-in for every element of your node

One service tells every element who came and with which roles. Email and password work from the start, guests come on demand, and the accounts stay on your own computer.

[Sign in](/login)
[Create an account](/register)

## How a person gets in

#### A page asks who came

An element sends the visitor’s cookie to /api/session and gets the session with its roles, or 401.

#### The service checks the entry

Email and password from the start; Google and a Resend magic link open as soon as their keys are in.

#### Roles decide the rest

Fourteen roles and the guest, and every route of an element says who may open it.

#### An element on its own domain

It signs people in through the single sign-on: a one-time code becomes a ticket of that site.

The first account registered on this computer becomes the architect of the node for good.

## Always on

The node never turns this element off: the other elements depend on it. It starts with the node and does not sleep, even when memory is short.

## Guests and two ready providers

Guest sign-in is built in: a guest account appears on request and remembers what the visitor did in this browser, a half-filled cart for one. Guests are limited: a cap per address and an overall ceiling, at which the guest who has been away longest goes first.

Google and the Resend magic link are already installed. To turn them on, enter their keys; no code is needed.

## What changes for you

| Without it | With the sign-in service |
| --- | --- |
| Every element would build its own sign-in | Every element asks one service who came |
| A visitor’s half-filled cart is lost | A guest account keeps what a visitor did in this browser |
| Roles are copied by hand into every app | Fourteen roles and the guest, set for every route |
| The accounts sit on someone else’s server | They stay in one file on your computer, never in git |

## How to start

- On this computer, register the first account: it becomes the architect of the node.
- Connect your own domain: on the temporary address sign-in and registration are closed.
- Add a Google or a Resend key when you want those ways in; email and password need nothing.

Every account of the node is seen and changed in the core, on the Users tab of this element. Deleting an account wipes the personal data and keeps the identifier and the journal.

## Ask who came

An element of the node asks the service with the visitor’s cookie:

```
const r = await fetch(`${process.env.AUTH_SERVICE_URL}/api/session`, {
  headers: { cookie: request.headers.get('cookie') ?? '' },
})
const session = r.ok ? await r.json() : null // null — nobody signed in
```

Guests come on demand and stay bounded: a limit per address, and a ceiling on guest records, where the guest inactive the longest leaves first.

## Under the hood

| Part | What it does |
| --- | --- |
| NextAuth 5 | Providers, callbacks, sessions and sign-out |
| SQLite | One file of accounts, organizations and roles on this computer, never in git |
| /api/session | Who came and with which roles, or 401 |
| /api/auth/sso | Single sign-on for an element on its own domain |
| 82 languages | Every sign-in screen speaks the visitor’s language, built into the page |
| Applications | On an app factory each application has its own people: one email in two applications is two accounts |

## Change it early

Change sign-in early in the life of your application: it carries the highest risk. If sign-in breaks, nobody opens the protected routes, the architects included, and it is restored through the development mode.

## Your own builder comes with it

Every element of the node comes with its own Claude Code agent and can get its own Telegram bot. When something in this element should change, write to its bot from your phone, and the agent updates the logic or the design.

The agent works only in its element's folder and never reads the whole node, so each change costs fewer tokens. Your Claude Code subscription pays for it.

- The element's bot is connected in the core, on its «Telegram» page.
- The agent returns a commit; you look at it in «Preview» and accept it or turn it down.
- At the computer, the agent's terminal is in the core, in this element's «Build».

## Open source

Built by Fractera for the [Lagrix](https://lagrix.dev) protocol and for any web2 project that needs sign-in. MIT license, the code is at [github.com/Fractera/fractera-auth-starter](https://github.com/Fractera/fractera-auth-starter).

## Questions and answers

**Does a visitor have to register?**
No. A guest account appears on request, so a visitor can start without a password; sign-in is asked only where a route needs it.

**How do I turn on Google or Resend?**
Both are installed. Enter their keys and they open on the sign-in screen; email and password keep working beside them.

**Who becomes the architect?**
The first account registered on this computer, for good. Create it before you connect your own domain.

**Where are the accounts kept?**
In one file on your computer, never in git. You see and change them in the core, on this element's «Users» tab.