How charmbracelet/soft-serve works
1. What this repo is
Soft Serve is a single Go binary that hosts a self-contained Git service. It exposes the same repository through multiple entrypoints: SSH, HTTP(S), the Git protocol, and an SSH-driven TUI. The server is also its own admin UI for users, repos, access tokens, collaborators, and settings.
2. Top-level process layout
cmd/soft/main.go is the CLI entry. It dispatches into four main modes: serve to run the server, browse for local repository browsing, admin for admin helpers, and hook for hook management. The soft serve mode is the long-running daemon; the other commands are mostly client-side tools.
3. Server-facing transport boundary
The runtime server is split into transport-specific front doors:
- pkg/ssh for interactive SSH sessions and SSH commands
- pkg/web for HTTP endpoints, clone support, auth-token login, health checks, and Git LFS HTTP
- pkg/daemon for the Git protocol daemon
- pkg/stats for an optional stats endpoint
Each transport feeds into the same backend and store layers, so protocol differences are mostly at the edge.
4. SSH is the control plane
SSH is the primary administration and interactive channel. pkg/ssh/cmd contains the command router for repo, user, token, settings, webhook, and other server-admin operations. The same SSH session can also open the TUI instead of a command. Authentication and session middleware live in pkg/ssh/middleware.go and pkg/ssh/session.go.
5. Repository serving and Git operations
Git repository behavior is coordinated by pkg/backend and pkg/git, with the repository metadata and access decisions flowing through the store layer. This is where repo creation, import, rename, delete, branch/tag listing, tree/blob views, mirror pull behavior, and collaborator management are orchestrated. The root git/ package provides lower-level repository and object utilities used by these features.
6. Persistence model
Persistent state is split between the repository filesystem and the database. pkg/store is the application-facing data access layer for users, repos, collaborators, access tokens, settings, webhooks, and LFS metadata. pkg/db is the actual database layer with migrations and driver support for SQLite and Postgres. Repositories themselves live on disk under the configured data path, while metadata and permissions live in the DB.
7. Authentication and authorization
Access control is centralized rather than per-transport. pkg/access, pkg/backend/auth.go, and related store code implement the access levels described in the README: no-access, read-only, read-write, and admin-access. SSH public keys are the primary identity mechanism, while HTTP access can use user access tokens. Anonymous and keyless access are configuration-driven and affect SSH, HTTP, and Git protocol behavior.
8. Git LFS support
LFS is a first-class subsystem, not an add-on. pkg/lfs handles pointer parsing, transfer negotiation, and HTTP/SSH client behavior, while pkg/backend/lfs.go and pkg/web/git_lfs.go expose server-side endpoints. The architecture supports HTTP LFS out of the box and can optionally enable pure SSH transfer.
9. Hooks, webhooks, and background work
There are two eventing paths:
- server-side Git hooks: generated and managed via pkg/hooks, with per-repo and global hooks
- repository webhooks: validated and dispatched by pkg/webhook and persisted via the store/DB
Background work such as mirror pulls is scheduled through pkg/jobs and pkg/cron, with pkg/sync/workqueue.go handling queued asynchronous work.
10. TUI and local browsing
The interactive UI is in pkg/ui. It is a terminal UI with repo-centric pages for files, commits, refs, stash, README, and empty states. The SSH session can launch this UI remotely, and soft browse can launch it locally against a filesystem repository. This UI is a consumer of the same backend data model used by the server commands.
11. Configuration and runtime wiring
pkg/config loads YAML plus environment overrides and resolves server paths, listen addresses, URLs, and key files. It also governs which transports are enabled and where the data directory lives. pkg/backend/context.go, pkg/db/context.go, and similar context packages show that the app passes infrastructure objects through context rather than relying on globals.
12. Data flow in practice
A typical request path is: transport entrypoint → auth/access check → backend/service logic → store/db and/or repository filesystem → response. For example, an SSH repo blob command reads repository data and permission state, then renders output through the SSH UI layer; a git push may create a repo on demand, update refs, run hooks, persist metadata, and enqueue follow-up work.
13. Operational and packaging boundaries
The repo is packaged as a single deployable binary with release automation, Docker, and systemd integration. The .nfpm, Dockerfile, and GitHub Actions files support distribution, but they do not change the runtime architecture. The important deployment knobs are the data path, SSH host/client keys, database driver, and enabled listen addresses.
14. Useful diagram anchors
If you draw this system, the main boxes are: client protocols, SSH/web/git-daemon/stats front ends, backend/service layer, store/DB, repository filesystem, Git LFS, webhooks/hooks/jobs, and the TUI. The most important arrows are from transport to backend, backend to store/DB and repo storage, and backend to hooks/webhooks/jobs for side effects.
Main entry points: backend.go Backend · serve.go Serve · repo.go Repos · ssh.go SSH
Components 23
Entrypoints
CLI modes that start the daemon or local tooling
Front Doors
Protocol-specific server entrypoints
- SSH · Interactive SSH sessions and SSH command access
pkg/ssh/ssh.go - HTTP · HTTP(S) endpoints for web UI, clone, auth, and LFS
pkg/web/server.go - Git Daemon · Git protocol daemon entrypoint
pkg/daemon/daemon.go - Stats · Optional stats endpoint
pkg/stats/stats.go - SSH Cmds · Repo, user, token, settings, webhook, and other SSH-admin commands
pkg/ssh/cmd/cmd.go - Session · Session middleware and interactive TUI handoff
pkg/ssh/session.go
Core Services
Backend orchestration and policy
- Backend · Central orchestration for repository, auth, settings, and side effects
pkg/backend/backend.go - Access · Access control and identity checks across transports
pkg/backend/auth.go - Repos · Repository creation, import, rename, delete, refs, tree/blob, and collaborator flows
pkg/backend/repo.go - LFS · Server-side Git LFS integration and negotiation
pkg/backend/lfs.go
Data Layer
Database and repository storage
- Store · Application-facing persistence for users, repos, tokens, settings, webhooks, and LFS metadata
pkg/store/store.go - DB · Driver, migrations, and database access for SQLite and Postgres
pkg/db/db.go - Repo Files · On-disk repository data under the configured data path
pkg/storage/local.go - Git Core · Repository and object utilities used by backend and transports
pkg/git/git.go
Auxiliary Systems
UI, hooks, webhooks, jobs, and LFS
- LFS Core · Pointer parsing, transfer, and client/server LFS helpers
pkg/lfs/transfer.go - Hooks · Generated server-side hooks and hook management
pkg/hooks/hooks.go - Webhooks · Repository webhook validation, persistence, and dispatch
pkg/webhook/webhook.go - Jobs · Mirror pulls and queued asynchronous work
pkg/jobs/jobs.go - TUI · Repo-centric terminal interface for files, commits, refs, stash, and README
pkg/ui/pages/repo/repo.go - Config · YAML and environment configuration for transports, paths, keys, and listen addresses
pkg/config/config.go
Connections 30
- soft → Serve: serve · Starts the daemon process
- soft → Browse: browse · Starts local repository browsing
- Serve → Config: loads · Resolves runtime paths, listeners, and enabled transports
- Serve → SSH: starts · Opens SSH transport
- Serve → HTTP: starts · Opens HTTP transport
- Serve → Git Daemon: starts · Opens Git daemon transport
- Serve → Stats: starts · Optionally opens stats endpoint
- SSH → SSH Cmds: routes · Dispatches SSH admin and repo commands
- SSH → Session: session · Handles interactive sessions and TUI launch
- HTTP → Backend: calls · Delegates web requests to backend services
- Git Daemon → Backend: serves · Bridges Git protocol operations to backend logic
- Stats → Backend: reads · Exposes runtime and repository stats
- SSH Cmds → Backend: uses · Performs admin and repo operations through backend
- Session → TUI: opens · Launches repo UI inside SSH session
- Backend → Access: checks · Central access and identity validation
- Backend → Repos: orchestrates · Coordinates repository and collaborator flows
- Backend → LFS: delegates · Handles LFS-specific server behavior
- Backend → Store: persists · Reads and writes application metadata
- Backend → Repo Files: operates on · Reads and writes repository contents on disk
- Repos → Git Core: uses · Performs repository and object operations
- Repos → Hooks: triggers · Runs server-side hook generation and execution
- Repos → Webhooks: emits · Dispatches repository events
- Repos → Jobs: enqueues · Schedules mirror pulls and async follow-up work
- LFS → LFS Core: uses · Shares pointer and transfer logic
- LFS → Store: reads · Uses stored LFS metadata and auth state
- Store → DB: backed by · Database-backed metadata persistence
- Webhooks → DB: persists · Stores webhook configuration and events
- Jobs → DB: tracks · Uses database state for queued work
- Browse → TUI: launches · Uses the same repo UI locally
- TUI → Backend: consumes · Reads repository data through backend services