πŸ’‘ Architecture: How cella Talks to LXD & Docker

An overview of cella's internal architecture and how it communicates with container runtimes.

Overview

cella is a single Go binary built on the Bubbletea framework (Elm architecture for terminals). It communicates with LXD and Docker through their respective Unix domain sockets β€” no daemon, no config files, no external dependencies.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  cella TUI                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Bubbleteaβ”‚  β”‚ Lipgloss β”‚  β”‚ cobra CLI     β”‚  β”‚
β”‚  β”‚ (runtime)β”‚  β”‚ (styling)β”‚  β”‚ (entry point) β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚       β”‚                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚        Runtime Interface (runtime.go)     β”‚   β”‚
β”‚  β”‚    ListContainers() / Exec() / Stats()    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚       β”‚                      β”‚                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚ LXD Client  β”‚  β”‚ Docker Client      β”‚        β”‚
β”‚  β”‚ (unix sock) β”‚  β”‚ (unix sock)        β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

LXD Communication

cella talks to LXD via its REST API over the Unix socket at /var/snap/lxd/common/lxd/unix.socket (snap) or /var/lib/lxd/unix.socket (deb).

Docker Communication

Docker uses the same interface but talks to /var/run/docker.sock:

Parallel Fetching

cella fetches from both runtimes concurrently using goroutines. The results are merged into a unified container list with a Runtime field ("lxd" or "docker") to distinguish them.

The Bubbletea Model

The entire TUI state lives in a single app struct (~300 fields). Bubbletea's update loop processes keyboard events and timer ticks, returning commands that trigger async operations (API calls, bpftrace output parsing, etc.).

All rendering happens in the View() method, which builds the entire screen as a string on every frame. Lipgloss handles styling, borders, and layout.