Skip to content

About

AI mind map collaboration workbench scaffold and Phase 0 validation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AI Mind Map Workbench

Greenfield TypeScript monorepo for the AI Mind Map Workbench. Phase 0 established the stable project skeleton, Phase 1 added official mind-map versioning, and Phase 2 adds the candidate change gate for reviewing AI/runtime suggestions before they become official facts.

Tech stack baseline

  • Package manager/workspace: pnpm workspace
  • Frontend: React + TypeScript + Vite, PWA-ready structure
  • Backend: Node.js + TypeScript, NestJS-style modular monolith boundaries
  • Database: PostgreSQL with pgvector as the first vector-index adapter
  • ORM/migrations: Prisma
  • Queue: Redis/BullMQ placeholder
  • Object storage: S3-compatible interface, local MinIO placeholder
  • Shared contracts: packages/shared

See docs/superpowers/decisions/0001-tech-stack.md for the accepted ADR.

Repository layout

apps/
  web/                 React + Vite PWA shell
  api/                 TypeScript API modular monolith shell + Prisma config
    prisma/            Prisma schema and migration history
packages/
  shared/              Shared metadata/contracts placeholder
infra/                 Local infrastructure compose files
scripts/               Workspace utility scripts
docs/superpowers/      Plans, specs, and ADRs

The API skeleton intentionally preserves modular monolith boundaries:

  • apps/api/src/api - HTTP/API boundary
  • apps/api/src/domain - domain modules and invariants
  • apps/api/src/tasks - async job/worker boundary
  • apps/api/src/runtime - AI runtime boundary, including Direct Proxy/cc-switch adapters later
  • apps/api/src/storage - S3-compatible object storage adapter boundary
  • apps/api/src/vector - vector index adapter boundary
  • apps/api/src/shared - API-local shared utilities

Prerequisites

  • Node.js 20+
  • pnpm 9+
  • Docker with Compose support for local PostgreSQL/Redis/MinIO

Dependencies are not installed by this skeleton task. After cloning or pulling this repository, run pnpm install before using package scripts that invoke workspace dependencies such as Prisma or tsx.

Local startup entries

# Install workspace dependencies
pnpm install

# Start local infrastructure: PostgreSQL/pgvector, Redis, MinIO
pnpm dev:infra

# Start the empty backend API shell
pnpm dev:api

# Start the empty frontend PWA shell
pnpm dev:web

# Start the worker placeholder
pnpm dev:worker

# Start web, API, and worker concurrently after dependencies exist
pnpm dev

Current ports planned by the skeleton:

Database setup and migration flow

Local PostgreSQL uses the pgvector/pgvector:pg16 image in infra/docker-compose.yml. Defaults are development-only and may be overridden by copying infra/.env.example to infra/.env.

  1. Prepare local environment files:

    cp apps/api/.env.example apps/api/.env
    # optional: cp infra/.env.example infra/.env
  2. Start infrastructure:

    pnpm dev:infra
  3. Generate Prisma client after dependencies are installed:

    pnpm db:generate
  4. Run the local development migration:

    pnpm db:migrate

    For non-interactive deployment-style migration execution, use:

    pnpm db:deploy
  5. Check migration status:

    pnpm db:status
  6. Verify schema version after a successful migration:

    docker compose -f infra/docker-compose.yml exec postgres \
      psql -U ai_mind_map -d ai_mind_map \
      -c 'SELECT version FROM schema_versions WHERE id = 1;'

    Expected result includes phase-0-init. Prisma also tracks applied migrations in its internal _prisma_migrations table.

  7. Reset/rebuild the local development database when needed:

    pnpm db:reset

    This is destructive and should only be used for local development databases. To remove containers and volumes entirely:

    pnpm infra:down -- --volumes
    pnpm dev:infra
    pnpm db:deploy

Additional database helpers:

pnpm db:studio   # open Prisma Studio
pnpm check       # static workspace + database configuration checks

Phase 1 domain versioning status

Phase 1 now adds the first official-data loop on top of the Phase 0 skeleton:

  • Prisma schema and migration define MindMap, Branch, Version, Node, TreeEdge, ChangeLog, and Snapshot as the PostgreSQL source of truth.
  • Domain services support creating a mind map with its main branch and initial version, creating a root node, editing a node, moving a node, versioned mutation idempotency, base-version conflict detection, graph cycle validation, snapshots, and a Prisma repository adapter.
  • Minimal API routes are available through the framework-free handler in apps/api/src/api/index.ts: POST /mind-maps, POST /mind-maps/:mindMapId/branches/:branchId/root-node, PATCH /mind-maps/:mindMapId/branches/:branchId/nodes/:nodeId, and POST /mind-maps/:mindMapId/branches/:branchId/nodes/:nodeId/move.
  • Installed-dependency validation currently passes with pnpm --filter @ai-mind-map/api test for the Phase 1 domain/API unit tests.

Phase 2 candidate change gate status

Phase 2 adds the review gate for proposed graph changes before they update official versions:

  • Prisma schema and migration define CandidateChangeSet and CandidateOperation, including pending/applied/partially-applied/rejected/superseded status fields, operation payload JSON, supersession links, and applied ChangeLog links.
  • Domain services validate candidate operation payloads, enforce state transitions, create candidate sets, preview in-memory diffs, edit pending operations, reject/supersede candidates, and apply full or selected operations through the versioned mutation transaction boundary.
  • Candidate apply writes official ChangeLog rows with candidate_change_set source and updates candidate/operation status in the same repository transaction.
  • Minimal API routes are available through apps/api/src/api/index.ts: POST /candidate-change-sets, GET /candidate-change-sets/:id, POST /candidate-change-sets/:id/preview, POST /candidate-change-sets/:id/apply, POST /candidate-change-sets/:id/apply-operations, POST /candidate-change-sets/:id/reject, and PATCH /candidate-operations/:id.
  • Installed-dependency validation covers Phase 2 domain/API unit tests via pnpm --filter @ai-mind-map/api test.

Still out of scope after Phase 2: AI Runtime / cc-switch execution, document import, DocumentChunk / SourceRef / embedding search, export/share/permission recovery UI, and Managed CLI Runtime.

Test and quality entries

Phase 0 now includes sample unit tests and quality configuration while keeping the default commands runnable before dependencies are installed. The default pnpm test, pnpm lint, pnpm format, and pnpm format:check commands execute the lightweight reusable quality gate in scripts/check-quality-gate.mjs. After pnpm install, the tool-backed commands below can run Vitest, ESLint, Prettier, and Playwright directly.

# Phase 0 runnable smoke/unit-test gate: validates test directories, sample tests, configs, and scripts
pnpm test

# Real Vitest unit tests after dependencies are installed
pnpm test:unit
pnpm --filter @ai-mind-map/api test
pnpm --filter @ai-mind-map/web test
pnpm --filter @ai-mind-map/shared test

# Phase 0 integration/e2e/contract placeholders are checked by the reusable quality gate
pnpm test:integration
pnpm test:e2e
pnpm test:contract

# Real E2E runner after dependencies and browsers are installed
pnpm test:e2e:run

# Phase 0 lint/format gates available immediately
pnpm lint
pnpm format
pnpm format:check

# Real tool-backed lint/format commands after pnpm install
pnpm lint:run
pnpm format:write
pnpm format:check:run

# CI-style Phase 0 quality gate: workspace + database config + test/lint/format config checks
pnpm check

Current sample tests:

  • apps/api/tests/unit/smoke.test.ts verifies the API domain boundary placeholder.
  • apps/web/tests/unit/App.test.tsx smoke-renders the React app shell with react-dom/server so it does not require a browser DOM.
  • packages/shared/tests/unit/metadata.test.ts verifies shared project metadata used by app smoke tests.

Quality configuration files:

  • vitest.workspace.ts plus app/package vitest.config.ts files for unit tests.
  • eslint.config.js for TypeScript strict linting and React hooks rules.
  • prettier.config.js and .prettierignore for formatting.
  • scripts/check-quality-gate.mjs for CI-reusable Phase 0 checks that run without installed npm dependencies.

pnpm check runs scripts/check-workspace.mjs, scripts/check-database-config.mjs, and scripts/check-quality-gate.mjs. It verifies expected Phase 0 skeleton files, Prisma schema, initial migration, environment examples, database scripts, test directories, sample tests, lint/format config, and package scripts. It does not claim to execute Vitest/ESLint/Prettier until pnpm install has installed dependencies.

About

AI mind map collaboration workbench scaffold and Phase 0 validation

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages