Skip to content

πŸ› οΈ Development GuideΒΆ

Welcome to GoLangGraph development! This guide will help you set up your development environment and contribute effectively.

πŸ“‹ PrerequisitesΒΆ

  • Go: Version 1.21 or later
  • Docker: For running integration tests with PostgreSQL and Redis
  • Make: For build automation
  • Git: For version control

Optional ToolsΒΆ

  • golangci-lint: For code linting (will be installed automatically)
  • Ollama: For local LLM testing with Gemma models
  • pre-commit: For git hooks

πŸš€ Quick SetupΒΆ

  1. Clone the repository:
git clone https://github.com/piotrlaczkowski/GoLangGraph.git
cd GoLangGraph
  1. Install dependencies:
make install
  1. Run tests:
make test
  1. Build the project:
make build
  1. Set up local development environment:
# Start PostgreSQL and Redis containers
make docker-up

# Set up Ollama with required models
make ollama-setup

# Run comprehensive tests
make test-local

πŸ—οΈ Project StructureΒΆ

GoLangGraph/
β”œβ”€β”€ πŸ“ pkg/              # Core library packages
β”‚   β”œβ”€β”€ agent/           # AI agent implementations (Chat, ReAct, Tool)
β”‚   β”œβ”€β”€ builder/         # Quick builder patterns for rapid development
β”‚   β”œβ”€β”€ core/            # Graph execution engine and state management
β”‚   β”œβ”€β”€ debug/           # Debugging and visualization tools
β”‚   β”œβ”€β”€ llm/             # LLM provider integrations (OpenAI, Ollama, Gemini)
β”‚   β”œβ”€β”€ persistence/     # Database integration and checkpointing
β”‚   β”œβ”€β”€ server/          # HTTP server and WebSocket support
β”‚   └── tools/           # Built-in tools and tool registry
β”œβ”€β”€ πŸ“ cmd/              # CLI applications
β”‚   β”œβ”€β”€ golanggraph/     # Main CLI application
β”‚   └── examples/        # Example CLI tools
β”œβ”€β”€ πŸ“ examples/         # Working examples (each with own go.mod)
β”‚   β”œβ”€β”€ 01-basic-chat/
β”‚   β”œβ”€β”€ 02-react-agent/
β”‚   β”œβ”€β”€ 03-multi-agent/
β”‚   β”œβ”€β”€ 04-rag-system/
β”‚   β”œβ”€β”€ 05-streaming/
β”‚   β”œβ”€β”€ 06-persistence/
β”‚   β”œβ”€β”€ 07-tools-integration/
β”‚   β”œβ”€β”€ 08-production-ready/
β”‚   └── 09-workflow-graph/
β”œβ”€β”€ πŸ“ docs/             # Documentation source
β”œβ”€β”€ πŸ“ test/             # Integration tests
β”œβ”€β”€ πŸ“ scripts/          # Build and utility scripts
β”œβ”€β”€ πŸ“ .github/          # GitHub Actions workflows
β”œβ”€β”€ go.work              # Go workspace configuration
β”œβ”€β”€ Makefile             # Build automation
└── README.md            # Project overview

πŸ§ͺ Testing StrategyΒΆ

Unit TestsΒΆ

# Run all unit tests
make test

# Run tests with coverage
make test-coverage

# Run short tests (skip integration)
make test-short

# Run with race detector
make test-race

Integration TestsΒΆ

# Start dependencies and run integration tests
make test-integration

# Run comprehensive local tests with all services
make test-local

Example TestsΒΆ

# Test all examples
make test-examples

# Run local demo with all services
make demo-local

Enhanced TestingΒΆ

# Run enhanced test suite including CLI tests
make test-enhanced

# Run benchmarks
make benchmark

πŸ”§ Development WorkflowΒΆ

1. Branch Naming ConventionΒΆ

  • feature/description - New features
  • fix/description - Bug fixes
  • docs/description - Documentation updates
  • refactor/description - Code refactoring

2. Commit MessagesΒΆ

Follow Conventional Commits:

type(scope): description

feat(agent): add new tool integration
fix(core): resolve graph execution deadlock
docs(readme): update installation instructions
refactor(llm): simplify provider interface

3. Code QualityΒΆ

# Run linter
make lint

# Format code
make fmt

# Security scan
make security-scan

# Run all quality checks
make quality

4. Pre-commit HooksΒΆ

Install pre-commit hooks:

pip install pre-commit
pre-commit install

🐳 Docker Development¢

Database ServicesΒΆ

# Start PostgreSQL and Redis containers
make docker-up

# View container logs
make docker-logs

# Stop and remove containers
make docker-down

Local LLM SetupΒΆ

# Install and setup Ollama with gemma2:2b model
make ollama-setup

# Start Ollama service
make ollama-start

πŸ“¦ Go Workspace ManagementΒΆ

The project uses Go workspaces to manage multiple modules:

# The workspace is already configured in go.work
# It includes the main module and all examples

# To sync workspace
go work sync

# To add a new example
go work use ./examples/new-example

πŸ” Building and RunningΒΆ

Build CommandsΒΆ

# Build main binary
make build

# Build all binaries and examples
make build-all

# Run the main application
make run

# Clean build artifacts
make clean

Running ExamplesΒΆ

# Examples are in the workspace, run them directly
cd examples/01-basic-chat
go run main.go

# Or run from root
go run ./examples/01-basic-chat/main.go

πŸ” DebuggingΒΆ

Enable Debug LoggingΒΆ

export LOG_LEVEL=debug
export GOLANGGRAPH_DEBUG=true

Performance ProfilingΒΆ

# CPU profiling
go test -cpuprofile=cpu.prof -bench=.

# Memory profiling
go test -memprofile=mem.prof -bench=.

# View profiles
go tool pprof cpu.prof

πŸ“š DocumentationΒΆ

Local DocumentationΒΆ

# Generate Go docs
godoc -http=:6060

# View at http://localhost:6060/pkg/github.com/piotrlaczkowski/GoLangGraph/

MkDocs DocumentationΒΆ

# Install dependencies
pip install -r requirements.txt

# Serve documentation locally
mkdocs serve

# Build documentation
mkdocs build

🚒 Release Process¢

  1. Update version:
git tag v1.x.x
  1. Push tag:
git push origin v1.x.x
  1. GitHub Actions will automatically:
  2. Run tests
  3. Build binaries
  4. Create release
  5. Deploy documentation

🧰 Available Make Targets¢

Run make help to see all available targets:

make help

Key targets include:

  • Development: install, build, run, clean
  • Testing: test, test-coverage, test-integration, test-local
  • Quality: lint, fmt, security-scan, quality
  • Docker: docker-up, docker-down, docker-logs
  • Ollama: ollama-setup, ollama-start, demo-local

❓ TroubleshootingΒΆ

Common IssuesΒΆ

Go workspace issues:

# Reinitialize workspace
go work sync

Docker permission issues:

# Add user to docker group (Linux)
sudo usermod -aG docker $USER

Module resolution issues:

# Clean and rebuild
make clean
go clean -modcache
make install

Ollama connection issues:

# Check if Ollama is running
curl http://localhost:11434/api/tags

# Restart Ollama
make ollama-start

Test failures:

# Run tests with verbose output
go test -v ./pkg/...

# Run specific test
go test -v -run TestSpecificFunction ./pkg/core

πŸ“ Adding New FeaturesΒΆ

1. Adding a New Agent TypeΒΆ

  1. Create agent implementation in pkg/agent/
  2. Add tests in pkg/agent/
  3. Update documentation
  4. Add example in examples/

2. Adding a New ToolΒΆ

  1. Implement tool interface in pkg/tools/
  2. Register in tool registry
  3. Add tests
  4. Update documentation

3. Adding a New LLM ProviderΒΆ

  1. Implement provider interface in pkg/llm/
  2. Add configuration options
  3. Add tests with mocked responses
  4. Update documentation

πŸ“ž Getting HelpΒΆ

  • πŸ’¬ Discussions: GitHub Discussions
  • πŸ› Issues: GitHub Issues
  • πŸ“§ Email: Support via GitHub Issues
  • πŸ“– Docs: Browse the /docs directory

🀝 Contributing Guidelines¢

Please read CONTRIBUTING.md for detailed contribution guidelines.

Development ChecklistΒΆ

Before submitting a PR:

  • Code follows Go conventions
  • Tests pass: make test
  • Linting passes: make lint
  • Documentation updated
  • Examples work with changes
  • Integration tests pass: make test-integration

Happy coding! πŸš€