This guide helps you set up a development environment for Tracker and contribute to the project.
- Go 1.26+ - Install Go
- Node.js 23+ and npm - Install Node.js
- MongoDB 7+ - Install MongoDB
- Protocol Buffers Compiler - Install buf
- Task (optional) - Install Task
- Git - Install Git
# Clone the repository
git clone https://github.com/BananaOps/tracker.git
cd tracker
# Start MongoDB (if not running)
docker run -d -p 27017:27017 --name tracker-mongo mongo:7
# Run backend
go run main.go serv
# In another terminal, run frontend
cd web
npm install
npm run devAccess the application at http://localhost:5173
tracker/
├── cmd/ # Command-line entry points
├── internal/ # Private application code
│ ├── api/ # API handlers
│ ├── db/ # Database layer
│ ├── models/ # Data models
│ └── services/ # Business logic
├── proto/ # Protocol buffer definitions
├── generated/ # Generated code (gRPC, OpenAPI)
├── server/ # Server implementation
├── web/ # Frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── hooks/ # Custom hooks
│ │ └── lib/ # Utilities
│ └── public/ # Static assets
├── helm/ # Kubernetes Helm charts
├── docs/ # Documentation
└── scripts/ # Build and utility scripts
# Install Go dependencies
go mod download
# Install development tools
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest# Run with hot reload (using air)
go install github.com/air-verse/air@latest
air
# Or run directly
go run main.go serv
# With custom configuration
DB_HOST=localhost DB_PORT=27017 go run main.go servWhen you modify .proto files:
# Using Task (recommended)
task generate
# Or using buf
buf generate
# Or manually
protoc --go_out=. --go-grpc_out=. proto/**/*.proto# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run tests with verbose output
go test -v ./...
# Run specific package tests
go test ./internal/services/...
# Generate coverage report
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out# Install golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linter
golangci-lint run
# Auto-fix issues
golangci-lint run --fix# Build binary
go build -o tracker main.go
# Build with version info
go build -ldflags "-X main.Version=1.0.0" -o tracker main.go
# Build for different platforms
GOOS=linux GOARCH=amd64 go build -o tracker-linux-amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o tracker-darwin-arm64 main.gocd web
# Install dependencies
npm install
# Install development tools globally (optional)
npm install -g typescript vite# Development server with hot reload
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Type checking
npm run build:check# Run ESLint
npm run lint
# Fix linting issues
npm run lint -- --fix
# Format code with Prettier (if configured)
npm run format# Run tests (if configured)
npm test
# Run tests in watch mode
npm test -- --watch
# Generate coverage
npm test -- --coverageThe project includes a Taskfile for common development tasks:
# List available tasks
task --list
# Generate protocol buffers
task generate
# Run backend
task dev:backend
# Run frontend
task dev:frontend
# Run both backend and frontend
task dev:all
# Build Docker image
task docker:build
# Run tests
task test
# Run linter
task lint# Connect to local MongoDB
mongosh tracker
# View collections
show collections
# Query events
db.events.find().limit(10)
# Create index
db.events.createIndex({ "attributes.service": 1 })
# View indexes
db.events.getIndexes()Tracker uses automatic index creation. Indexes are defined in code and created on startup.
To add a new index:
- Edit
internal/db/indexes.go - Add index definition
- Restart the application
# Build image
docker build -t tracker:dev .
# Build with specific tag
docker build -t tracker:1.0.0 .
# Build without cache
docker build --no-cache -t tracker:dev .# Start services
docker-compose up -d
# View logs
docker-compose logs -f tracker
# Rebuild and restart
docker-compose up -d --build
# Stop services
docker-compose downUsing Delve debugger:
# Install Delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Debug the application
dlv debug main.go -- serv
# Set breakpoints in code
(dlv) break main.main
(dlv) continue- Open browser DevTools (F12)
- Use React DevTools extension
- Check console for errors
- Use breakpoints in Sources tab
Enable debug logging:
LOG_LEVEL=debug go run main.go serv# Fork the repository on GitHub
# Then clone your fork
git clone https://github.com/YOUR_USERNAME/tracker.git
cd tracker
# Add upstream remote
git remote add upstream https://github.com/BananaOps/tracker.git# Update main branch
git checkout main
git pull upstream main
# Create feature branch
git checkout -b feature/my-new-feature
# Or bugfix branch
git checkout -b fix/bug-description# Make your changes
# Add tests for new features
# Update documentation
# Run tests
go test ./...
cd web && npm test
# Run linters
golangci-lint run
cd web && npm run lint# Stage changes
git add .
# Commit with descriptive message
git commit -m "feat: add new feature description"
# Follow conventional commits
# feat: new feature
# fix: bug fix
# docs: documentation
# test: tests
# refactor: code refactoring
# chore: maintenance# Push to your fork
git push origin feature/my-new-feature
# Create Pull Request on GitHub
# Fill in the PR template
# Link related issues- Address review comments
- Push additional commits
- Keep PR focused and small
- Be responsive to feedback
- Follow Effective Go
- Use
go fmtfor formatting - Follow project conventions
- Write clear comments
- Keep functions small and focused
- Use TypeScript for type safety
- Follow React best practices
- Use functional components and hooks
- Keep components small and reusable
- Use Tailwind CSS for styling
# Install hey
go install github.com/rakyll/hey@latest
# Test API endpoint
hey -n 1000 -c 10 http://localhost:8080/api/v1alpha1/events
# Test with POST
hey -n 1000 -c 10 -m POST \
-H "Content-Type: application/json" \
-d '{"title":"Test"}' \
http://localhost:8080/api/v1alpha1/event# CPU profiling
go test -cpuprofile=cpu.prof -bench=.
go tool pprof cpu.prof
# Memory profiling
go test -memprofile=mem.prof -bench=.
go tool pprof mem.prof# Find process using port
lsof -i :8080
# Kill process
kill -9 <PID># Clean module cache
go clean -modcache
# Tidy dependencies
go mod tidy
# Verify dependencies
go mod verify# Clear node_modules
rm -rf node_modules package-lock.json
# Reinstall
npm install
# Clear Vite cache
rm -rf web/.vite- Go Documentation
- gRPC Documentation
- React Documentation
- TypeScript Handbook
- MongoDB Documentation
- Tailwind CSS
- Installation Guide - Install Tracker
- Configuration Guide - Configure Tracker
- Contributing Guidelines - Contribution process