> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stellarium.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Nodes, resources, and peers

> How Stellarium nodes discover each other and route RequestScript requests to the resources they need.

## Nodes

A **node** is a process running `stellarium-ts`. It does three things:

* Hosts **internal resources**: the functions you register with `node.register()`, which run in your process.
* Remembers **external resources** and **peers** it has learned about from other nodes. These are stored in `requestscript.db`, a SQLite file created in the working directory on startup.
* Runs RequestScript **requests** submitted to `POST /v1/run`, calling resources locally or forwarding them to the peer that hosts them.

## Resources

A resource is a named set of functions. `path` and `name` together form its fully qualified name, such as `com.example.Weather`. Each function declares its RequestScript parameter types and return type.

```typescript theme={null}
const weather: StellariumResource = {
  id: 1,
  baseUrl: process.env.BASE_URL!,
  metadata: {},
  path: "com.example",
  name: "Weather",
  functions: [
    {
      name: "temperature",
      parameters: [{ name: "city", type: "string" }],
      returnType: "int32",
      exec: async (args) => 12,
    },
  ],
};
```

When a node shares its resources, it publishes each resource's `path`, `name`, `baseUrl`, and function signatures (`name`, `returnType`, `parameters`, and any `paymentManifest`). Function implementations never leave the node that hosts them.

A function can optionally carry a **payment manifest** that sets its price. See [Payments](/concepts/payments).

## Requests

A RequestScript `request` binds resources with `const <name>: <path>.<ResourceName>` and calls their functions with named arguments:

```requestscript theme={null}
request GetTemperature {
  const weather: com.example.Weather

  return weather.temperature(city: "Oslo")
}
```

When a node runs this:

* If `com.example.Weather` is registered on this process, its `exec` runs locally.
* If it was learned from a peer, the node forwards the call to that peer's `{baseUrl}/v1/run/resource` and returns the result.

See the [RequestScript repository](https://github.com/qualletio/requestscript-js) for the full language.

## Joining a network

Pass `startingPeer` to `node.start()` to bootstrap from a node that is already running. Once the node is listening, it:

<Steps>
  <Step title="Copies the peer list">
    `GET {startingPeer}/v1/peers`. If this node has no peers yet, it stores the returned list, plus the starting peer itself (from `GET {startingPeer}/v1/self`). An existing list is left as-is.
  </Step>

  <Step title="Copies the resource list">
    `GET {startingPeer}/v1/resources`. Each resource is stored with the `baseUrl` that peer advertised.
  </Step>

  <Step title="Announces itself">
    Sends a signed `PUT /v1/peers` to every known peer with its `baseUrl` and public key.
  </Step>

  <Step title="Broadcasts its resources">
    Sends a signed `PUT /v1/all-resources` to every known peer with its internal resources.
  </Step>
</Steps>

Announcements are signed with the node's Ed25519 `SIGNING_PRIVATE_KEY` and expire after 10 minutes. Receiving nodes verify the signature against the sender's public key and reject expired or invalid payloads.

<Tip>
  Omit `startingPeer` to run a standalone node, for example the first node in a new network.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.