# How Folkways works

URL: https://docs.folkways.io/docs/concepts

The parts of Folkways, who talks to which, and the words the rest of the docs use.

Folkways has three public surfaces, and your code talks to two of them:

| Surface | Address | Who uses it | For |
| --- | --- | --- | --- |
| **Console** | [console.folkways.io](https://console.folkways.io) | You and your team, in a browser | Workspaces, packages, segments, keys, topic rules, team, usage |
| **Realtime API** | Your segment's Realtime URL, from its **Connect** tab | Your apps and your backend | Connecting, publishing, subscribing, presence, members, DMs |
| **Platform API** | `https://api.folkways.io/api/v1` | Your servers, with an API key | Reading your workspace, segments and usage |

<Diagram name="platform" alt="You set up a workspace, segments, keys and topic rules in the Console. Your backend holds the private signing key and gives each signed-in user a token. Your app connects to the Realtime API with that token to publish and subscribe. Your backend can also publish, manage members and open DMs with a service token, and read usage from the Platform API with an API key." />

## The flow [#the-flow]

1. **You set up a segment** in the Console: a signing key, so your backend can sign tokens, and topic rules, which
   say which topics exist and what they carry.
2. **Your backend signs a token** for each signed-in user. The token names the segment, the user and what they may
   do. Signing happens in your process with your private key; Folkways never sees that key.
3. **Your app connects** to the Realtime API with the token, then publishes and subscribes to topics. Folkways
   checks every operation against the token and the topic's rule.
4. **Your backend can act too**, with a service token: publish events, manage who may use a private topic, open
   direct-message rooms, disconnect a user.

## The building blocks [#the-building-blocks]

| Concept | In one line | Read more |
| --- | --- | --- |
| Workspace | Your team's account: one package, its segments, team and billing | [Workspaces and segments](/docs/concepts/workspaces-and-segments) |
| Segment | One isolated app in one environment | [Workspaces and segments](/docs/concepts/workspaces-and-segments) |
| Identity and token | Who a connection is, and what it may do | [Identities and tokens](/docs/concepts/authentication) |
| Topic | A named channel, e.g. `rooms/42`, matched by a topic rule | [Topics](/docs/concepts/topics) |
| Event | One published item: a name, a type and a payload | [Events](/docs/concepts/events) |
| Stream, KV, Signal, Presence | How events are kept and delivered | [Primitives](/docs/primitives) |
| Cursor | An event's position in a stream, for resuming | [Delivery and ordering](/docs/concepts/delivery) |
| Connection | A WebSocket or HTTP session with the Realtime API | [Connections](/docs/concepts/connections) |

None of these depend on an SDK. The [JavaScript SDK](/docs/js-sdk) wraps them, and any language can use the
[Realtime API](/docs/realtime-api) directly.
