Skip to content

Flowfull-Go

Official Library + Starter Kit

Go has two official pieces:

Use flowfull-go when you need the Go client package in your own backend. Use flowfull-go-starter when you want a complete backend template already wired with Fiber, GORM, Bridge validation, auth middleware, HybridCache, and Trust Tokens.

Status

Available - official Go library plus production-shaped starter for teams that want Flowfull concepts in Go.

Install the library:

bash
go get github.com/pubflow/flowfull-go

Or clone the starter:

bash
git clone https://github.com/pubflow/flowfull-go-starter.git my-backend
cd my-backend
go mod download

The Go starter depends on the official flowfull-go library and keeps the same Flowfull model: Bridge Validation, auth middleware, portable database patterns, and custom backend routes.

Included / Expected Features

  • Go 1.22+ - Modern Go with generics
  • Fiber v2 - Fast web framework in the starter
  • GORM - Multi-database ORM in the starter
  • All 7 Core Concepts - Bridge Validation, HybridCache, Trust Tokens, etc.
  • Type Safety - Leveraging Go's strong typing
  • Goroutines - Concurrent request handling

Starter Structure

flowfull-go-starter/
├── cmd/
│   └── server/
│       └── main.go
├── internal/
│   ├── bridge/           # Bridge Validation
│   ├── cache/            # HybridCache
│   ├── auth/             # Auth Middleware
│   ├── database/         # Database
│   ├── tokens/           # Trust Tokens (PASETO)
│   └── config/           # Configuration
├── api/
│   ├── handlers/         # HTTP Handlers
│   └── middleware/       # Middleware
├── migrations/           # Database Migrations
├── .env.example
├── go.mod
└── README.md

Technology Stack

TechnologyPurposeVersion
GoLanguage1.22+
flowfull-goOfficial Go SDK/client0.1+
FiberStarter web frameworkv2
GORMStarter ORMLatest
go-redisRedis ClientLatest
pasetoTrust Tokensv2
viperConfigurationLatest

Core Concepts (Preview)

1. Bridge Validation

go
package bridge

import (
    "context"
    "net/http"
)

type Validator struct {
    flowlessURL  string
    bridgeSecret string
}

func (v *Validator) ValidateSession(ctx context.Context, sessionID string, opts ValidationOptions) (*Session, error) {
    // Validate the session with Flowless and enforce the selected validation mode.
    return nil, nil
}

2. HybridCache

go
package cache

import (
    "context"
    "time"
)

type HybridCache struct {
    lru   *LRUCache
    redis *RedisCache
}

func (c *HybridCache) Get(ctx context.Context, key string, fetcher func() (interface{}, error)) (interface{}, error) {
    // Layer 1: LRU
    if val, ok := c.lru.Get(key); ok {
        return val, nil
    }
    
    // Layer 2: Redis
    if val, err := c.redis.Get(ctx, key); err == nil {
        c.lru.Set(key, val)
        return val, nil
    }
    
    // Layer 3: Database
    val, err := fetcher()
    if err != nil {
        return nil, err
    }
    
    c.redis.Set(ctx, key, val, 5*time.Minute)
    c.lru.Set(key, val)
    
    return val, nil
}

3. Auth Middleware

go
package middleware

import (
    "github.com/gin-gonic/gin"
    "net/http"
)

func RequireAuth(validator *bridge.Validator) gin.HandlerFunc {
    return func(c *gin.Context) {
        sessionID := c.GetHeader("X-Session-Id")
        if sessionID == "" {
            c.JSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
            c.Abort()
            return
        }
        
        session, err := validator.ValidateSession(c.Request.Context(), sessionID, bridge.ValidationOptions{
            IP:        c.ClientIP(),
            UserAgent: c.GetHeader("User-Agent"),
        })
        
        if err != nil {
            c.JSON(http.StatusUnauthorized, gin.H{"error": "Invalid session"})
            c.Abort()
            return
        }
        
        c.Set("user_id", session.UserID)
        c.Next()
    }
}

Repository

Resources

Support