gohead

module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT

README

GoHead

GoHead

The headless CMS that reacts.
Model content over HTTP, get REST and GraphQL instantly,
and let AI agents act on every change. One Go binary.

CI Release Container image Go Report Card Docs MIT

Quick start · Handbook · Agents · Deploy


Why GoHead?

Most headless CMSs stop at storing content. GoHead also does something with it: every create, update or delete can wake up an agent that summarizes, tags, moderates, translates or syncs, writing the result straight back into your content, with the same validation and permissions as a human.

⚡ Schema in, API out Define collections over HTTP. REST endpoints and a GraphQL schema appear immediately, no codegen, no restart.
🤖 Agents built in LLM agents triggered by content events, webhooks or cron, with OpenAI, Anthropic or Ollama, and typed functions to read and write content.
📝 Editorial workflow Draft and publish per collection, reusable (and repeatable) components, one flat JSON shape for every item.
🔌 Integrations Long-lived scoped API tokens, an OpenAPI 3.1 spec with Swagger UI for typed clients, and signed outbound webhooks for Slack, Zapier or site rebuilds.
🖼️ Media built in Upload images, video and documents; store them on disk or in any S3-compatible bucket (S3, MinIO, R2); reference them from content.
🔎 Real querying Filters ($eq $ne $lt $gte $contains…), multi-key sort, pagination, relation population, batch writes in one transaction.
🔐 Secure by default Roles enforced identically in REST and GraphQL, schema-validated writes, masked secrets, signed images, distroless containers.
🪶 One binary API, worker, dispatcher and scheduler in one Go binary. SQLite on your laptop, PostgreSQL or MySQL in production.
🚢 Ships anywhere Multi-arch images, a Helm chart, Kubernetes manifests and Flux image automation included. Tested on SQLite, PostgreSQL and MySQL.

60-second start

git clone https://github.com/gohead-cms/gohead.git && cd gohead
printf 'GOHEAD_JWT_SECRET=%s\nGOHEAD_ADMIN_USERNAME=admin\nGOHEAD_ADMIN_PASSWORD=%s\n' \
  "$(openssl rand -hex 32)" "$(openssl rand -hex 12)" > .env
docker compose up -d        # API :8080 · admin UI :3000 · Postgres · Redis · MinIO · workers
export ADMIN_PASSWORD=$(sed -n 's/^GOHEAD_ADMIN_PASSWORD=//p' .env)

Log in as the admin (password in .env) and model a collection:

export GOHEAD=http://localhost:8080 JSON='Content-Type: application/json'

export AUTH="Authorization: Bearer $(curl -s -X POST $GOHEAD/auth/login -H "$JSON" \
  -d "{\"username\":\"admin\",\"password\":\"$ADMIN_PASSWORD\"}" | jq -r .data.token)"

curl -s -X POST $GOHEAD/admin/collections -H "$JSON" -H "$AUTH" -d '{
  "name": "articles", "kind": "collection",
  "attributes": {
    "title":     { "type": "string", "required": true },
    "views":     { "type": "int" },
    "published": { "type": "bool" }
  }
}'

Write and query content:

curl -s -X POST $GOHEAD/api/collections/articles -H "$JSON" -H "$AUTH" \
  -d '[{"data":{"title":"Hello GoHead","views":42,"published":true}},
       {"data":{"title":"Filtering 101","views":250,"published":true}}]'

curl -s -G $GOHEAD/api/collections/articles -H "$AUTH" \
  --data-urlencode 'filters[views][$gte]=100' --data-urlencode 'sort=views:desc'

curl -s -X POST $GOHEAD/api/graphql -H "$JSON" -H "$AUTH" \
  -d '{"query":"{ articles(limit: 5) { id title views } }"}'

The full walkthrough is in the quick start.

Agents in one request

Summarize every new article into a summaries collection:

POST /admin/agents
{
  "name": "summarizer",
  "system_prompt": "Summarize each new article in two sentences and store it with save_summary.",
  "max_turns": 3,
  "llm_config": { "provider": "openai", "model": "gpt-4o-mini" },
  "memory": { "type": "in-memory", "session_scope": "user" },
  "trigger": { "type": "collection_event",
               "event_trigger": { "collection": "articles", "events": ["item:created"] } },
  "functions": [{ "name": "save_summary", "impl_key": "collections.upsert_item",
                  "description": "Store a summary",
                  "parameters": { "type": "object",
                                  "properties": { "collection_name": { "type": "string" },
                                                  "data": { "type": "object" } } } }]
}

Triggers: collection events, webhooks (POST /agents/webhook/{id}) and cron. Built-in functions cover content (collections.*) and text tasks (llm.summarize_text, llm.classify_text, llm.extract_structured_data…). Read the agents guide →

How it fits together

flowchart LR
  C[Clients / Admin UI] -- REST · GraphQL --> API[gohead start]
  W[Webhooks] --> API
  API --> DB[(PostgreSQL · MySQL · SQLite)]
  API -- events --> R[(Redis)]
  R --> D[gohead dispatcher] -- jobs --> R
  S[gohead scheduler] -- cron jobs --> R
  R --> K[gohead worker] --> L[[OpenAI · Anthropic · Ollama]]
  K --> DB

Install

Docker Compose docker compose up -d (everything, as above)
Container docker run -p 8080:8080 -e GOHEAD_JWT_SECRET=… ghcr.io/gohead-cms/gohead
Helm helm install gohead oci://ghcr.io/gohead-cms/charts/gohead --set database.url=postgres://…
Kubernetes (GitOps) kubectl apply -k deploy/kubernetes/overlays/production (or let Flux do it)
Binary Releases for Linux, macOS, Windows (PostgreSQL/MySQL)
Source make build (Go 1.26+, cgo for SQLite)

Configuration is a YAML file or GOHEAD_* environment variables, see configuration.

Documentation

The GoHead Handbook covers everything:

Status

GoHead is pre-1.0: the API is usable and tested, and may still change between minor versions (see the changelog). Known gap: dynamic zones.

Contributing

Issues and pull requests are welcome. Start with the contributing guide:

make test-race   # Go tests
make up          # full stack from your checkout
make docs        # handbook on :8000

License

MIT

Directories

Path Synopsis
internal
accounts
Package accounts creates user accounts and the first administrator.
Package accounts creates user accounts and the first administrator.
api/handlers
internal/api/handlers/component.go
internal/api/handlers/component.go
api/middleware
internal/api/middleware/auth.go
internal/api/middleware/auth.go
contract
Package contract builds a fixed content model and compares the public API generated from it (OpenAPI document, GraphQL introspection) with the snapshots in api/, so changes to the API surface are visible in review and checked for breaking changes in CI.
Package contract builds a fixed content model and compares the public API generated from it (OpenAPI document, GraphQL introspection) with the snapshots in api/, so changes to the API surface are visible in review and checked for breaking changes in CI.
models
internal/models/json_map.go
internal/models/json_map.go
openapi
Package openapi describes the REST API as an OpenAPI 3.1 document, generated from the collections, components and singletons the same way the GraphQL schema is, so typed clients and Swagger UI always match the current content model.
Package openapi describes the REST API as an OpenAPI 3.1 document, generated from the collections, components and singletons the same way the GraphQL schema is, so typed clients and Swagger UI always match the current content model.
webhooks
Package webhooks delivers content events to external URLs.
Package webhooks delivers content events to external URLs.
pkg
auth
pkg/auth/jwt.go
pkg/auth/jwt.go
cluster
Package cluster keeps state that lives in memory consistent across API replicas.
Package cluster keeps state that lives in memory consistent across API replicas.
llm
logger
pkg/logger/logger.go
pkg/logger/logger.go
media
Package media stores uploaded files on a pluggable backend: the local filesystem (development, single replica) or any S3-compatible object store (AWS S3, MinIO, Cloudflare R2, Garage, Ceph...).
Package media stores uploaded files on a pluggable backend: the local filesystem (development, single replica) or any S3-compatible object store (AWS S3, MinIO, Cloudflare R2, Garage, Ceph...).
metrics
pkg/metrics/metrics.go
pkg/metrics/metrics.go
migrations
Package migrations versions the database schema.
Package migrations versions the database schema.
ratelimit
Package ratelimit provides fixed-window counters shared by all API replicas through Redis, with an in-memory fallback when Redis is not configured or temporarily unreachable.
Package ratelimit provides fixed-window counters shared by all API replicas through Redis, with an in-memory fallback when Redis is not configured or temporarily unreachable.
tracing
pkg/tracing/tracing.go
pkg/tracing/tracing.go
validation
Package validation holds checks that need the database.
Package validation holds checks that need the database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL