Development Setup
Development Setup
This guide covers multiple ways to set up your LogChef development environment.
Prerequisites
LogChef requires:
- Go 1.24+ - Backend development
- Node.js 22+ - Frontend development
- pnpm - Frontend package management
- Docker - For running ClickHouse and test infrastructure
- just - Command runner for development tasks
- sqlc - SQL code generation
Setup Options
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
# 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)
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
The Nix flake provides:
- Go 1.24 with gopls, golangci-lint
- Node.js 22 with pnpm
- Development tools: just, sqlc, git
- Infrastructure: docker, docker-compose, vector
- Isolated Go/Node environments with proper caching
Option 2: Manual Installation
If you prefer not to use Nix, install dependencies manually:
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
# 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
# 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
After installing dependencies (via Nix or manually):
1. Generate Database Code
# Generate SQLC code from SQL queriesjust sqlc-generate2. 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
# Build backend + frontendjust build
# Or build separatelyjust build-backendjust build-frontend4. 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
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
- 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
cd frontend/
# Development server with hot reloadpnpm dev
# Type checkingpnpm typecheck
# Build for productionpnpm buildDocker Development
# Build Docker imagejust build-docker
# Run with Docker Composedocker compose -f deployment/docker/docker-compose.yml upTroubleshooting
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
Clear pnpm cache and reinstall:
cd frontend/rm -rf node_modules .pnpm-storepnpm installDocker Permission Issues
Add your user to the docker group:
sudo usermod -aG docker $USERnewgrp dockerPort 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
- 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