8.8 KiB
Development
This guide describes the current technical scaffold and the commands declared in the repository. Product workflows remain planned; see ARCHITECTURE.md for the target design.
Stack and version sources
| Component | Version source |
|---|---|
| Go | exact 1.26.8 in backend/go.mod, toolchain, and Go build image |
| Node.js | frontend/.node-version |
| Frontend dependencies | current stable releases in package manifests and pnpm-lock.yaml |
| Python and uv | ML toolchain declarations and uv.lock |
Select current stable frontend dependency releases and keep pnpm-lock.yaml committed for repeatable installs. ML dependencies are locked in uv.lock; Go dependencies are in backend/go.mod. An update must change its lock/configuration and pass checks for that service. Container images use the requested moving latest or alpine tags; inspect their current Compose/Dockerfile references instead of treating the tag as a fixed version.
Install and work loop
The frontend uses TypeScript 7.0.2 (tsc) for type checking. The @typescript/native npm alias points to that compiler, while typescript points to the compatible @typescript/typescript6 API for ESLint. This follows Microsoft's side-by-side setup: current typescript-eslint does not support the TS7 API yet. Type checking covers source files, Vite configuration, and codegen/orval.config.ts.
Orval writes directly to frontend/src/shared/api/endpoints/ and schemas/, without an extra generated/ directory. The adjacent client.ts and root shared/api/index.ts are handwritten. A Node test exercises the generated MSW handler together with the generated client. Vitest still reports a peer warning expecting MSW 2; the current Node path is tested with MSW 3, and browser mode is not used.
Ignore rules belong to each component's .gitignore; root rules cover only root files. CI installs pnpm from frontend/package.json's packageManager declaration and does not require bundled Corepack. To check ML locally with a different global uv version, pass UV='uv tool run --from uv==0.12.22 uv' to Make.
Run make help at the repository root for the current target list. Main targets:
- make install installs dependencies for api, frontend, ML, and backend.
- make generate bundles both OpenAPI contracts and updates generated Go/TypeScript/Python output.
- make fmt and make fmt-check format or check formatting.
- make lint runs configured linters.
- make test runs backend, frontend, and ML unit/component/service tests.
- make check checks api, backend, frontend, ML, deploy, observability, and documentation.
- make verify runs generation, drift checks, root check, API/backend validation, and a technical Compose smoke.
- make docs-check validates RU/EN docs, local links, routes, and imports.
Use each area's Makefile for its focused loop, for example make -C backend help, make -C frontend help, make -C ml help, make -C api help, make -C deploy help, and make -C observability help.
make check is not a business end-to-end suite. make verify runs a deployment smoke with Docker and a backend integration target. See TESTING.md for validation scope and DEPLOY.md for the local stack.
Layout
| Directory | Purpose |
|---|---|
| api/core/ | Public browser-to-Go OpenAPI contract |
| api/ml/ | Internal Go-to-ML OpenAPI contract |
| scripts/ | Shared schema merge, generated drift, and docs-check |
| backend/ | Go HTTP service, adapters, bootstrap, SQL, and consumer codegen |
| backend/config/ | Shared Go configuration outside internal |
| frontend/ | Vite SPA, Orval configuration, generated TypeScript |
| ml/ | Python service, lockfile, and Pydantic model generator |
| deploy/ | Compose, Nginx, and smoke script |
| observability/ | Prometheus, Loki, Alloy, provisioning, and dashboard JSON |
| .agents/ | Canonical project instructions and working standards |
| docs/ru/, docs/en/ | User documentation in Russian and English |
Codegen directories belong to the services that use the generated code: backend/codegen/, frontend/codegen/, and ml/codegen/. The Go client for the internal ML API is generated from backend/codegen/ogen-ml.yml and consumed at backend/internal/adapter/secondary/ml/api/. The public Go handler is generated from backend/codegen/ogen.yml and mounted in chi. sqlc configuration is backend/codegen/sqlc.yml, with generated SQL under backend/internal/adapter/secondary/postgres/sqlc/. Orval reads the public bundle from frontend/codegen/orval.config.ts. backend/cmd/app/main.go calls bootstrap.Run() and handles its error; startup, dependency wiring, and lifecycle logic live in backend/internal/bootstrap/app.go.
Contracts and generation
Source YAML stays beside its contract. Run make -C api bundle to merge schemas separately for api/core/ and api/ml/ and then bundle both inputs. The public and internal APIs remain separate contracts.
Root make generate prepares both bundles once, then runs Go, TypeScript, and Python consumers. Merged schemas, bundles, and generated clients are tracked derived files; change their sources and regenerate them. After changing a contract, regenerate every consumer and check drift. A service-local Make target can generate one consumer when its inputs are ready and the shared contract owner has agreed.
The target is OpenAPI 3.2.0, with ogen for Go, Orval for TypeScript, and datamodel-code-generator for Python/Pydantic v2. Verify the actual feature subset used by the project through pinned tools and the runtime path. A version string does not prove full specification support.
datamodel-code-generator 0.83.0 reads api/ml/openapi.bundle.yml and writes ml/src/lincodex_ml/api/models.py. Settings live in ml/codegen/pyproject.toml; this file configures the tool, while dependencies remain in ml/pyproject.toml and uv.lock. Health/readiness handlers import the generated models instead of maintaining handwritten schema copies. make -C ml generate bundles the API first; when called by root make generate, API_PREPARED=1 reuses the prepared bundle. make -C ml check-generated compares output with --check without rewriting the file. CI uses the shared make generate target, which includes the Python models.
Code boundaries
SQL linter dependencies are listed in backend/requirements-quality.txt beside .sqlfluff. The make -C backend lint-sql command installs them in the local .venv-quality environment and checks migrations and queries. Running the Go service does not require this environment.
Go follows domain, usecase, port, adapter, and bootstrap boundaries. The HTTP adapter mounts the generated ogen handler in chi. SQL belongs in backend/db/queries/; schema changes belong in backend/db/migrations/. sqlc output and wire_gen.go are generated.
Shared backend settings live in backend/config/. The service uses go-logkit 0.6.0 through its slog bridge and go-httpkit 0.7.0 for request IDs, request logging, and panic recovery. It retains custom Prometheus middleware because it bounds method labels and uses chi route patterns; go-httpkit/metrics accepts the raw method name as a label.
PostgreSQL uses pgxpool.NewWithConfig, and a generated SELECT 1 readiness query checks connectivity. Pool construction must not wait for the database during startup. go-pgkit 1.4.0 is not used because its constructor probes and retries before returning a pool, coupling service startup to database availability. Health handlers remain explicit: go-httpkit's helper returns ok/degraded with check details, while the shared contract uses ok/ready/not_ready. Do not add pgkit, httpkit/metrics, JWT, cache, or WebSocket without a concrete need and a check of the pinned version's behavior.
The frontend is a React/Vite SPA. Keep FSD boundaries as product screens are added. Generated transport types are not automatically entity models. MSW supports UI development; its fixtures do not prove that the API is implemented.
ML runs as a separate FastAPI process. It currently provides operational health/readiness only. Readiness stays at 503 without a model. Do not add placeholder inference that looks like a real result.
Write all source comments and docstrings in English. Keep canonical agent instructions in one English version; maintain user documentation in Russian and English.
Change rules
- Inspect current code and ownership before editing a shared file.
- Preserve other contributors' current changes.
- Coordinate changes to OpenAPI, migrations, shared Makefiles, lockfiles, and generated output with one owner of that shared surface.
- Regenerate derived files through Make targets.
- Label current behavior and intended behavior separately.
- Do not commit local paths, secrets, or personal developer settings.
For backend, frontend, ML, API, database, and infrastructure tasks, use the routes in the root AGENTS_ROUTING.md.