Skip to content

Development Setup

Prerequisites

  • Go 1.25 (see go.mod)
  • Node.js 20+ (see frontend/package.json)
  • PostgreSQL 15+ running on localhost:5432
  • Redis 7+ (optional, for caching — see docker-compose.yml)

Quick Start

bash
# 1. Start PostgreSQL and Redis via Docker (optional)
docker compose up -d postgres redis

# 2. Backend — run with hot-reload
cd cmd/slozy-web && go run .

# 3. Frontend — start Vite dev server (port 3000, proxies API to :8080)
cd frontend && npm install && npm run dev

The frontend dev server at http://localhost:3000 proxies /api requests to http://localhost:8080.

Hot-Reload with Air

bash
# Install Air (if not installed)
go install github.com/air-verse/air@latest

# Run in project root (uses .air.toml config)
air

The .air.toml builds ./cmd/slozy-web, watches .go, .tpl, .html, .yaml, .toml, .mod, .sum files, and rebuilds on changes with a 1-second delay.

Environment Variables

Copy .env.example to .env and adjust. Key variables:

VariableDefaultDescription
PORT8080Server port
POSTGRES_DSNpostgres://postgres:postgres@localhost:5432/slozy_db?sslmode=disableDatabase connection
REDIS_URLredis://localhost:6379Redis connection
JWT_SECRETdev_change_me_in_production_min_32_charsJWT signing key
DEV_MODEtrueEnables dev-only routes and debug logging
LOG_LEVELdebugLogging verbosity

Pre-configured files: .env.development (dev defaults), .env.production (prod defaults).

Docker Development

  • Dockerfile.dev — Go build with Alpine runtime, exposes :8080 and :9090
  • docker-compose.yml — Full stack: postgres, redis, prometheus, grafana, slozy-web, slozy-frontend
  • docker compose up --build to start everything