Package Library
The Gofasta library is a set of independent packages under pkg/. A scaffolded project imports a curated subset as its defaults — the same way any Go backend imports a curated set of community libraries. Each import is a default, not a requirement: delete one and replace it with a different library or a local implementation, and nothing else in the project has to change.
The pages below document each package’s public API, configuration, and the way the scaffold wires it.
Core infrastructure
| Package | What it provides |
|---|---|
pkg/config | Koanf-backed loader: config.yaml plus GOFASTA_-prefixed env overrides into a typed AppConfig, with SetupDB for all five drivers. |
pkg/logger | Structured logging on log/slog — JSON or text, configurable level, context fields, trace-ID propagation. |
pkg/errors | Typed domain errors that map to HTTP status codes, with stable error codes and a GraphQL error presenter. |
pkg/models | BaseModelImpl: UUID primary keys, managed timestamps, soft delete, optimistic locking via RecordVersion. |
pkg/types | Shared DTOs for pagination, sorting, error payloads, and common response envelopes. |
pkg/utils | Pagination math, string case conversion, GORM sort/filter query builders. |
HTTP and API surface
| Package | What it provides |
|---|---|
| HTTP utilities | Request binding and validation, JSON response helpers, pagination support for handlers. |
| Middleware | CORS, rate limiting, request logging, authentication, panic recovery, request IDs. |
pkg/graphql | Reusable gqlgen schema fragments for pagination, sorting, errors, and the health probe. |
pkg/health | /health, /health/live, and /health/ready probes with per-dependency status. |
Authentication and security
| Package | What it provides |
|---|---|
pkg/auth | JWT generation, validation, and refresh; claims management; auth middleware; Casbin-backed RBAC. |
pkg/session | Server-side sessions over gorilla/sessions with cookie and filesystem stores. |
pkg/encryption | AES-256-GCM authenticated encryption for data at rest. |
| Validators | Struct-tag validation on go-playground/validator with custom rules registered by the scaffold. |
Data and storage
| Package | What it provides |
|---|---|
pkg/cache | One caching interface over an in-memory store or Redis, with per-key TTL. |
pkg/storage | File storage across local filesystem and S3-compatible backends, including presigned URLs. |
pkg/seeds | Ordered seeder registry — Register(name, fn) and RunAll(). |
Communication
| Package | What it provides |
|---|---|
pkg/mailer | Outbound email over SMTP, SendGrid, or Brevo, with HTML template rendering and attachments. |
pkg/slack | Slack messages via incoming webhooks or bot tokens — files, thread replies, block kit. |
pkg/whatsapp | WhatsApp messaging across UltraMsg, Twilio, and the Meta Cloud API. |
| Push notifications | Mobile push via Firebase Cloud Messaging behind a pluggable Sender interface. |
| Notifications | Multi-channel dispatch across email, SMS, Slack, and in-app database delivery. |
pkg/websocket | WebSocket hub with a connection registry, rooms, and broadcasting. |
Background processing
| Package | What it provides |
|---|---|
pkg/scheduler | Cron scheduling on robfig/cron with 6-field expressions. |
pkg/queue | Async tasks on asynq and Redis — concurrency, retries with backoff, scheduled delivery, priorities. |
| Resilience | Circuit breaking and retry-with-backoff via failsafe-go. |
Operations and instrumentation
| Package | What it provides |
|---|---|
| Observability | Prometheus metrics and OpenTelemetry tracing as HTTP middleware. |
| Feature flags | Flag evaluation through the OpenFeature Go SDK with swappable providers. |
pkg/i18n | go-i18n translations from per-locale YAML, with Accept-Language resolution and pluralization. |
| Test utilities | testcontainers-backed PostgreSQL test databases with migrations applied. |
Last updated on