Codebase map

This map describes the clean V2 repository. Paths are authoritative; diagrams and plans are not proof that a target service exists.

Top-level boundaries

AreaPrimary pathsOwnsRead before changing
Webv2/web/React product shell, public preview, worker routing, UI data accessdocs/UI_SPEC.md, web callers, v2/web/wrangler.jsonc
APIv2/api/authenticated HTTP routes, actor scope, analytics, investigations, callbacksv2/api/worker.ts, route tests, shared contracts
Authv2/auth/Better Auth server/client integration and organization membershipauth worker, auth schema, auth tests, bindings
Sharedv2/shared/HarvyDex, HQL, automation, artifacts, errors, cache policy, cubesall callers and contract tests
Migrationsv2/migrations/database schema sourcemigration order, adapter, isolation tests
Catalogv2/catalog/source and API registry/reference ledgersconnector policy, source permissions, provenance rules
Workflowsv2/workflows/inactive local Automation starters and examplesdocs/DEVELOPMENT.md, workflow README
Docsdocs/canonical engineering and operations documentationdocs/PLAN.md, docs/DEVELOPMENT.md
Testsv2/tests/, v2/auth/*.test.mjslocal contract, API, auth, and UI utility checksthe implementation under test

Request path

Browser
  -> v2/web/ worker and client
  -> Better Auth session / organization actor
  -> v2/api/worker.ts
  -> actor scope + product entitlement + capability check
  -> bounded domain handler or analytics layer
  -> local SQL adapter (D1 test adapter today; PostgreSQL + Hyperdrive target)
  -> Basin SQL only for engine-marked historical analytics

Automation is a separate boundary:

POST /api/v1/runs
  -> registered approved source snapshot
  -> bounded signed Automation envelope
  -> VPS Automation workflow
  -> approved Spider Unlimited or registered API path + required proxy
  -> normalized artifact in R2 + historical ingest
  -> signed callback/publication to the API Worker

The live Automation path is not proven by checked-in templates or local tests.

API route ownership

  • v2/api/worker.ts owns health, callbacks, context, entitlements, audit, sources, search, events, stories, briefs, dashboards, runs, and HQL.
  • v2/api/investigations.ts owns investigations, investigation items, entities, relationships, and graph reads.
  • v2/api/analytics.ts owns cube metadata, normalization, HQL-to-semantic conversion, and execution dispatch.
  • v2/api/basin-compiler.ts owns bounded Basin SQL compilation and Basin execution configuration.
  • v2/shared/ owns the input/output contracts used by API, web, and Automation boundaries.

Caller and test rule

Before changing a shared function or contract:

  1. Search every caller.
  2. Read the corresponding test and migration/config binding.
  3. Preserve existing error, validation, scope, and revision behavior.
  4. Add or update one focused test for non-trivial behavior.
  5. Run the required local checks and label missing live checks BLOCKED.

Configuration evidence

  • v2/web/wrangler.jsonc configures the web Worker locally.
  • v2/api/wrangler.jsonc configures the API Worker locally.
  • v2/auth/wrangler.jsonc configures the Auth Worker locally.
  • A Wrangler binding is local configuration, not deployment evidence.
  • The intended launch database is PostgreSQL through Hyperdrive; the current local implementation still has D1-backed paths and requires migration/adapter work before launch.