π οΈ 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ΒΆ
- Clone the repository:
- Install dependencies:
- Run tests:
- Build the project:
- 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ΒΆ
Enhanced TestingΒΆ
π§ Development WorkflowΒΆ
1. Branch Naming ConventionΒΆ
feature/description- New featuresfix/description- Bug fixesdocs/description- Documentation updatesrefactor/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:
π³ 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ΒΆ
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ΒΆ
- Update version:
- Push tag:
- GitHub Actions will automatically:
- Run tests
- Build binaries
- Create release
- Deploy documentation
π§° Available Make TargetsΒΆ
Run make help to see all available targets:
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:
Docker permission issues:
Module resolution issues:
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ΒΆ
- Create agent implementation in
pkg/agent/ - Add tests in
pkg/agent/ - Update documentation
- Add example in
examples/
2. Adding a New ToolΒΆ
- Implement tool interface in
pkg/tools/ - Register in tool registry
- Add tests
- Update documentation
3. Adding a New LLM ProviderΒΆ
- Implement provider interface in
pkg/llm/ - Add configuration options
- Add tests with mocked responses
- Update documentation
π Getting HelpΒΆ
- π¬ Discussions: GitHub Discussions
- π Issues: GitHub Issues
- π§ Email: Support via GitHub Issues
- π Docs: Browse the
/docsdirectory
π€ 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! π