Logo docs

Developer Guide

Development Guide#

Information for contributing to ncps development.

Quick Start#

See Contributing for comprehensive development guidelines.

Development Environment#

ncps uses Nix flakes with direnv for development environment:

# Clone repository
git clone https://github.com/kalbasit/ncps.git
cd ncps

# Enter dev shell (if using direnv)
direnv allow

# Or manually
nix develop

Available tools in dev shell:

  • go, golangci-lint, sqlc, sqlfluff
  • dbmate, delve, watchexec
  • Integration test helpers

Development Workflow#

Run Development Server#

# Local storage (default)
./dev-scripts/run.py

# S3 storage (requires dependencies)
nix run .#deps  # In separate terminal
./dev-scripts/run.py --mode ha --locker redis

# Other modes and flags
./dev-scripts/run.py --help

Development Dependencies#

Start MinIO, PostgreSQL, MySQL, Redis for testing:

nix run .#deps

This starts:

  • MinIO (port 9000) - S3-compatible storage
  • PostgreSQL (port 5432) - Database
  • MySQL/MariaDB (port 3306) - Database
  • Redis (port 6379) - Distributed locks

Code Quality#

# Format code
nix fmt

# Lint with auto-fix
golangci-lint run --fix

# Run tests
go test -race ./...

Database Migrations#

# Create new migration
dbmate --migrations-dir db/migrations/sqlite new migration_name

# Run migrations
dbmate migrate up

SQL Code Generation#

# After modifying db/query.sql
sqlc generate

Testing#

See Testing for comprehensive testing information.

Related Documentation#