How stylessh/diffkit works
1. Monorepo shape
- This is a Turborepo/pnpm workspace with one main application, apps/dashboard, plus shared UI/icon/type packages and a browser extension.
- The architecture is centered on the dashboard app; the other packages are support libraries, not separate runtime services.
2. Primary runtime boundary
- The dashboard runs on Cloudflare Workers using TanStack Start and TanStack Router.
- Server code is split from client code through route files, *.server.ts / *.client.ts modules, and the worker entry at src/entry-worker.ts.
3. Public vs protected app surfaces
- Public routes include login, setup, privacy, terms, and GitHub auth callbacks.
- Most product functionality lives under src/routes/_protected, which is the authenticated shell for dashboard, repo, issue, pull request, review, and settings pages.
4. Core domain areas
- The UI is organized around four main product flows: repositories, pull requests, issues, and code reviews.
- Each has dedicated list/detail components and route entry points, with additional pages for inbox, global search, and user settings.
5. Data access pattern
- The app uses TanStack Query on the client and Octokit/GitHub API on the server side for live GitHub data.
- The src/lib/github.* modules are the main abstraction boundary for API access, request policy, and GitHub-specific query composition.
6. Persistence layer
- Local state is stored in Cloudflare D1 (SQLite) through Drizzle ORM.
- Database migrations live under apps/dashboard/drizzle, and the schema is defined in src/db/schema.ts.
- This layer appears to support app state, auth/session-related data, and GitHub caching/revalidation metadata.
7. Authentication and installation model
- Auth is handled by Better Auth with a GitHub OAuth App for user login and a GitHub App for repository-scoped access.
- The app has separate routes for OAuth auth, GitHub App authorization, and GitHub App callback handling, which makes auth a distinct subsystem from the normal dashboard pages.
- The README indicates the GitHub App is also used for installation discovery, webhooks, and higher-scope repository actions.
8. Cache and invalidation flow
- The repo has explicit GitHub caching and revalidation modules, plus docs dedicated to cache architecture.
- The important flow is: GitHub data is fetched, cached, then invalidated or refreshed when webhooks arrive or when revalidation signals are emitted.
- This keeps the dashboard responsive while still reacting to GitHub-side changes.
9. Webhook and event ingestion
- GitHub webhooks land in src/routes/api/webhooks/github.ts.
- Those events feed the cache invalidation / signal-relay path, which updates stale views and can notify open tabs or clients that data changed.
10. UI shell and cross-cutting interaction layer
- Shared layout components provide the persistent dashboard chrome: top bar, side panel, tabs, mobile nav, error/loading states, and dialogs.
- Cross-cutting interaction features include the command palette, keyboard shortcuts, filter cookies, optimistic mutations, and tab/session state.
11. Shared component and design system layer
- packages/ui is the design system: buttons, dialogs, tables, markdown, resizable panes, sidebar, etc.
- packages/icons and shared utility hooks/styles are used across the dashboard to keep the visual language consistent and reduce duplication.
12. Browser extension integration
- extensions/diffkit-redirect is a companion browser extension, not part of the dashboard runtime.
- Its role is to bridge GitHub pages and the DiffKit experience, which suggests the product is intended to coexist with GitHub rather than replace it.
13. Operational concerns
- The repo is configured for linting, type-checking, formatting, tests, and Cloudflare deployment.
- Environment configuration is explicit: local development requires GitHub OAuth/App secrets, webhook secret, Better Auth secret, and D1 migrations before the app runs correctly.
14. How to think about the architecture diagram
- The main boxes are: browser UI, Cloudflare Worker app, GitHub API/App/OAuth, D1 database, and webhook delivery from GitHub.
- The main arrows are: browser requests to TanStack routes, server requests to GitHub, webhook events back into the worker, and cache/revalidation signals back out to active clients.
Main entry points: components Product views · router.tsx App router · layouts Dashboard shell · github.server.ts GitHub core
Components 21
Dashboard app
Primary Cloudflare Worker application, routes, UI, and data layers.
- Worker entry · Runtime entrypoint for the dashboard app.
apps/dashboard/src/entry-worker.ts - App router · Route tree and application wiring.
apps/dashboard/src/router.tsx - Public routes · Login, setup, legal pages, and auth callbacks.
apps/dashboard/src/routes - Protected shell · Signed-in dashboard surface for product workflows.
apps/dashboard/src/routes/_protected - API routes · Auth, GitHub App, and webhook entrypoints.
apps/dashboard/src/routes/api - Dashboard shell · Persistent chrome, nav, dialogs, loading, and error states.
apps/dashboard/src/components/layouts - Product views · Repository, issue, pull request, review, inbox, and settings screens.
apps/dashboard/src/components - Repo flow · Repository overview, file tree, activity, and code explorer.
apps/dashboard/src/components/repo - Issue flow · Issue lists, detail pages, labels, and new issue composer.
apps/dashboard/src/components/issues - PR flow · Pull request lists, detail pages, and merge/review helpers.
apps/dashboard/src/components/pulls - Review flow · Review diffs, file trees, and submit interactions.
apps/dashboard/src/components/pulls/review - Query client · Client-side cache, hydration, and mutation boundary.
apps/dashboard/src/lib/query-client.tsx - GitHub core · Server-side GitHub request composition, access policy, and helpers.
apps/dashboard/src/lib/github.server.ts - GitHub cache · Caching policy and refresh coordination for GitHub data.
apps/dashboard/src/lib/github-cache.ts - Signal relay · Revalidation and change signals pushed to active clients.
apps/dashboard/src/lib/signal-relay.server.ts - Auth system · OAuth login, GitHub App authorization, and auth runtime glue.
apps/dashboard/src/lib/auth.server.ts - D1 database · SQLite persistence for app state, sessions, and cache metadata.
apps/dashboard/src/db/schema.ts
Shared packages
Workspace libraries reused by the dashboard and extension.
Browser extension
Companion extension that bridges GitHub pages into DiffKit.
- DiffKit extension · Companion extension that integrates GitHub pages with DiffKit.
extensions/diffkit-redirect
Docs and ops
Architecture notes and repository operations support.
- Cache docs · Design notes for GitHub cache and invalidation behavior.
docs/github-cache-architecture.md
Connections 26
- Worker entry → App router: boots · The Cloudflare Worker starts the application router.
- App router → Public routes: serves · Routes unauthenticated pages and auth callbacks.
- App router → Protected shell: serves · Routes the authenticated dashboard shell and product pages.
- App router → API routes: serves · Exposes auth, GitHub App, and webhook endpoints.
- Protected shell → Dashboard shell: composes · Protected pages share the persistent dashboard shell.
- Protected shell → Product views: renders · Route pages mount the main product screens.
- Product views → Repo flow: includes · Repository experience covers overview and file navigation.
- Product views → Issue flow: includes · Issue experience covers lists, detail, and creation.
- Product views → PR flow: includes · Pull request experience covers lists and detail pages.
- Product views → Review flow: includes · Review experience handles diffs and submissions.
- Product views → UI kit: uses · Domain screens are built from shared design-system primitives.
- Dashboard shell → UI kit: uses · Shell chrome is assembled from shared UI components.
- Dashboard shell → Icons: uses · Navigation and chrome use shared icons.
- Dashboard shell → Signal relay: subscribes · Shell can react to live revalidation and change signals.
- Product views → Query client: queries · Client views read and mutate data through TanStack Query.
- Query client → GitHub core: fetches · Client data ultimately resolves to GitHub-backed server access.
- GitHub core → Auth system: checks access · GitHub requests depend on user and installation authorization.
- GitHub core → D1 database: reads/writes · GitHub state and cache metadata are tracked in D1.
- GitHub core → GitHub cache: caches · Requests flow through cache and request policy layers.
- GitHub cache → Signal relay: invalidates · Cache refresh events emit signals for live clients.
- API routes → Auth system: handles · Auth routes manage login and GitHub authorization.
- API routes → Signal relay: ingests webhooks · GitHub webhook events trigger invalidation and relay paths.
- Auth system → D1 database: persists · Auth state and related records are stored in D1.
- Signal relay → Query client: pushes · Open clients can react to revalidation and refresh signals.
- DiffKit extension → Product views: extends · The browser extension bridges GitHub pages to the product experience.
- Cache docs → GitHub cache: describes · Documentation explains cache and invalidation architecture.