Files
lincodex/docs/en/DEVELOPMENT.md
T

6.9 KiB

Development

Русский

Run commands below from the repository root. ARCHITECTURE.md explains the services, DEPLOYMENT.md covers the environment, and TESTING.md covers checks.

Tools

Use the versions declared by the build inputs:

Tool Source
Go backend/go.mod, runner/go.mod, labd/go.mod, and their Dockerfiles
Node.js frontend/.node-version
pnpm and frontend frontend/package.json, frontend/pnpm-lock.yaml
Python and uv ml/.python-version, ml/pyproject.toml, ml/uv.lock
Go generators tool directives and dependencies in Go modules
Containers deploy/docker/ and service Dockerfiles

Container checks require Docker with the Compose plugin. The race detector needs a supported C toolchain. Keep lockfiles and test consumers when updating dependencies. Moving latest and alpine tags can change image content; a reproducible release pins digests.

make install
make help

install installs API, frontend, and ML dependencies and downloads backend, runner, and labd Go modules. It does not start services or install Docker or system compilers.

Normal workflow

  1. Locate the source of the change: contract, usecase, SQL, UI, or configuration.
  2. Change source files and add a check for observable behavior.
  3. Run make generate if generator inputs changed.
  4. Check the affected area; use make check for the combined checks.
  5. Review the diff, update both documentation languages, and run make docs-check.
Command Purpose
make fmt Reformat source files
make fmt-check Check formatting without edits
make test Service unit and component tests
make check Code, documentation, and configuration checks
make verify Generation, drift, checks, race, integration tests, and smoke

verify requires Docker. It does not include Playwright, security scanners, or real-model checks; select those separately for the change.

Local environment

Use Compose for the complete application. .env.example describes its variables; keep secrets in the local .env, outside Git and command examples.

make -C backend run reads process environment variables, not .env. PostgreSQL, Redis, SeaweedFS, and Kafka addresses inside Compose may not be reachable by a host process. Do not disable required dependencies just to make startup succeed.

make -C frontend dev starts Vite and proxies /api to 127.0.0.1:8080. Authentication validates the public Origin, so APP_PUBLIC_URL must match the browser address. Use the application behind Nginx for the complete cookie flow.

Mail is disabled by default. Develop registration against the isolated mail E2E stand or configure Resend; the SMTP transport is not implemented. A separate demo stand provides prepared synthetic accounts.

Contracts and generation

Edit routes/ and components/ grouped by subject in api/core/, api/ml/, api/runner/, or api/labd/. api/README.en.md summarizes HTTP conventions.

make -C api check
make generate
make check-generated

Generation order is API bundles, Go backend, runner, labd, frontend, and Python ML. make check-generated compares output with Git without running generators. Intentional contract changes should include updated output in the same commit; investigate unexpected differences.

  • ogen writes Go HTTP code into the relevant adapter's api/ directory.
  • sqlc writes PostgreSQL queries into backend/internal/adapter/secondary/postgres/sqlc/.
  • wire assembles dependencies in backend/internal/bootstrap/.
  • mockery generates only interfaces selected in backend/codegen/mockery.yml.
  • Orval writes the client, query hooks, Zod schemas, and MSW into frontend/src/shared/api/endpoints/ and schemas/.
  • datamodel-code-generator creates Pydantic models from the ML contract.

Do not edit output by hand. Generator configuration belongs to its consumer's codegen/ directory: the Go ML client belongs to backend and the Python models belong to ML.

Backend and data

Domain types live directly in internal/domain/. Usecases depend on ports; adapters provide HTTP, database, and external-service access. internal/bootstrap/ assembles dependencies and manages their lifecycle; cmd/app/main.go calls it.

  • Put business rules in domain/usecase and HTTP conversion in adapter/primary/http/v1/.
  • Define the required port and adapter for new infrastructure. Services do not access another service's tables directly.
  • Edit SQL in db/queries/, then run make -C backend gen-sqlc.
  • Add schema changes as new migrations in db/migrations/ and test on an isolated database. Do not rewrite applied migrations.
  • Save business changes and their outbox event in one transaction. Handlers must tolerate repeated delivery.
  • Extract repeated code into small helpers; use named constants or configuration for values with domain meaning.

Errors identify the location and reason: fmt.Errorf("ProfileUseCase.Update - save profile: %w", err). Use the same format without %w when there is no underlying error. HTTP responses expose safe problem codes, not internal errors or personal data.

make -C backend help lists maintenance commands. Migrations, mail retries, policy publication, and backfills change state: select the intended environment explicitly.

Frontend

FSD layers are app, pages, widgets, features, entities, and shared. Import lower layers through slice public APIs; do not couple neighboring slices through internal imports. Common components and styles belong in shared/; use generated API types.

Keep server state in TanStack Query and drafts in form state. Preserve entered data on version conflicts and offer to reload the server state. Asynchronous screens need loading, empty, error, and retry states.

Check keyboard access, focus, field labels, and narrow screens. Vitest checks logic; Playwright checks the interface in a browser.

ML and additional services

ML commands: make -C ml help. Ordinary checks use Ruff, mypy, and pytest; model quality and real inference are separate checks. Pin model weights and evaluation data versions.

Runner and labd are separate Go modules. Unit tests do not replace runner isolation checks or testing labd on a separate LXD test host. Their environments are described in runner/ and labd/.

Documentation and Git

A directory README explains its purpose, startup, and main commands. Details belong in contracts, source files, and the relevant guide. Keep execution history and inventories of individual tests out of documentation.

Write code comments in English. Maintain documentation in RU/EN pairs. Plans and their identifiers stay in local PRD/, which must not be committed. Use a short, single-line commit message describing the change, without assistant authorship or coauthor trailers.