Concepts
How Folkways works
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 | 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 |
The flow
- 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.
- 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.
- 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.
- 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
| Concept | In one line | Read more |
|---|---|---|
| Workspace | Your team's account: one package, its segments, team and billing | Workspaces and segments |
| Segment | One isolated app in one environment | Workspaces and segments |
| Identity and token | Who a connection is, and what it may do | Identities and tokens |
| Topic | A named channel, e.g. rooms/42, matched by a topic rule | Topics |
| Event | One published item: a name, a type and a payload | Events |
| Stream, KV, Signal, Presence | How events are kept and delivered | Primitives |
| Cursor | An event's position in a stream, for resuming | Delivery and ordering |
| Connection | A WebSocket or HTTP session with the Realtime API | Connections |
None of these depend on an SDK. The JavaScript SDK wraps them, and any language can use the Realtime API directly.