- TypeScript 85%
- Go 12%
- JavaScript 2%
- CSS 1%
- Python <1%
- 3 more languages <1%
kodamachi #
FOSS, AT Protocol-native anonymous Q&A. Receive questions anonymously and answer directly to your Bluesky feed.
What It Does #
kodamachi lets Bluesky users receive anonymous questions via a public inbox link and post answers (optionally with a styled image card) directly to their Bluesky feed. Bluesky (AT Protocol) serves as both the identity provider (OAuth) and a secondary data store via PDS sync.
The companion kodamachi-feed repo is a Bluesky custom feed generator that surfaces answered questions on the network.
Tech Stack #
| Layer | Technologies |
|---|---|
| Client | React 19, Vite, TypeScript, Mantine UI v9, React Query v5, React Router v8 |
| Server | Bun.serve + Hono, TypeScript, Kysely ORM, AT Protocol SDK, Pino |
| Image rendering | html-to-image: Bun + headless Chromium, renders question cards to PNG |
| Link cards | opengraph-service: Go, serves OpenGraph tags and preview images for shared links |
| Database | SQLite (development) · PostgreSQL (production) |
| Auth | AT Protocol OAuth (Bluesky as identity provider) |
| Testing | Vitest + Testing Library (client) · bun test (server) · go test (opengraph-service) · Playwright (E2E) |
| Observability | Pino structured logging, optional Axiom transport |
Monorepo Structure #
Bun workspaces (client, server, html-to-image) plus one Go module:
navyfragen-app/
├── client/ # React + Vite SPA
├── server/ # Bun.serve + Hono API
├── html-to-image/ # Headless Chromium renderer for question images
├── opengraph-service/ # Go service for link previews
├── e2e/ # Playwright specs
├── anubis/ # Anubis WAF config
├── caddy/ # Caddy reverse proxy config
├── docker/ # Dockerfiles and compose overlays
└── docs/ # Developer notes and the design handoff
brand.json at the root holds the app name, domains and the mark; the client, server and Go service all read it.
Getting Started #
Prerequisites #
- Bun (package manager and runtime — see issue #250)
- Git
- A modern web browser
- Node.js — only if you want to run the Playwright E2E suite locally
Node is needed for exactly one thing: Playwright, which cannot load our E2E specs under Bun. Install it only if you plan to run
bun run test:e2elocally. Everything else works with Bun alone.
Windows users: You may need the C++ build tools (required by
sharp). WSL2 is recommended for the best experience.
Installation #
-
Clone the repository:
git clone https://github.com/karanshukla/navyfragen-app.git cd navyfragen-app -
Install all dependencies:
bun install -
Configure the server:
cp server/.env.template server/.envThe template works for local development as it is, except for
OAUTH_TOKEN_SECRET, a 32-byte hex string used for AES-256 encryption that has no default. Generate one and set it inserver/.env:bun -e "console.log(crypto.getRandomValues(new Uint8Array(32)).toHex())" -
Point the client at the server:
echo "VITE_API_URL=http://127.0.0.1:8080" > client/.env.development.localUse
.env.development.localrather thanclient/.env: the test runner loads.envtoo, and a value there changes what the client tests see. -
Start the development servers:
bun run devThis starts the client (port
5173), the server (port8080, from the template'sPORT) and thehtml-to-imageservice (port3033). -
Open the app at
http://127.0.0.1:5173, nothttp://localhost:5173— the AT Protocol OAuth flow and the session cookie both need127.0.0.1. See Local Development: 127.0.0.1 vs localhost below.
Image Generation #
Responding to a message with an image card requires the in-house html-to-image service (located in html-to-image/ at the repo root). It renders HTML in a headless Chromium browser and returns a screenshot.
bun run dev at the repo root starts it automatically alongside the client and server. To run it in isolation:
bun run --cwd html-to-image start
For Docker (e.g. in CI or the full stack), use:
bun run html-to-image
Set EXPORT_HTML_URL=http://localhost:3033/ in server/.env (this is the default).
Image Themes #
Three themes are available when responding to a message:
| Theme | Description |
|---|---|
default |
Quote — white card on the navy fill (the design's default) |
compressed |
Compact — white-ruled block on midnight, for feeds read in the dark |
twitter |
Post — a paper post from the app's own account, with the mark as avatar |
Users pick a theme in the Image theme card on the Messages page; it is stored per-user in the database.
Infrastructure #
Anubis WAF (optional but recommended) #
Anubis acts as a WAF to protect public-facing pages from DDoS and spam. Configuration is in /anubis.
Pair it with a Caddy reverse proxy (a sample config is in /caddy). Route traffic as:
Internet → Caddy → Anubis → Vite/Client
→ Server (API)
CloudFront can also be used in place of Caddy.
Short Links #
Users share a short link to their public inbox (e.g. kodamachi.online/user123 -> kodamachi.app/profile/user123). Any URL-prefix-preserving redirect service works, for example docker-redirector.
Set the shortlink base in the client's VITE_SHORTLINK_URL (e.g. kodamachi.online).
Development Notes #
Running Tests #
# Client tests
cd client && bun run test
# Server tests
cd server && bun run test
# With coverage
cd client && bun run test:coverage
cd server && bun run test:coverage
# Link-preview service
cd opengraph-service && go test ./...
The client is gated at 100% on all four metrics (statements, lines, branches, functions) with Vitest's istanbul provider. The server is gated at 97% lines through Coveralls, because Bun's built-in reporter carries lines and functions only.
The Playwright suite runs against the full Docker stack with a real Bluesky test account; setup is in docs/e2e-testing.md.
AT Protocol Lexicons #
Custom lexicons live in server/lexicons/. Generated TypeScript types are in server/src/lexicon/ (do not edit them manually). Regenerate with:
cd server && bun run lexgen
Windows users: Run
lexgenin WSL2. Running it natively on Windows may delete the generated files.
Pre-commit Hook #
The repo uses Husky to run checks automatically before every git commit. The hook runs on all platforms (macOS, Linux, Windows via Git Bash).
What it does:
| Step | Tool | Effect |
|---|---|---|
| Format staged files | bun fmt |
Auto-fixes formatting (quotes, indentation, trailing commas) |
| Lint staged files | oxlint | Auto-fixes import order, unused vars, etc. |
| Type check client | bun check |
Blocks commit if there are TypeScript errors |
| Type check server | bun check |
Blocks commit if there are TypeScript errors |
The hook is installed automatically when you run bun install (via the prepare script).
To skip it in an emergency:
git commit --no-verify -m "your message"
Local Development: 127.0.0.1 vs localhost #
AT Protocol's OAuth implementation follows RFC 8252 loopback rules: a local client's redirect_uri must use the IP literal 127.0.0.1, not the hostname localhost. server/src/auth/client.ts already hardcodes the OAuth redirect_uri to http://127.0.0.1:<PORT> for local dev, so if the server itself is bound to localhost instead of 127.0.0.1, the OAuth callback silently fails — localhost and 127.0.0.1 can resolve to different addresses (::1 vs 127.0.0.1), so the server ends up listening on one while the callback hits the other.
server/.env(the template's defaults):HOST="127.0.0.1" CLIENT_URL="http://127.0.0.1:5173"client/.env.development.local(create if it doesn't exist):VITE_API_URL=http://127.0.0.1:8080- Browser: open the app at
http://127.0.0.1:5173, nothttp://localhost:5173.
This applies on every platform. Windows has an additional wrinkle on top: cookie SameSite handling differs between 127.0.0.1 and localhost, so Windows users should use 127.0.0.1 even when not debugging OAuth specifically.