Skip to main content

Development Setup

Prerequisites

ToolVersionInstallation
Go1.22+go.dev
Node.js20+nodejs.org
Docker24+docker.com
Docker Composev2Included with Docker Desktop
golang-migratelatestgo install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
golangci-lintv2golangci-lint.run

First-Time Setup

# 1. Clone the repository
git clone <repo-url> && cd invoice

# 2. Start PostgreSQL
make docker-up

# 3. Run migrations
make migrate-up

# 4. Configure environment
cp backend/.env.example backend/.env
# Edit .env with your ClickHouse DSN and JWT secret

# 5. Install frontend dependencies
cd frontend && npm install && cd ..

# 6. Start backend
make run-backend # Port 8081

# 7. Start frontend (new terminal)
make run-frontend # Port 5173

Environment Variables

Create backend/.env with:

INVOICE_DB_URL=postgres://invoice:invoice@localhost:5433/invoice?sslmode=disable
INVOICE_CLICKHOUSE_DSN=https://default:[email protected]:443/default
INVOICE_JWT_SECRET=change-me-in-production
INVOICE_PDF_CONVERTER_URL=https://convert.prxm.uz
INVOICE_SERVER_PORT=8081
INVOICE_CORS_ORIGINS=http://localhost:5173

See Environment Variables for the complete list.

Makefile Commands

Build & Run

CommandDescription
make buildBuild Go binary to bin/invoice-server
make run-backendStart Go server (port 8081)
make run-frontendStart Vite dev server (port 5173)

Testing

CommandDescription
make testRun all unit tests
make test-raceTests with Go race detector
make test-coverageGenerate HTML coverage report
make test-integrationIntegration tests (needs Docker)
make test-e2eEnd-to-end smoke tests
make test-db-setupCreate and migrate test database

Linting & Formatting

CommandDescription
make lintRun golangci-lint + ESLint
make lint-backendGo linting only
make lint-frontendTypeScript/React linting only
make formatPrettier format frontend code

Database

CommandDescription
make docker-upStart PostgreSQL container
make docker-downStop PostgreSQL container
make migrate-upApply all pending migrations
make migrate-downRollback last migration
make migrate-create NAME=xxxCreate new migration pair
make migrate-statusShow current migration version
make seedNote: seed data included in migrations

Documentation

CommandDescription
make docs-devStart Docusaurus dev server
make docs-buildBuild documentation site

Test Database

For isolated testing:

make test-db-setup

This creates an invoice_test database, runs all migrations, and seeds data. Tests use TEST_DB_URL for the connection string.

Docker Services

# docker-compose.yml
services:
postgres:
image: postgres:16
container_name: invoice-postgres
ports:
- "5433:5432"
environment:
POSTGRES_USER: invoice
POSTGRES_PASSWORD: invoice
POSTGRES_DB: invoice

Note: Port 5433 is used to avoid conflicts with other PostgreSQL instances (proxima-backend uses 5432).