.agents
Add the Redakt mail POC: inbox shell, demo fixtures, and Stalwart-backed stack.
.husky
Add Trylle checks and staged linting (#9)
.railway
Convert to a Turborepo monorepo and add the worker app
.trylle
Deploy the worker to production after the web app
apps
Trigger CI for the pull request
deploy
Bound public demo sessions
docs
Remember the open inbox and stop false Gmail reconnect prompts (#15)
packages
Trigger CI for the pull request
scripts
Convert to a Turborepo monorepo and add the worker app
.dockerignore
Migrate application to TanStack Start
.env.example
Convert to a Turborepo monorepo and add the worker app
.gitignore
Convert to a Turborepo monorepo and add the worker app
.lintstagedrc.json
Add Trylle checks and staged linting (#9)
AGENTS.md
Migrate application to TanStack Start
biome.jsonc
Add Trylle checks and staged linting (#9)
CLAUDE.md
Add the Redakt mail POC: inbox shell, demo fixtures, and Stalwart-backed stack.
CODE_OF_CONDUCT.md
Merge remote-tracking branch 'origin/main' into stylessh/cloud-agent-1788236378832-mchqw
CONTRIBUTING.md
Convert to a Turborepo monorepo and add the worker app
docker-compose.yml
Convert to a Turborepo monorepo and add the worker app
eslint.config.mjs
Convert to a Turborepo monorepo and add the worker app
LICENSE
Merge remote-tracking branch 'origin/main' into stylessh/cloud-agent-1788236378832-mchqw
package.json
Convert to a Turborepo monorepo and add the worker app
pnpm-lock.yaml
Keep Focus current from the worker, classifying only what changed
pnpm-workspace.yaml
Convert to a Turborepo monorepo and add the worker app
README.md
Trigger CI for the pull request
skills-lock.json
Add the Redakt mail POC: inbox shell, demo fixtures, and Stalwart-backed stack.
tsconfig.base.json
Convert to a Turborepo monorepo and add the worker app
tsconfig.json
Convert to a Turborepo monorepo and add the worker app
turbo.json
Convert to a Turborepo monorepo and add the worker app

Redakt

A design-first, open-source mail client and provider. Host mail on a domain you own or connect Gmail, then read and send from a quiet, account-aware inbox.

Redakt is the product layer: onboarding, connected accounts, DNS, and the inbox. Stalwart is the hosted-mail engine (SMTP, JMAP, IMAP, DKIM); Gmail stays the source of truth for connected Google accounts. This repository is MIT and does not fork Stalwart. Stalwart stays AGPL when you run it.

The project is early (0.1.0). Demo mode is the fastest way to look at the product. Live mode talks to a real mail engine on your machine.

Interface inspiration: Define and Tatem.

Run it

You need pnpm 11 and Node 20+. Live mode also needs Docker.

Demo

No Postgres, no Stalwart, no port 25.

cp .env.example .env
pnpm install
pnpm dev

Open http://localhost:3000. Demo mode keeps a local session and serves three sample mailboxes for the seed login ada@redakt.local / demo: the hosted work inbox (plus the fixture .eml files from apps/web/fixtures/), a personal Gmail account and a Google Workspace account, both served from catalogs in packages/core/src/demo/ so Gmail flows run without Google credentials. Mail includes designed HTML (receipts, campaigns, notifications, invites) alongside plain conversations. Demo state lives in apps/web/.data/demo.json; delete it and restart to get the untouched mailboxes back.

Live (Postgres + Stalwart)

pnpm install
pnpm dev:live

dev:live creates .env with local defaults and independent authentication and stored-data secrets when it is missing. If .env already exists, it appends only documented settings that are not present and leaves every existing value untouched. It then starts Postgres and Stalwart, pushes the schema, and runs the app with DEMO_MODE=false.

ServicePort
Redakt3000
Postgres5432
Stalwart HTTP / JMAP8080
SMTP / SMTPS / IMAPS25 / 465 / 993

On first Stalwart boot, finish the wizard at http://localhost:8080/admin (admin / changeme unless you changed .env). Copy the generated admin into .env, close that tab, and use Redakt at http://localhost:3000.

The Stalwart Dashboard on HTTP will loop on a browser sign-in prompt. Cancel it. Redakt talks to Stalwart over JMAP, not that screen.

Step-by-step wizard values: deploy/stalwart/README.md.

docker compose up --build also runs the app in a container. Prefer pnpm dev:live while developing.

Gmail

Gmail connections use OAuth and the Gmail API in live mode. Add the Google client credentials to .env, then use Manage accounts → Add Gmail account. The complete OAuth, restricted-scope review, Pub/Sub, watch-renewal, encryption, and privacy runbook is in docs/gmail.md.

AI features

Focus is an optional, read-only view that groups recent inbox conversations by what needs a reply, has a deadline, is waiting on someone, is informational, or is probably low priority. It evaluates conversation previews with Jev through Vercel AI Gateway, then reads bounded message content only when a result is uncertain.

Smart Compose uses a Redakt-managed model through the same Gateway. It can offer short inline completions while a message is being written and draft or revise a message in a selected tone. Inline completions are requested only after a typing pause. Every suggestion remains editable and is never sent automatically.

Each AI feature is off until the user explicitly agrees to AI processing and turns that feature on. Focus considers at most 20 recent inbox conversations. Smart Compose sends the current draft and relevant message context. Redakt does not use this content to train models, and AI features never send mail or apply mailbox actions automatically. Live deployments read a server-only AI_GATEWAY_API_KEY; the public demo uses deterministic results and never calls an AI service.

Internet mail

Local live mode creates real mailboxes in Stalwart. It does not receive mail from Gmail or other public servers.

Inbound and outbound on the public internet need Stalwart on a host with usable port 25, a matching PTR record, and a warm IP — or an outbound relay. Set MAIL_HOSTNAME to that public MX host (not mail.example.com). The DNS wizard still checks live DNS over Cloudflare DoH.

An HTTP tunnel does not replace SMTP on port 25.

To put this on Vercel, Railway, Coolify, Openship, or a VPS, see docs/self-hosting.md.

How it fits together

  browser  →  account-scoped TanStack Start routes + provider-neutral mail contract
                                      │
                 ┌────────────────────┴────────────────────┐
                 │                                         │
        Redakt hosted adapter                     Gmail API adapter
          demo or JMAP                         on-demand mail + drafts
                 │                                         │
          Stalwart mail                           Google OAuth grant
                 └────────────────────┬────────────────────┘
                                      │
                         Postgres connection metadata
                      (no connected-Gmail message store)

getMailProvider(user, accountId) in packages/core/src/mail/provider-factory.ts resolves a provider-neutral MailAccount, obtains credentials through its connector, and returns the shared MailProvider contract. Domain administration is a separate contract, so an external mailbox connector never inherits hosted-domain powers.

Mail views have canonical, refresh-safe URLs. Authenticated route data is loaded on the server; navigation, search controls, pagination, compose, and the persistent tab rail enhance those pages on the client.

RouteView
/mail/a/:accountId/:folderAccount-scoped inbox, unread, starred, sent, drafts, spam, trash, or archive
/mail/a/:accountId/focusOpt-in AI classification of recent inbox conversations
/mail/a/:accountId/focus/thread/:threadIdConversation opened from Focus with a Focus return path
/mail/a/:accountId/:folder/thread/:threadIdAccount-scoped conversation in its originating folder context
/mail/settings/accountsConnected mailboxes, privacy, and account lifecycle
/mail/settings/domainDomain and DNS setup

Folder query state such as search, filters, and sort order is encoded in the URL, so a copied link and a full reload render the same result.

Redakt is a pnpm and Turborepo monorepo. Run pnpm build, pnpm typecheck, and pnpm test from the root to run them across every package.

PathRole
apps/web/The mail app: TanStack Start routes, components, and StyleX theme
apps/web/src/routes/TanStack Router pages, nested layouts, and server routes
apps/web/src/server/Authenticated server functions and provider boundaries
apps/web/src/queries/Shared TanStack Query keys and query options
apps/web/components/Shell, mail, Focus, settings, and shared UI controls (StyleX + Base UI)
apps/web/theme/StyleX tokens
apps/web/fixtures/Sample .eml files for demo
apps/worker/Background job server: Hono API and pg-boss queues on Postgres
packages/core/Code shared by the web app and worker, imported as @redakt/core/*
packages/core/src/db/Drizzle schema and SQL migrations
packages/core/src/mail/Provider types, routing, and the provider factory
packages/core/src/ai/AI settings, provider adapters, structured output, and validation
packages/core/src/intelligence/Focus classification and reply context, shared with the worker
packages/core/src/google/, gmail/Google OAuth lifecycle, Gmail API client, MIME, and sync
packages/core/src/demo/Demo store and fixture provider
packages/core/src/stalwart/JMAP client and live provider
deploy/stalwart/Stalwart notes and future production config
docs/self-hosting.mdVercel, Railway, Coolify, Openship, VPS

Environment

Copy .env.example to .env. Do not commit .env.

VariableDemoLive
DEMO_MODEtrue (default)false (pnpm dev:live sets this)
BETTER_AUTH_SECRETunusedrequired
BETTER_AUTH_SECRETSunusedBetter Auth OAuth-token keyring, current first
REDAKT_ENCRYPTION_KEYSunusedseparate mailbox and AI-key keyring, current first
BETTER_AUTH_URLunusedhttp://localhost:3000
DATABASE_URLunusedPostgres URL
STALWART_URLunusedhttp://localhost:8080
STALWART_ADMIN_USERunusedwizard admin email after first boot
STALWART_ADMIN_SECRETunusedwizard admin password
MAIL_HOSTNAMEMX host shown in the DNS wizardsame; use your public mail host in production
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRETunusedenables Google sign-in and Gmail OAuth
GOOGLE_CTA_ENABLEDunusedset to true to expose Google entry points on redakt.app
GOOGLE_PUBSUB_TOPICunusedoptional Gmail push topic
GOOGLE_PUBSUB_AUDIENCEunusedexact authenticated push audience
GOOGLE_PUBSUB_SERVICE_ACCOUNT_EMAILunusedexact push JWT identity
MAIL_SYNC_CRON_SECRETunusedprotects daily watch renewal
WORKER_URLunusedworker base URL for the web app; on Railway, its private domain
WORKER_API_TOKENunusedshared secret for the worker's internal API, at least 32 characters
REPLY_PROBABILITY_THRESHOLDunusedworker only, optional; how sure a reply must be owed before one is drafted (default 0.7)

Mailbox passwords are at least 8 characters (Better Auth).

Background worker

apps/worker runs background jobs:

JobWhenWhat it does
mail.sweepevery 15 minqueues mail.ingest for users with Focus on and a session in the last 14 days
mail.ingestsweep, Gmail push, stale Focus visitclassifies changed conversations and rebuilds the stored Focus result
reply.draftafter ingestprepares a reply when one is likely owed and "Draft replies in advance" is on
gmail.watch-sweep / gmail.watch-renewevery 6 hrenews Gmail push watches
maintenance.cleanupdailyapplies retention limits to prepared replies, insights, and outcomes

Background AI use is capped per user per day (60 classification runs, 30 drafts). It uses the same Postgres (pg-boss keeps its queues in the pgboss schema) and needs DEMO_MODE=false, DATABASE_URL, WORKER_API_TOKEN, and the same auth, Google, and encryption variables as the web app. Run it locally with pnpm --filter @redakt/worker dev, which reads the root .env.

It serves /healthz and /readyz, plus an authenticated internal API: POST /v1/jobs/:name to enqueue a job, GET /v1/queues for queue depth, and GET /v1/stats/replies for how often prepared replies are used. Failed jobs retry with exponential backoff, then move to the dead-letter queue. Set WORKER_TEST_DATABASE_URL to run its Postgres integration tests.

Keyboard

⌥N compose, j / k move, ⌘W close tab, r reply, c compose.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md and CODE_OF_CONDUCT.md.

License

MIT. Stalwart remains AGPL when you run it.