Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1.89 KB

File metadata and controls

58 lines (39 loc) · 1.89 KB

Boardit backend

The Go API is a modular monolith for authentication, notes, folders, publishing, revisions, and durable change events.

Run

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.

Dependency direction

router -> HTTP handler -> noteapp.Service -> Repository -> GORM/database
  • internal/noteapp owns permissions, concurrency, transaction, revision, and publishing rules.
  • internal/handler owns HTTP parsing and response mapping.
  • internal/model is 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

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.

Database operations

# 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 down

Read database-migrations.md before schema changes or rollback. Applied migrations are immutable and every new version requires PostgreSQL and SQLite up/down files.

API contract

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: