Documentation

Docs / Command line

graphvein project

graphvein project init --name NAME [--dir DIR] [REPOSITORY=]PATH...
graphvein project add [--manifest DIR] [REPOSITORY=]PATH
graphvein index --project MANIFEST [--workers N] [--timeout D] [--max-file-size N]
graphvein status --project MANIFEST
graphvein project suggest [--manifest DIR] [--json] [--accept N]
graphvein project forget [--manifest DIR] REPOSITORY
graphvein callers|impact <target> --project MANIFEST [--repository MEMBER] [--depth N] [--json]
graphvein changes [impact ID] --project MANIFEST [--repository MEMBER] [--base B] [--json]

A project groups repositories that work together, typically a frontend and a backend kept in separate repositories, so Graphvein can link calls in one to routes in another while every repository keeps its own identities. Design and reasons: ADR 0075 ; plan: the T022 task record (internal).

Overview, in the order you meet it:

  1. Write the manifest: project init and project add ("Commands"; the file is described in "The manifest" and "The local file", checked by "Validation rules").
  2. Index and link: index --project indexes every member and runs the link pass; status --project shows member freshness and stale links ("Indexing a project").
  3. Resolve ambiguity: declare what each member consumes, with selectors and link scopes where one repository holds several servers ("The manifest"); project suggest proposes declarations from env, compose and dev-server files ("Suggestions").
  4. Query: callers, impact and changes with --project ("Querying a project").
  5. Serve: serve --project gives the web UI with the Project view, where declarations can also be edited ("Serving a project").

A cross-repository link is inferred, at most as confident as its path match, shows the assumption it rests on and is never labelled Precise (precision).

Commands

graphvein project forget --manifest . backend
Removed backend from project shop: its stored index and its project rows. Links of the other members to it are gone; run graphvein index --project to link the project again.

Indexing a project

graphvein index --project MANIFEST (the manifest file or the directory holding it) indexes every member and then links them:

  1. Each member with a checkout on this machine is indexed into the project store, as graphvein index would index it, under the repository name the manifest gives, with its own index lock and its own fact cache. Each member's lock is released before the next member and before the link pass. Members are indexed in manifest order.
  2. The link pass then runs under the project lock: it reads every member's stored nodes and stores the cross-repository links and every source's outcome (linked, ambiguous, unmatched, incomplete, ...) in one transaction. The rules are the claim contract in docs/extract/project-links.md.

The project store is <manifest directory>/.graphvein/index.db, or GRAPHVEIN_SQLITE_PATH, or the Postgres database in GRAPHVEIN_POSTGRES_URL. With SQLite the project lock is the store's index lock, so nothing else writes the store during the pass; with Postgres it is an advisory lock of its own, and a pass that finds a member published while it read is retried (up to three times). Single-repository flags (--repository, --emit, --indexer, a path) are refused: every member's name and path come from the manifest.

Output: one line per member, then the pass with its link counts (added, removed, changed, unchanged) and the outcome counts. Exit codes: 0 every member indexed and linked; 1 a member failed to index, a lock was held or the pass failed; 2 usage error or invalid manifest.

graphvein status --project MANIFEST reads the project store and writes nothing:

A link is fresh only while both members' latest runs are the runs it records, neither member failed to index before the pass, and the manifest's declarations are those the pass used. The manifest hash covers the project name, the members in order and their consumes and scopes; member paths and comments are left out, so moving a checkout or editing a comment does not mark links stale. Run graphvein index --project again to refresh them.

Querying a project

Once graphvein index --project has stored a link pass, callers and impact with --project MANIFEST traverse every member and cross repositories through the stored links, and graphvein changes --project reports the link journal diff; graphvein changes impact ID --project MANIFEST --repository MEMBER continues a change's impact into other members (queries). Every result names its repository; a step through a project link shows the link's assumption, is inferred and at most as confident as the link, and a stale link (the same freshness rule as status --project) is followed and marked with its reasons. Examples on a frontend + backend project:

graphvein callers 'route:src/server.ts#GET%20%2Fusers' --project . --repository backend
graphvein impact listUsers --project . --repository backend --depth 4
graphvein changes impact 'table:src/db/schema.ts#users' --project . --repository backend --depth 6
graphvein changes --project .

Serving a project

graphvein serve --project . serves the project's web UI and HTTP API: every endpoint answers per member through a repository parameter, and /api/v0/project shows the members, their freshness and the link pass (serve). The Project view's "Edit declarations" writes the manifest through typed edits with a diff preview (serve); renaming a member there also removes its stored index and links under the old name from the project store (the preview names it, "delete stored index of NAME (N nodes)", and the write needs that explicit confirm; T022 review), and offers a project re-index (after a rename made on disk, graphvein project forget OLD-NAME does the same). A manifest edited on disk while the server runs (an editor, git checkout, project add) is served from the next project request; its links are stale until the next link pass, and a file that does not validate is ignored (logged) until it does.

The manifest

graphvein-project.yaml lives either in a separate project folder (often the parent of the checkouts) or inside one member, pointing at the others by relative path. Commit it.

version: 1
name: realworld
members:
  - repository: frontend
    path: ../realworld-react
    consumes:                 # optional: narrows the providers
      - repository: express
        select:               # optional: which calls this entry covers
          bases: [__API_URL__]
          origins: ["http://localhost:3000"]
          path_prefixes: [/api]
  - repository: express
    path: ../express
    scopes:                   # optional: link scopes inside the member
      - name: users
        path: apps/user
      - name: articles
        path: apps/article

The local file

graphvein-project.local.yaml, next to the manifest, holds machine-specific member paths. Do not commit it. It may only set path for members the manifest lists; the path may be absolute or relative to the manifest's directory, in the operating system's own form.

version: 1
members:
  express:
    path: D:/src/express

Validation rules

Every rule refuses the manifest with the file, the line when known and the reason. Each rule has at least one fixture in internal/config/testdata/project/refuse-<rule>* with a golden error; a test keeps this table and the fixtures 1:1.

Rule Refused
yaml Malformed YAML, an empty file, several YAML documents, or a root that is not a mapping.
alias YAML anchors or aliases anywhere.
keys Non-string, duplicate or unknown keys in any mapping.
version version missing or not integer 1.
name name missing, not a string, empty, with NUL or with @ref:.
members members missing, not a list, or empty.
member-repository A member without repository (the directory name is never used), or one that is not a valid repository ID.
member-repository-unique Two members with the same repository.
member-path A manifest path that is empty, absolute (including C:), or uses backslashes.
member-path-unique Two members resolving to the same directory.
member-path-directory A member path that exists but is not a directory.
member-name-conflict A member whose own graphvein.yaml names a different repository.
member-config A member whose own graphvein.yaml is invalid.
consumes consumes that is not a nonempty list of strings or repository/scope/default_scope/select mappings.
consumes-target A consumes entry naming a repository that is not a member, or a scope its member does not declare.
consumes-default-scope default_scope that is not the boolean true, given together with scope, or naming a member that declares no scopes.
consumes-self A member, or a scope, consuming itself (a member's default scope naming its own repository's default_scope included).
consumes-duplicate The same provider (repository and scope, or repository and default scope) twice in one consumes list.
select A select with no list, or a list that is empty or not a list of strings.
select-base A base that is empty or contains whitespace.
select-origin An origin that is not lower-case http(s)://host[:port] without path, query, fragment or user.
select-path-prefix A path prefix not starting with /, or containing a query, fragment or whitespace.
scope A scope without name or path, or a name using characters other than letters, digits, ., _ and -.
scope-path A scope path that is ., absolute, uses backslashes or :, or has ., .. or empty elements.
scope-unique Two scopes of one member with the same name.
scope-overlap Two scopes of one member where one folder contains the other.
local-version A local file without version: 1.
local-member A local file naming a repository the manifest does not list.
local-path A local member entry with a key other than path, or an empty path.

Suggestions

graphvein project suggest [--manifest DIR] [--json] [--accept N]
graphvein callers|impact <target> --project MANIFEST [--repository MEMBER] [--depth N] [--json]
graphvein changes [impact ID] --project MANIFEST [--repository MEMBER] [--base B] [--json]

project suggest (T022) reads the project's files and proposes consumes entries with the evidence for each. It only reads: it never runs a file, a package script or a dev server, and listing never writes. Nothing changes how calls link until you accept a proposal with --accept N and link the project again (graphvein index --project).

--accept N takes proposal N of the current listing, appends it to the consumer's consumes list through the same writer as project add (comments kept, the whole manifest validated, atomic replace; a refused proposal writes nothing). A proposal for a provider the consumer already declares is refused: edit that entry instead. When it is the consumer's first entry, the command says so: from then on only calls an entry covers link across repositories (project links). --json prints the listing as structured data (proposals, unmatched, unread), the form the web UI reads. Exit codes: 0 listed or written; 2 usage error, invalid manifest or refused proposal; 1 file error.

Read forms

The readers follow a claim contract: each row says what it reads and when it refuses; every form no row covers goes to the single default SG-U (listed under "Not read" with the reason). Configuration written in code is read only in the literal forms below. Code: internal/projectsuggest (Rows); a test keeps this table, the code and the fixture goldens (testdata/fixtures/projectsuggest*) 1:1.

Row Reads Yields Refused (not read)
SG-E1 .env* line KEY=VALUE (optional export, quotes, # comment) whose value is an http(s) URL address; bases: [KEY], origins: [origin] $ interpolation or escapes, credentials, query or fragment, non-numeric port; non-http(s) values (database URLs) are not addresses
SG-E2 .env* line PORT, HTTP_PORT, SERVER_PORT, APP_PORT or API_PORT the member listens on that local port a value that is not a port 1-65535; other *_PORT keys (they usually name a port the member connects to) are not read
SG-C1 Compose environment (list or mapping) of a service built from a member, value an http(s) URL address of that member, matched by service name only inside the same file as SG-E1; a service without a literal local build context, with extends or a << merge key
SG-C2 Compose ports of a service built from a member: "C", "P:C", "IP:P:C" (optional /proto), long syntax target/published published P: a local port; container C: a port of the service name interpolation, ranges, more than three parts, non-literal values
SG-C3 Compose expose of a service built from a member a container port of the service name anything but one port
SG-V1 vite.config.*: export default {…} or export default defineConfig({…}) with literal server.proxy entries '/path': 'URL' or '/path': { target: 'URL', … } address; path_prefixes: [/path] config computed in code (a function, variable, spread or call), a key that is a pattern (^…, globs) or not starting with /, a non-literal target, rewrite, pathRewrite, router or bypass
SG-W1 webpack.*: module.exports = {…} or export default {…} with literal devServer.proxy object entries (as SG-V1) as SG-V1 as SG-V1
SG-W2 webpack.* literal devServer.proxy array items { context: '/path' or ['/path', …], target: 'URL' } address per context path; path_prefixes a computed or empty context, and as SG-V1
SG-R1 package.json "proxy": "URL" when the package depends on react-scripts address; no select no react-scripts dependency (nothing else reads the field), a non-string proxy
SG-D1 a define entry NAME: JSON.stringify(process.env.X): webpack new DefinePlugin({…}) or new webpack.DefinePlugin({…}) with one literal object argument anywhere in a webpack.* file, or Vite define: {…} in the literal exported config (SG-V1 forms); NAME an identifier, process.env.N or import.meta.env.N (base N); the config loads env files with dotenv (require('dotenv'), dotenv/config) the constant is X at build time: an SG-E1 address of X in an env file in the config's folder also offers base NAME a computed argument, key or value (a fallback X || '…', a template, a variable, raw code such as 'process.env.X'); a config without dotenv (listed: no env file is tied to it)
SG-D2 a define entry (forms as SG-D1) whose value is JSON.stringify('URL') or the JSON text '"URL"' address with base NAME as SG-D1, and as SG-E1 for the URL
SG-M1 a loopback address whose port exactly one other member declares (SG-E2 or a published SG-C2 port) proposal -
SG-M2 an SG-C1 address naming a service of the same Compose file built from exactly one other member, with that container port (SG-C2, SG-C3) proposal -
SG-M3 an address no other member declares, only the member itself, or several members; any other host (a public name is never guessed) unmatched evidence with the reason; no proposal -
SG-M4 an address read outside a Compose file (SG-E1, SG-D2, a proxy target) whose host is a service name of the Compose files in the address's own member checkout, every service of that name built from one other member (or one scope of it), one of them declaring that container port (SG-C2, SG-C3) proposal a service of that name built from no member (an image, an unread service: unmatched, the name is not proven), from several members, or only from the member itself; no service of that name declaring the port
SG-M5 a matched address (SG-M1, SG-M2, SG-M4) with a base: of its base, the SG-D1 constants reading it and its origin, none is recorded by a stored call of the consumer (in the evidence's scope) that the pass could link, or the consumer has no stored index unmatched evidence: "no calls use this base" (or: index the project first); no proposal -
SG-U everything else, and every refused form above listed as not read with the reason; nothing proposed -

Not read at all: Kubernetes manifests, reverse-proxy configs (nginx, Traefik labels), setupProxy.js and env_file references. A define constant written as a bare identifier (__API_URL__) is read (SG-D1); since extractors-47 the clients extractor records a call through it as an unresolved base with that base_expression when the constant is declared only in a declaration file (docs/extract/clients.md "Build-time constant bases"), so a matched address proposes bases: [__API_URL__]; without such a declaration the call stays dynamic and the address is SG-M5.

Report a problem with this pageSource: docs/cli/project.md