The Go API is a modular monolith for authentication, notes, folders, publishing, revisions, and durable change events.
cp .env_sample .env
# Set DATABASE_DSN and JWT_SECRET.
go run .Startup validates configuration, opens PostgreSQL or SQLite, applies pending embedded SQL migrations, and then starts the HTTP server on the configured address.
router -> HTTP handler -> noteapp.Service -> Repository -> GORM/database
internal/noteappowns permissions, concurrency, transaction, revision, and publishing rules.internal/handlerowns HTTP parsing and response mapping.internal/modelis persistence-only.- Future AI writes must call the note use-case and must not write GORM models directly.
See the root architecture and agent guide for complete invariants.
test -z "$(gofmt -l .)"
go vet ./...
go test -race -p 1 ./...Tests default to SQLite with DATABASE_DSN=:memory:. CI runs against PostgreSQL 15. Test databases are truncated; never use a database containing valuable data.
# Apply pending migrations explicitly
go run ./cmd/migrate -direction up
# Roll back exactly one migration after reviewing its down SQL
go run ./cmd/migrate -direction downRead database-migrations.md before schema changes or rollback. Applied migrations are immutable and every new version requires PostgreSQL and SQLite up/down files.
docs/api/api-contract-v1.yaml is authoritative. After changing it, regenerate the frontend client from frontend/ with npm run orval. Do not hand-edit generated TypeScript.
Useful references: