Development Setup
This guide covers multiple ways to set up your Logchef development environment.
Prerequisites
Section titled “Prerequisites”Logchef requires:
- Go 1.27+ - Backend development
- Bun 1.4.2 - Frontend and docs package manager (the version CI uses)
- Rust - CLI development (optional, only if working on CLI)
- Docker - For running ClickHouse and test infrastructure
- just - Command runner for development tasks
- sqlc v1.31.1 - SQL code generation
- golangci-lint v2.14.0 - Go linting.
just lintfails if your version differs from the one pinned in.github/workflows/go-tests.yml.
Installation
Section titled “Installation”Install dependencies using your system’s package manager (or the methods below).
Go Installation
Section titled “Go Installation”Download Go 1.27 or newer from go.dev/dl, or use your
package manager (for example brew install go).
Install Bun with your package manager (for example brew install oven-sh/bun/bun),
or follow bun.sh/docs/installation. The
frontend lockfile is frontend/bun.lock; do not use npm, pnpm, or yarn.
Additional Tools
Section titled “Additional Tools”# just - command runnercargo install just
# sqlc - SQL code generator (pin the version CI uses)go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1
# golangci-lint - install the pinned release binary, for example:brew install golangci-lintgolangci-lint version # must print 2.14.0
# Docker - follow official docs for your OS# https://docs.docker.com/engine/install/Initial Setup
Section titled “Initial Setup”After installing dependencies:
1. Generate Database Code
Section titled “1. Generate Database Code”# Generate SQLC code from SQL queriesjust sqlc-generate2. Start Development Infrastructure
Section titled “2. Start Development Infrastructure”# Start ClickHouse and Dex OIDC providerjust dev-dockerThis starts:
- ClickHouse on port 9000 (HTTP: 8123)
- Dex OIDC provider on port 5556
- Sample log data and configurations
3. Build the Application
Section titled “3. Build the Application”# Build backend + frontendjust build
# Or build separatelyjust build-backendjust build-frontend4. Run Logchef
Section titled “4. Run Logchef”# Run with development configjust CONFIG=dev/config.toml run
# Or run backend/frontend separatelyjust run-backendjust run-frontend # In another terminalAccess Logchef at http://localhost:8125
Development Workflow
Section titled “Development Workflow”Common Commands
Section titled “Common Commands”# Run all checks (format, vet, lint, sqlc, tests)just check
# Run tests with coveragejust test
# Run tests without coverage (faster)just test-short
# Format codejust fmt
# Lint codejust lint
# Vet codejust vetWorking with Database Changes
Section titled “Working with Database Changes”- Modify migrations in
internal/store/sqlite/migrations/ - Update queries in
internal/store/sqlite/queries.sql - Regenerate code:
Terminal window just sqlc-generate - Update models in
pkg/models/if needed
Frontend Development
Section titled “Frontend Development”cd frontend/
# Development server with hot reloadbun run dev
# Type checkingbun run typecheck
# Unit testsbun run test
# Build for productionbun run buildCLI Development
Section titled “CLI Development”The CLI is written in Rust and lives in the cli/ directory:
# Build debug version (fast compilation)just build-cli-debug
# Build release version (optimized)just build-cli
# Run testsjust test-cli
# Lint with clippyjust lint-cli
# Format codejust fmt-cli
# Run all CLI checksjust check-cliThe debug binary is at cli/target/debug/logchef, release at cli/target/release/logchef.
Docker Development
Section titled “Docker Development”# Build Docker imagejust build-docker
# Run with Docker Composedocker compose -f deployment/docker/docker-compose.yml upTroubleshooting
Section titled “Troubleshooting”SQLC Generation Fails
Section titled “SQLC Generation Fails”Ensure sqlc is installed and in your PATH:
sqlc versionFrontend Build Errors
Section titled “Frontend Build Errors”Reinstall dependencies from the lockfile:
cd frontend/bun install --frozen-lockfileDocker Permission Issues
Section titled “Docker Permission Issues”Add your user to the docker group:
sudo usermod -aG docker $USERnewgrp dockerPort Already in Use
Section titled “Port Already in Use”Check if another process is using the required ports:
# Backend (8125)lsof -i :8125
# ClickHouse (9000, 8123)lsof -i :9000lsof -i :8123Next Steps
Section titled “Next Steps”- Review the Architecture Overview to understand the codebase
- See Roadmap for upcoming features
- Read the main CONTRIBUTING.md for contribution guidelines