source: Klonkt/README.md@ 8240e80

main
Last change on this file since 8240e80 was f574435, checked in by Robin <roboburr@…>, 7 weeks ago

Docs: README + .env.example for paid posts and auto-generated keys

Tell users how the paid-posts key works: no env editing needed, it's
generated on first use like SESSION_SECRET already is. Plus a general pass
for missing features.

Changed files:
README.md

  • "What it does": Paid posts (own Patreon, passkey unlock, no visitor account/cookie, patron identity never stored)
  • Configuration table: PAID_SECRET (auto) + KLONKT_PREMIUM_ENABLED; SESSION_SECRET marked auto (matches .env.example, not "required")
  • new "Auto-generated secrets & backups" section: where the keys live, why PAID_SECRET is outside the DB, and to back up storage/ as a whole
  • Stack: link to FEDERATION.md

.env.example

  • PAID_SECRET block (auto-generate, or openssl rand -base64 32)
  • paid posts added to the premium-extras list

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

  • Property mode set to 100644
File size: 10.0 KB
Line 
1# Klonkt
2
3Your own, **self-hosted** corner of the web — for your story, your visuals and
4your sound. Built on **Node + SQLite + htmx**: lightweight, server-rendered, and
5yours. No algorithm, no ads, no platform sitting in between.
6
7## What it does
8
9- **Solo** — one personal site, entirely yours, on your own domain.
10- **Blog & photos** — posts with cover, tags, timeline or grid.
11- **Host your own music** — built-in audio player with tracks, albums and playlists.
12- **Fediverse-native** — your posts federate over **ActivityPub**: people follow,
13 like, boost and reply from Mastodon (or another Klonkt). You can follow accounts,
14 see a home timeline, and reply/like back — Klonkt is a full fediverse client.
15- **Grow**: newsletter, download-for-email, EPK/press kit, link-in-bio,
16 show calendar, and **cookie-free statistics**.
17- **Paid posts** — put a post behind your **own Patreon**. Supporters unlock it
18 with a **passkey**: no account on your site, no cookie, and a patron's identity
19 (name/email) is never stored — only a pseudonymous, expiring entitlement. You
20 connect your Patreon once in the admin and pick a minimum amount per post.
21- **Circles** — a curated feed of the makers you choose: feature accounts (other Klonkt
22 sites, Mastodon, PeerTube — any fediverse server) and their public posts appear in your
23 Circle. Decentralized, no central platform — built on ActivityPub.
24- **Themes & languages** — multiple palettes (light + dark), interface in EN/NL/DE.
25- **Installable (PWA)**, **privacy-first** (self-hosted fonts, no tracking).
26
27### Lite mode (no audio)
28
29Set `KLONKT_AUDIO=off` in `.env` to disable the entire audio/music feature.
30Klonkt then runs as a lightweight **blog/photo/EPK/links site without ffmpeg** —
31ideal for minimal hosting. Circles and external embeds
32(YouTube/SoundCloud/Spotify) keep working.
33
34It's **fully reversible**: set `KLONKT_AUDIO` back to `on` (or remove the line)
35and restart — no reinstall. The flag only toggles the audio routes/UI; the
36database tables are never dropped, so any tracks you had are preserved.
37
38## Self-hosting
39
40Klonkt is a **Node app** — run it on a **VPS, in Docker, or on a Node hosting
41platform (PaaS)**. **Not** on classic shared PHP hosting. The database (SQLite)
42creates itself on first start.
43
44> **Requires [Node.js](https://nodejs.org/) 20 or newer.** The one-command VPS
45> installer and the Docker image include it; only a manual install needs you to
46> provide it.
47
48### Option A — One-command VPS installer (recommended)
49
50**Good if:** you have (or just rented) a fresh, empty Debian/Ubuntu VPS and want
51the easiest path. This single line does everything — installs Node 20, sets up
52Caddy for automatic HTTPS, runs Klonkt as a background service that auto-restarts
53on reboot, and adds an update command. It's coexistence-safe (if the server
54already runs something it picks a free port and skips Caddy), but a clean VPS is
55simplest. Point your domain's DNS (A + AAAA records) at the server first, then run
56as root:
57
58```bash
59curl -fsSL https://klonkt.com/install.sh | sudo bash -s -- --domain yourdomain.com
60```
61
62Then open `https://yourdomain.com` and finish setup in the browser. Update anytime
63with `klonkt-update`.
64
65Updates track the **`stable`** branch — it only advances to a version that's been verified,
66so `klonkt-update` never pulls work-in-progress. Want the bleeding edge instead? Install with
67`--branch main` (or set `KLONKT_BRANCH=main`).
68
69### Option B — Docker
70
71**Good if:** you already use Docker, or want everything bundled in one isolated
72container. Node, ffmpeg and cwebp are inside the image — you only need Docker +
73Docker Compose.
74
75```bash
76git clone https://github.com/roboburr/klonkt.git
77cd klonkt
78cp .env.example .env # works as-is; optionally set PUBLIC_BASE_URL to your domain
79docker compose up -d
80```
81
82`SESSION_SECRET` is auto-generated on first start, so the defaults work as-is.
83Klonkt runs on port 3000 — put your own reverse proxy in front for HTTPS (see
84step 5 of Option C). Data (database + media) stays in the `klonkt-data` volume,
85even across updates. Update: `git pull && docker compose up -d --build`.
86
87### Option C — manual (Node 20+), step by step
88
89**Good if:** you want full control, are adding Klonkt to a server you already
90manage, or just want to test it locally.
91
92**1. Get the code & install dependencies**
93
94```bash
95git clone https://github.com/roboburr/klonkt.git
96cd klonkt
97npm ci
98```
99
100**2. Create your config.** `SESSION_SECRET` (the key that signs login cookies) is
101auto-generated on first start, so this works as-is. For production, set
102`PUBLIC_BASE_URL` to your site address (e.g. `https://yourdomain.com`) so email &
103login links are correct:
104
105```bash
106cp .env.example .env
107nano .env # optional: PUBLIC_BASE_URL, plus SMTP if you want it
108```
109
110**3. Start it** — the SQLite database is created automatically on first start:
111
112```bash
113npm start # runs on http://localhost:3000
114```
115
116Just testing locally? Stop here and open `http://localhost:3000`.
117
118**4. Keep it running** across crashes and reboots (easiest is pm2):
119
120```bash
121npm install -g pm2
122pm2 start src/server.js --name klonkt
123pm2 save && pm2 startup # run the one command it prints, once
124```
125
126**5. Add HTTPS** with a reverse proxy in front. With Caddy (automatic
127certificates), put this in `/etc/caddy/Caddyfile` and reload Caddy:
128
129```caddy
130yourdomain.com {
131 reverse_proxy localhost:3000
132}
133```
134
135By default the app binds to `127.0.0.1` (via `HOST` in `.env`), so only your
136reverse proxy can reach it — not the open internet. Local testing on the same
137machine (`localhost:3000`) still works. Only set `HOST=0.0.0.0` if you need direct
138external access without a proxy (then open the port in your firewall and add HTTPS
139yourself).
140
141(`cwebp` is optional — `apt install webp` — for WebP image conversion.)
142
143### HTTPS (Docker / bare Node)
144
145Put a reverse proxy in front of the app. With **Caddy** (automatic Let's Encrypt):
146
147```caddy
148yourdomain.com {
149 reverse_proxy localhost:3000
150 encode gzip zstd
151}
152```
153
154(The VPS installer sets up Caddy + HTTPS for you already.)
155
156### First run
157
158Open your site → you get the **setup wizard**: pick your language, name your site
159and create your admin. The **first user automatically becomes the administrator**;
160registration then closes. Lost your password?
161`npm run reset-admin` (Docker: `docker compose exec klonkt npm run reset-admin`).
162
163## Configuration (`.env`)
164
165| Variable | Required | What |
166|---|---|---|
167| `SESSION_SECRET` | auto | Signs login sessions. Leave empty to auto-generate (`storage/.session-secret`), or set a random ≥32-char string. |
168| `PUBLIC_BASE_URL` | ✅ | Canonical URL (e.g. `https://yourdomain.com`) |
169| `PAID_SECRET` | auto | Encrypts the stored Patreon secrets for **paid posts**. Leave empty to auto-generate on first use (`storage/.paid-secret`), or set your own ≥16-char string. |
170| `SMTP_HOST` / `_PORT` / `_USER` / `_PASS` / `_FROM` | — | Email for password reset + newsletter |
171| `KLONKT_DEFAULT_LANG` | — | Default language for visitors (`en`/`nl`/`de`) |
172| `KLONKT_AUDIO` | — | `off` = lite mode (no audio/ffmpeg) |
173| `KLONKT_PREMIUM_ENABLED` | — | `on` (default) enables the Patreon-unlocked extras (incl. paid posts) |
174| `HSTS_STRICT` | — | `1` = stricter HTTPS header (`includeSubDomains` + `preload`). Only set this if Klonkt owns the **whole** domain and all its subdomains are HTTPS — it forces every subdomain to HTTPS and can bake your domain into browsers near-permanently. Leave unset otherwise; the default is already safe. |
175
176### Auto-generated secrets & backups
177
178You never have to hand-edit the env for these: Klonkt generates them on first use
179and keeps them stable across restarts and updates.
180
181- `SESSION_SECRET` → `storage/.session-secret` (signs login sessions)
182- `PAID_SECRET` → `storage/.paid-secret` (encrypts the stored Patreon secrets for
183 paid posts)
184
185The paid-posts key lives **outside** the database on purpose: encrypting the
186Patreon secrets would be pointless if the key sat in the same file a database
187dump would leak. Set either variable in `.env` to override the generated one.
188
189**Back up the whole `storage/` directory** (database, media *and* these key
190files). Restoring the database without `storage/.paid-secret` leaves the stored
191Patreon secrets unreadable — you'd have to reconnect Patreon.
192
193## Stack
194
195- **Runtime:** Node 20+
196- **Web:** Express + Helmet + express-session
197- **DB:** better-sqlite3 (WAL), self-migrating on boot
198- **Templates:** EJS (server-rendered) + **htmx 1.9** (vendored, no build step)
199- **Audio:** ffmpeg-static (bundled)
200- **Fediverse / Circles:** ActivityPub (HTTP Signatures) — federates with Mastodon, PeerTube and other Klonkt sites. See [FEDERATION.md](FEDERATION.md) for the supported activities and FEPs.
201- **Fonts:** self-hosted variable woff2 (Fraunces / Plus Jakarta Sans)
202
203## Project structure
204
205```
206src/
207├── server.js # Express bootstrap + route mounting
208├── config/ # database, mailer, feature flags
209├── db/migrations/ # SQLite schema (001-init.sql)
210├── middleware/ # site resolving, auth, render (htmx-aware)
211├── routes/ # per-resource Express routers (posts, auth, admin-*, circle, …)
212├── services/ # domain logic (federation, stats, mailer, permissions, …)
213├── views/ # shell.ejs + partials/ + pages/ (EJS)
214└── assets/ # css/ (palette tokens + components), js/ (htmx, player), fonts/
215```
216
217## License
218
219**AGPL-3.0-or-later** — see [LICENSE](LICENSE). Klonkt is free software: you may
220use, study, modify and distribute it. The AGPL does require that a modified
221version you offer as a network service makes its source code available to the
222users of that service. Made by robo.burr (Robin Genis) ·
223<https://klonkt.com>
224
225## Acknowledgements
226
227Klonkt stands on a lot of open-source work — Node.js, FFmpeg, SQLite, libwebp, resvg, htmx, EJS and
228more, plus the Fraunces, Plus Jakarta Sans and Literata fonts. See
229[THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md) for the full list and their licences. Thank you to
230everyone who made them.
Note: See TracBrowser for help on using the repository browser.