gohead

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 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.
🔎 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.
🚢 GitOps-ready Multi-arch images, Kubernetes manifests and Flux image automation included.

60-second start

git clone https://github.com/gohead-cms/gohead.git && cd gohead
echo "GOHEAD_JWT_SECRET=$(openssl rand -hex 32)" > .env
docker compose up -d        # API :8080 · admin UI :3000 · Postgres · Redis · workers

Create the first account (it becomes the admin), log in, and model a collection:

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

curl -s -X POST $GOHEAD/auth/register -H "$JSON" \
  -d '{"username":"admin","email":"admin@example.com","password":"change-me-please"}'

export AUTH="Authorization: Bearer $(curl -s -X POST $GOHEAD/auth/login -H "$JSON" \
  -d '{"username":"admin","password":"change-me-please"}' | 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
Kubernetes 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 gaps: media uploads, draft/publish workflow, and component values in items.

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
api/handlers
internal/api/handlers/component.go
internal/api/handlers/component.go
api/middleware
internal/api/middleware/auth.go
internal/api/middleware/auth.go
models
internal/models/json_map.go
internal/models/json_map.go
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
metrics
pkg/metrics/metrics.go
pkg/metrics/metrics.go
migrations
pkg/migrations/migrations.go
pkg/migrations/migrations.go
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
pkg/validation/uniqueness.go
pkg/validation/uniqueness.go

Jump to

Keyboard shortcuts

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