Skip to Content
DocumentationPackage Library

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

PackageWhat it provides
pkg/configKoanf-backed loader: config.yaml plus GOFASTA_-prefixed env overrides into a typed AppConfig, with SetupDB for all five drivers.
pkg/loggerStructured logging on log/slog — JSON or text, configurable level, context fields, trace-ID propagation.
pkg/errorsTyped domain errors that map to HTTP status codes, with stable error codes and a GraphQL error presenter.
pkg/modelsBaseModelImpl: UUID primary keys, managed timestamps, soft delete, optimistic locking via RecordVersion.
pkg/typesShared DTOs for pagination, sorting, error payloads, and common response envelopes.
pkg/utilsPagination math, string case conversion, GORM sort/filter query builders.

HTTP and API surface

PackageWhat it provides
HTTP utilitiesRequest binding and validation, JSON response helpers, pagination support for handlers.
MiddlewareCORS, rate limiting, request logging, authentication, panic recovery, request IDs.
pkg/graphqlReusable 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

PackageWhat it provides
pkg/authJWT generation, validation, and refresh; claims management; auth middleware; Casbin-backed RBAC.
pkg/sessionServer-side sessions over gorilla/sessions with cookie and filesystem stores.
pkg/encryptionAES-256-GCM authenticated encryption for data at rest.
ValidatorsStruct-tag validation on go-playground/validator with custom rules registered by the scaffold.

Data and storage

PackageWhat it provides
pkg/cacheOne caching interface over an in-memory store or Redis, with per-key TTL.
pkg/storageFile storage across local filesystem and S3-compatible backends, including presigned URLs.
pkg/seedsOrdered seeder registry — Register(name, fn) and RunAll().

Communication

PackageWhat it provides
pkg/mailerOutbound email over SMTP, SendGrid, or Brevo, with HTML template rendering and attachments.
pkg/slackSlack messages via incoming webhooks or bot tokens — files, thread replies, block kit.
pkg/whatsappWhatsApp messaging across UltraMsg, Twilio, and the Meta Cloud API.
Push notificationsMobile push via Firebase Cloud Messaging behind a pluggable Sender interface.
NotificationsMulti-channel dispatch across email, SMS, Slack, and in-app database delivery.
pkg/websocketWebSocket hub with a connection registry, rooms, and broadcasting.

Background processing

PackageWhat it provides
pkg/schedulerCron scheduling on robfig/cron with 6-field expressions.
pkg/queueAsync tasks on asynq and Redis — concurrency, retries with backoff, scheduled delivery, priorities.
ResilienceCircuit breaking and retry-with-backoff via failsafe-go.

Operations and instrumentation

PackageWhat it provides
ObservabilityPrometheus metrics and OpenTelemetry tracing as HTTP middleware.
Feature flagsFlag evaluation through the OpenFeature Go SDK with swappable providers.
pkg/i18ngo-i18n translations from per-locale YAML, with Accept-Language resolution and pluralization.
Test utilitiestestcontainers-backed PostgreSQL test databases with migrations applied.
Last updated on