Development Setup
Development Setup
Section titled “Development Setup”This guide covers multiple ways to set up your Logchef development environment.
Prerequisites
Section titled “Prerequisites”Logchef requires:
- Go 1.24+ - Backend development
- Node.js 22+ - Frontend development
- pnpm - Frontend package management
- Rust - CLI development (optional, only if working on CLI)
- Docker - For running ClickHouse and test infrastructure
- just - Command runner for development tasks
- sqlc - SQL code generation
Setup Options
Section titled “Setup Options”Option 1: Nix/NixOS (Recommended)
Section titled “Option 1: Nix/NixOS (Recommended)”The easiest way to get started is using the provided Nix flake, which automatically installs all dependencies.
Using nix develop
Section titled “Using nix develop”# Clone the repositorygit clone https://github.com/mr-karan/logchef.gitcd logchef
# Enter the development shellnix develop
# You should see: "👉 Ready to build Logchef. Try: just build or just dev-docker"Using direnv (Automatic activation)
Section titled “Using direnv (Automatic activation)”For automatic environment activation when you enter the project directory:
-
Install direnv:
Terminal window # NixOS: Add to configuration.nixenvironment.systemPackages = [ pkgs.direnv ];# Other systemsnix-env -i direnv -
Hook direnv into your shell (
~/.bashrcor~/.zshrc):Terminal window eval "$(direnv hook bash)" # or zsh -
Create
.envrcin the project root:Terminal window echo "use flake" > .envrcdirenv allow
The development environment will now activate automatically!
What’s Included
Section titled “What’s Included”The Nix flake provides:
- Go 1.24 with gopls, golangci-lint
- Node.js 22 with pnpm
- Rust toolchain for CLI development
- Development tools: just, sqlc, git
- Infrastructure: docker, docker-compose, vector
- Isolated Go/Node/Rust environments with proper caching
Option 2: Manual Installation
Section titled “Option 2: Manual Installation”If you prefer not to use Nix, install dependencies manually:
Go Installation
Section titled “Go Installation”# Download and install Go 1.24+wget https://go.dev/dl/go1.24.linux-amd64.tar.gzsudo tar -C /usr/local -xzf go1.24.linux-amd64.tar.gzexport PATH=$PATH:/usr/local/go/binNode.js and pnpm
Section titled “Node.js and pnpm”# Using nvm (recommended)curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bashnvm install 22nvm use 22
# Install pnpmnpm install -g pnpmAdditional Tools
Section titled “Additional Tools”# just - command runnercargo install just# ORgo install github.com/casey/just@latest
# sqlc - SQL code generatorgo install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
# Docker - follow official docs for your OS# https://docs.docker.com/engine/install/Initial Setup
Section titled “Initial Setup”After installing dependencies (via Nix or manually):
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/sqlite/migrations/ - Update queries in
internal/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 reloadpnpm dev
# Type checkingpnpm typecheck
# Build for productionpnpm 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 versionIf using Nix, make sure you’re in the dev shell:
nix developFrontend Build Errors
Section titled “Frontend Build Errors”Clear pnpm cache and reinstall:
cd frontend/rm -rf node_modules .pnpm-storepnpm installDocker 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
- Check CLAUDE.md for development patterns
- See Roadmap for upcoming features
- Read the main CONTRIBUTING.md for contribution guidelines