Home
Softono
geo-optimizer

geo-optimizer

Open source MIT Go
260
Stars
14
Forks
0
Issues
5
Watchers
2 months
Last Commit

About geo-optimizer

A pluggable framework for GEO (Generative Engine Optimization) in Go. Built-in strategies for common use cases, with full support for custom strategy registration.

Platforms

Web Self-hosted

Languages

Go

Links

geo-optimizer

GEO Optimizer: Make Your Content Visible to AI Engines

Go Reference Go Report Card License: MIT

A pluggable framework for GEO (Generative Engine Optimization) in Go. Built-in strategies for common use cases, with full support for custom strategy registration.

Why this framework?

  • 🧩 Pluggable Architecture - Register your own optimization strategies or use built-in ones
  • πŸ“¦ 5 Built-in Strategies - Structure, Schema, AnswerFirst, Authority, FAQ ready to use
  • πŸ”Œ Easy Extension - Implement the Strategy interface to add custom logic
  • 🎯 Composable - Mix and match strategies for different optimization needs

Features

  • Multi-Strategy Optimization: 5 built-in optimization strategies that can be combined
  • LLM Abstraction: Clean interface supporting multiple LLM providers (GLM, extensible to others)
  • Content Scoring: Rule-based GEO quality scoring system
  • AI Platform Presets: Pre-configured preferences for ChatGPT, Perplexity, Google AI, and Claude
  • Schema Markup: Automatic JSON-LD structured data generation
  • Enterprise Ready: Multi-tenant architecture with enterprise isolation

Installation

go get github.com/Lin-Jiong-HDU/geo-optimizer

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/Lin-Jiong-HDU/geo-optimizer/pkg/llm"
    "github.com/Lin-Jiong-HDU/geo-optimizer/pkg/models"
    "github.com/Lin-Jiong-HDU/geo-optimizer/pkg/optimizer"
)

func main() {
    // 1. Create LLM client
    client, err := llm.NewClient(llm.Config{
        Provider: llm.ProviderGLM,
        APIKey:   "your-api-key",
        Model:    "glm-4.7",
    })
    if err != nil {
        log.Fatal(err)
    }

    // 2. Create optimizer
    opt := optimizer.New(client)

    // 3. Build request
    req := &models.OptimizationRequest{
        Content: "Your content here...",
        Title:   "Content Title",
        Enterprise: models.EnterpriseInfo{
            CompanyName: "Your Company",
            ProductName: "Your Product",
        },
        Strategies: []models.StrategyType{
            models.StrategyStructure,
            models.StrategySchema,
        },
    }

    // 4. Execute optimization
    resp, err := opt.Optimize(context.Background(), req)
    if err != nil {
        log.Fatal(err)
    }

    // 5. Use results
    fmt.Printf("Score: %.2f -> %.2f\n", resp.ScoreBefore, resp.ScoreAfter)
    fmt.Println(resp.OptimizedContent)
}

Optimization Strategies

Built-in Strategies

Strategy Description
StrategyStructure Adds clear heading hierarchy, bullet points, and organized sections
StrategySchema Generates JSON-LD structured data markup
StrategyAnswerFirst Moves key conclusions to the beginning
StrategyAuthority Enhances with citations, sources, and credentials
StrategyFAQ Generates FAQ sections for common queries

Register Custom Strategies

The framework is designed for extensibility. Implement the Strategy interface to add your own optimization logic:

import strategiespkg "github.com/Lin-Jiong-HDU/geo-optimizer/pkg/optimizer/strategies"

// Define your custom strategy
type SEOStrategy struct {
    *strategiespkg.BaseStrategy
    keywords []string
}

func NewSEOStrategy(keywords []string) *SEOStrategy {
    return &SEOStrategy{
        BaseStrategy: strategiespkg.NewBaseStrategy("seo", "SEO Optimization"),
        keywords:     keywords,
    }
}

// Implement the Strategy interface
func (s *SEOStrategy) Validate(req *models.OptimizationRequest) bool {
    return len(s.keywords) > 0
}

func (s *SEOStrategy) BuildPrompt(req *models.OptimizationRequest) string {
    return fmt.Sprintf("Optimize for keywords: %v\n\n%s", s.keywords, req.Content)
}

// Register and use your strategy
func main() {
    opt := optimizer.New(client)

    // Register custom strategy
    opt.RegisterStrategy(NewSEOStrategy([]string{"cloud", "AI", "optimization"}))

    // Use it alongside built-in strategies
    req := &models.OptimizationRequest{
        Content:    "...",
        Strategies: []models.StrategyType{"seo", models.StrategyStructure},
    }

    resp, _ := opt.Optimize(ctx, req)
}

Strategy Interface

type Strategy interface {
    Name() string
    Type() models.StrategyType
    Validate(req *models.OptimizationRequest) bool
    Preprocess(content string, req *models.OptimizationRequest) string
    Postprocess(content string, req *models.OptimizationRequest) string
    BuildPrompt(req *models.OptimizationRequest) string
}

Architecture

pkg/
β”œβ”€β”€ optimizer/         # Core optimization engine
β”‚   └── strategies/    # Individual strategy implementations
β”œβ”€β”€ llm/               # LLM abstraction layer
β”‚   └── prompts/       # Prompt templates and builders
β”œβ”€β”€ models/            # Data models (Request/Response)
β”œβ”€β”€ analyzer/          # Content analysis and scoring
└── config/            # Configuration and AI platform presets

E2E Testing

An end-to-end testing CLI tool is available in examples/e2e/ for validating the complete optimization workflow.

cd examples/e2e

# Configure your GLM API key
cp .env.example .env
# Edit .env and add your GLM_API_KEY

# Run all tests
go run .

# Run specific scenario
go run . --scenario=basic
go run . --scenario=full_flow

# Verbose output
go run . --verbose

The E2E tests validate:

  • Basic Functionality: LLM chat, content scoring, single strategy optimization
  • Full Business Flow: Complete optimization pipeline with realistic enterprise data

Test reports are generated in examples/e2e/output/ with detailed Markdown summaries.

Documentation

See API.md for detailed API documentation.

Requirements

  • Go 1.21+
  • LLM API access (currently supports GLM)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.