# go-app-kit (github.com/abeta-dev/go-app-kit@v0.8.0) > Production-grade enterprise application and domain accelerator kit for Go (Go 1.26.0, 100.0% statement coverage): PostgreSQL transactional outbox with relay worker, SHA-256 hash-chained compliance audit logging, HTML-to-PDF GST tax invoice generation (headless Chromium + zero-dep pure-Go PDF 1.4), multi-channel notifications (SMTP, WhatsApp Cloud API, Indian DLT SMS, Slack, HMAC Webhooks), RFC 4180 streaming CSV/HTTP exports, zero-leak in-memory & local atomic 0600 filesystem object storage with HMAC-SHA256 presigned URLs, and distributed + local OS flock/PID lease-fenced periodic job scheduling. ## Quick Installation ```bash # Install the Go module go get github.com/abeta-dev/go-app-kit@v0.8.0 # Install vendor-neutral AI Agent Skills (Claude Code, Google Antigravity, Gemini CLI, Codex, Cursor) npx skills add abeta-dev/go-app-kit ``` ## Key Links & Resources - [Documentation Portal](https://abeta-dev.github.io/go-app-kit/): Interactive package reference, architecture topology, and PostgreSQL DDL blueprints. - [Go Reference (pkg.go.dev)](https://pkg.go.dev/github.com/abeta-dev/go-app-kit): Official Go package and symbol documentation. - [GitHub Repository](https://github.com/abeta-dev/go-app-kit): Source code, verification scripts, and release artifacts. - [AGENTS.md](https://github.com/abeta-dev/go-app-kit/blob/main/AGENTS.md): Root AI agent routing table and repository invariants. - [Versioning Policy & Deprecation Contract (`docs/VERSIONING.md`)](https://github.com/abeta-dev/go-app-kit/blob/main/docs/VERSIONING.md): 7-package leaf-import isolation matrix (`./scripts/check_leaf_imports.sh`) and strict `N + 2` minor-release deprecation window policy (`./scripts/check_deprecation.sh`). - [Umbrella Skill (`skills/go-app-kit/SKILL.md`)](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit/SKILL.md): Cross-package transactional composition and truth-gate verification loop. - [Reference Microservice (`examples/invoice_service`)](https://github.com/abeta-dev/go-app-kit/tree/main/examples/invoice_service): End-to-end B2B GST invoicing service combining core packages with `go-fintech-india`. ## Packages & API Reference ### 1. `outbox` — PostgreSQL Transactional Outbox Engine - **Import Path**: `github.com/abeta-dev/go-app-kit/outbox` - **Skill**: [`skills/go-app-kit-outbox/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-outbox/SKILL.md) - **PostgreSQL DDL**: `outbox/ddl/001_outbox_events.sql`, `outbox/ddl/002_outbox_concurrency_index.sql` - **Key Types & Functions**: - `Event`, `NewEvent(aggregateType, aggregateID, eventType string, payload any) (*Event, error)` - `Status` (`StatusPending`, `StatusProcessing`, `StatusPublished`, `StatusDeadLetter`) - `Store`, `PGStore`, `NewPGStore(db DBOperator, opts ...StoreOption) *PGStore`, `WithLeaseDuration(d time.Duration) StoreOption` - `Publisher`, `PublisherFunc` - `Relay`, `RelayConfig`, `NewRelay(cfg RelayConfig) (*Relay, error)`, `(*Relay).Start(ctx context.Context) error` - **Summary**: Solves dual-write anomalies by inserting domain events inside the active `pgx.Tx` and polling asynchronously via `SELECT ... FOR UPDATE SKIP LOCKED`, UUID `lease_token` fencing, and full-jitter exponential backoff. ### 2. `pdf` — HTML-to-PDF Document Generator & GST Invoice Templates - **Import Path**: `github.com/abeta-dev/go-app-kit/pdf` - **Skill**: [`skills/go-app-kit-pdf/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-pdf/SKILL.md) - **Key Types & Functions**: - `Generate(html string, opts ...Option) (*bytes.Buffer, error)` - `GenerateWithContext(ctx context.Context, html string, opts ...Option) (*bytes.Buffer, error)` - `GenerateFromTemplate(tmplStr string, data any, opts ...Option) (*bytes.Buffer, error)` - `GenerateFromTemplateWithContext(ctx context.Context, tmplStr string, data any, opts ...Option) (*bytes.Buffer, error)` - `Renderer`, `ChromiumRenderer`, `NewChromiumRenderer(opts ...ChromiumOption) *ChromiumRenderer`, `FindChromiumBinary() (string, error)` - `PureGoRenderer`, `NewPureGoRenderer(opts ...PureGoOption) *PureGoRenderer` (zero external binaries, PDF 1.4) - `WkhtmlRenderer`, `NewWkhtmlRenderer(maxConcurrent ...int) *WkhtmlRenderer` *(Deprecated since `v0.8.0`, remove in `>= v0.10.0`)* - `Options`, `Option`, `WithPageSize`, `WithOrientation`, `WithMargins`, `WithDPI`, `WithTitle`, `WithRenderer` - `GSTInvoiceTemplate`, `ReceiptTemplate` - **Summary**: Compiles HTML/Go templates into PDF buffers via modern headless Chromium (ephemeral loopback HTTP SSRF isolation, CSS `@page` rules, bounded concurrency) or zero-dependency pure-Go PDF 1.4, alongside embedded Indian GST B2B tax invoice and payment receipt templates. ### 3. `notifications` — Multi-Channel Notification Dispatcher - **Import Path**: `github.com/abeta-dev/go-app-kit/notifications` - **Skill**: [`skills/go-app-kit-notifications/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-notifications/SKILL.md) - **Key Types & Functions**: - `Broker`, `Config`, `DefaultConfig() Config`, `NewBroker(cfg Config) *Broker` - `(*Broker).RegisterSender(s Sender)`, `(*Broker).Send(ctx context.Context, msg Message) error`, `(*Broker).SendAsync(ctx context.Context, msg Message) error`, `(*Broker).Close()` - `Message`, `Attachment`, `Channel` (`ChannelEmail`, `ChannelSlack`, `ChannelSMS`, `ChannelWhatsApp`, `ChannelWebhook`), `Priority` (`PriorityLow`, `PriorityNormal`, `PriorityHigh`, `PriorityCritical`) - `EmailSender`, `EmailConfig`, `NewEmailSender(cfg EmailConfig) *EmailSender` - `BrevoSender`, `BrevoConfig`, `NewBrevoSender(cfg BrevoConfig) (*BrevoSender, error)` - `WhatsAppSender`, `WhatsAppConfig`, `NewWhatsAppSender(cfg WhatsAppConfig) (*WhatsAppSender, error)` - `SMSSender`, `SMSConfig`, `NewSMSSender(cfg SMSConfig) (*SMSSender, error)` (Indian TRAI DLT `pe_id` and `template_id`) - `SlackSender`, `SlackConfig`, `NewSlackSender(cfg SlackConfig) *SlackSender` - `WebhookSender`, `WebhookConfig`, `NewWebhookSender(cfg WebhookConfig) *WebhookSender` - `WebhookVerifier`, `NewWebhookVerifier(secret string, maxAge time.Duration) *WebhookVerifier`, `VerifyWebhook(secret, signature, timestamp string, payload []byte) error` - **Summary**: Synchronous and bounded asynchronous (`go-libs/workerpool`) fan-out across SMTP Email, Brevo v3 API, Meta WhatsApp Cloud API v20+, Indian DLT SMS, Slack webhooks, and HMAC-SHA256 replay-protected HTTP webhooks. ### 4. `audit` — Tamper-Evident Compliance Audit Trail & State Diffing - **Import Path**: `github.com/abeta-dev/go-app-kit/audit` - **Skill**: [`skills/go-app-kit-audit/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-audit/SKILL.md) - **PostgreSQL DDL**: `audit/ddl/001_audit_logs.sql` - **Key Types & Functions**: - `Event`, `NewEvent(ctx context.Context, action, entityType, entityID string, oldState, newState any) Event` - `Actor`, `ContextWithActor(ctx context.Context, actor Actor) context.Context`, `ActorFromContext(ctx context.Context) Actor` - `WithComment(ctx context.Context, comment string) context.Context`, `CommentFromContext(ctx context.Context) string` - `FieldDiff`, `ComputeDiff(oldState, newState any) map[string]FieldDiff` - `ComputeHash(evt Event, prevHash string) string` - `Recorder`, `PGRecorder`, `Config`, `NewPGRecorder(cfg Config) (*PGRecorder, error)` - `(*PGRecorder).Record(ctx context.Context, evt Event) error`, `(*PGRecorder).RecordAsync(evt Event) error`, `(*PGRecorder).Close()` - **Summary**: Range-partitioned PostgreSQL compliance audit logging with `trg_prevent_audit_log_modification` append-only triggers, automated field-level JSON diffing (`Old` vs `New`), context-extracted actor metadata, and deterministic SHA-256 hash chaining (`prev_hash` -> `hash`). ### 5. `export` — Low-Memory Streaming CSV/HTTP Exporter - **Import Path**: `github.com/abeta-dev/go-app-kit/export` - **Skill**: [`skills/go-app-kit-export/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-export/SKILL.md) - **Key Types & Functions**: - `Column[T any]`, `CSVStreamer[T any]`, `Option` - `NewCSVStreamer[T any](w io.Writer, columns []Column[T], opts ...Option) *CSVStreamer[T]` - `(*CSVStreamer[T]).WriteRow(item T) error`, `(*CSVStreamer[T]).WriteRows(items []T) error`, `(*CSVStreamer[T]).Flush() error`, `(*CSVStreamer[T]).Close() error` - `StreamHTTP[T any](w http.ResponseWriter, filename string, columns []Column[T], rows []T, opts ...Option) error` - `StreamHTTPCompressed[T any](w http.ResponseWriter, r *http.Request, filename string, columns []Column[T], rows []T, opts ...Option) error` - `NegotiateEncoding(acceptEncoding string) string` - `WithBOM(enable bool) Option`, `WithDelimiter(r rune) Option`, `WithCRLF(useCRLF bool) Option`, `WithFlushInterval(rows int) Option` - **Summary**: Constant-memory RFC 4180 CSV streaming directly to `io.Writer` or `http.ResponseWriter` (with RFC 9110 `Accept-Encoding` Brotli `br` and Gzip `gzip` streaming compression via `sync.Pool`), Excel UTF-8 BOM (`\xEF\xBB\xBF`), sanitized `Content-Disposition` headers, and automatic spreadsheet formula-injection defense (`=`, `+`, `-`, `@`, `\t`, `\r`). ### 6. `storage` — Zero-Leak Object Storage & HMAC-SHA256 Presigned URL Engine - **Import Path**: `github.com/abeta-dev/go-app-kit/storage` - **Skill**: [`skills/go-app-kit-storage/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-storage/SKILL.md) - **Key Types & Functions**: - `Store`, `LocalStore`, `NewLocalStore(rootDir string, opts ...LocalOption) (*LocalStore, error)`, `LocalOption`, `WithFilePerm`, `WithDirPerm`, `WithLocalMaxObjectBytes`, `WithLocalBaseURL`, `WithLocalSigningSecret`, `WithLocalClock` - `MemoryStore`, `NewMemoryStore(opts ...Option) (*MemoryStore, error)` - `ObjectMeta`, `PutInput`, `PresignedURL`, `Option` - `WithMaxObjectBytes(limit int64) Option`, `WithBaseURL(baseURL string) Option`, `WithSigningSecret(secret []byte) Option`, `WithClock(nowFunc func() time.Time) Option` - `ValidateKey(key string) error`, `(*LocalStore).VerifyPresignedURL`, `(*MemoryStore).VerifyPresignedURL` - **Summary**: Stores compiled PDF tax invoices and streaming CSV export artifacts in memory or on an atomic local filesystem (`0600` temp write + `fsync` + atomic rename) with strict path-traversal key validation, bounded stream size limits, SHA-256 content digests (`SHA256Hex`), defensive metadata cloning, and constant-time HMAC-SHA256 presigned `GET` and `PUT` URLs. ### 7. `scheduler` — Distributed & Local OS `flock` Lease-Fenced Periodic Job Scheduler - **Import Path**: `github.com/abeta-dev/go-app-kit/scheduler` - **Skill**: [`skills/go-app-kit-scheduler/SKILL.md`](https://github.com/abeta-dev/go-app-kit/blob/main/skills/go-app-kit-scheduler/SKILL.md) - **Key Types & Functions**: - `Scheduler`, `NewScheduler(store LeaseStore, nodeID string, opts ...Option) (*Scheduler, error)` - `JobConfig`, `JobFunc`, `LeaseStore`, `FileLeaseStore`, `NewFileLeaseStore(dir string, opts ...FileLeaseOption) (*FileLeaseStore, error)`, `WithFileLeaseMode`, `WithFileLeaseDirMode`, `WithFileLeasePID`, `WithProcessAliveChecker`, `MemoryLeaseStore`, `NewMemoryLeaseStore() *MemoryLeaseStore` - `Option`, `WithClock(nowFunc func() time.Time) Option`, `WithErrorHandler(fn func(jobName string, err error)) Option` - `(*Scheduler).Register(cfg JobConfig) error`, `(*Scheduler).RunOnce(ctx context.Context, jobName string) (bool, error)`, `(*Scheduler).Start(ctx context.Context) error` - **Summary**: Coordinates singleton periodic background jobs across service replicas or single-machine OS processes (LaunchAgent + GUI/CLI via OS `flock` + `0600` PID/TTL lock files) using lease acquisition (`TryAcquire`, `Release`), panic recovery barriers, and graceful in-flight draining on context cancellation. ### 8. `examples/invoice_service` — Reference B2B GST Invoicing Service - **Import Path**: `github.com/abeta-dev/go-app-kit/examples/invoice_service` - **Key Types & Functions**: - `InvoiceService`, `NewInvoiceService(...) *InvoiceService`, `(*InvoiceService).IssueInvoice(ctx context.Context, req IssueInvoiceRequest) (*IssueInvoiceResponse, error)` - **Summary**: Demonstrates atomic composition of `go-fintech-india` (GSTIN checksum validation and exact integer paise tax calculation) with `outbox`, `audit`, `pdf`, `notifications`, and `export`. ## Governance & CI Truth Gates - `./scripts/test_bash_compat.sh`: Enforces Bash 3.2 compatibility across all `scripts/*.sh`. - `./scripts/check_secrets.sh`: TruffleHog verified-secret scanning and deterministic credential pattern checks. - `./scripts/check_leaf_imports.sh`: Verifies zero cross-package sibling coupling across all 7 core packages (`audit`, `export`, `notifications`, `outbox`, `pdf`, `scheduler`, `storage`) and verifies via `go list -deps` and isolated `go.mod` sandboxes that `export`, `pdf`, `notifications`, `storage`, and `scheduler` never pull `pgx`, `gin`, or `go-fintech-india`, and `audit` and `outbox` never pull `gin` or `go-fintech-india`. - `./scripts/check_deprecation.sh`: Enforces the strict `N + 2` Minor-Release Deprecation Window Policy (`// Deprecated: Since vX.Y.Z (remove in >= vA.B.C). Use instead.`, documented in `docs/VERSIONING.md`). - `./scripts/check_version.sh`: Verifies version parity (`v0.8.0`), `CHANGELOG.md` symbol accuracy, package inventory, and documentation truth. - `./scripts/check_coverage.sh`: Enforces `100.0%` statement coverage across all 7 core packages and `examples/invoice_service`. - `./scripts/module_agent_review.sh`: Runs the 8 Module Code-Owner Agents and Multi-Skill quality review. ## Abeta Go Ecosystem - **[`github.com/abeta-dev/go-libs`](https://github.com/abeta-dev/go-libs)** (`v0.5.0`): 36 foundational microservice systems engineering packages (`workerpool`, `circuitbreaker`, `ratelimit`, `retry`, `cache`, `compress`, `ginmw`, `httpclient`, `db`, `rbac`, `jwks`, `telemetry`, `logger`). - Docs: https://abeta-dev.github.io/go-libs/ | Reference: https://pkg.go.dev/github.com/abeta-dev/go-libs - **[`github.com/abeta-dev/go-fintech-india`](https://github.com/abeta-dev/go-fintech-india)** (`v0.4.0`): Zero-dependency Indian FinTech & statutory compliance engine (127 exported symbols across 15 domain files: GSTIN mod-36, PAN, Aadhaar Verhoeff D5, IFSC, VPA/UPI, exact `Money` paise math, Razorpay/Cashfree/PhonePe webhooks, Indian FY & AP/AR aging). - Docs: https://abeta-dev.github.io/go-fintech-india/ | Reference: https://pkg.go.dev/github.com/abeta-dev/go-fintech-india - **[`github.com/abeta-dev/go-app-kit`](https://github.com/abeta-dev/go-app-kit)** (`v0.8.0`): Enterprise application infrastructure (7 core packages: `outbox`, `pdf`, `notifications`, `audit`, `export`, `storage`, `scheduler`). - Docs: https://abeta-dev.github.io/go-app-kit/ | Reference: https://pkg.go.dev/github.com/abeta-dev/go-app-kit - **[`github.com/abeta-dev/cloud-native-observability`](https://github.com/abeta-dev/cloud-native-observability)** (`v0.4.0`): Production OpenTelemetry, Prometheus, Grafana, Loki, Tempo, and Kubernetes observability reference stack for Go microservices. - Docs: https://abeta-dev.github.io/cloud-native-observability/ | Repo: https://github.com/abeta-dev/cloud-native-observability