CLAUDE.md

43 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# Congo

Single-binary Go framework CLI. Scaffolds projects with vendored source, deploys them, wraps Claude Code.

## Structure

```
congo.go       Root package (package congo) — exports ScaffoldFS, SourceFS, ClaudeContext
cmd/main.go    CLI entry point — dispatches to cmd/commands/
cmd/commands/  Subcommands: init, new, dev, build, launch, connect, claude, source
cmd/internal/  Scaffold rendering + framework extraction helpers
pkg/           Framework source (application, database, frontend, assistant, platform)
res/           Scaffold templates + claude context
web/           Promotional website (dogfoods the framework)
```

## Commands

```bash
go build -o congo ./cmd         # Build CLI
go build -o web/web ./web       # Build website
go mod tidy                     # Resolve deps
make build                      # Build CLI binary
```

## How It Works

- `congo.go` (package `congo`) at root embeds `res/scaffold/`, `res/claude-context.md`, and `pkg/`
- `cmd/commands/` imports `congo.gg` to access the embedded filesystems
- `congo init` extracts `pkg/` via `congo.SourceFS` into `internal/`, rewrites `congo.gg/pkg/` → `<target>/internal/`
- `congo new` adds an app to an existing project (controllers, models, views, main.go)
- `congo source` extracts a flat buildable copy, rewriting `congo.X` → local vars to avoid import cycles
- `web/` is part of the same module, uses `pkg/` directly and `congo.SourceFS` for the source browser

## Code Conventions

- IDs are always strings (UUIDs)
- SQL uses PascalCase: `WHERE UserID = ?`
- Value receiver on `Handle()` for request isolation
- Templates by filename only: `{{template "nav.html" .}}`
- `cmp.Or()` for env var defaults
- No custom ServeMux — use `http.DefaultServeMux`
- Package-level vars as runtime state (no config structs)