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.
- 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.
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 boundaryapps/api/src/domain- domain modules and invariantsapps/api/src/tasks- async job/worker boundaryapps/api/src/runtime- AI runtime boundary, including Direct Proxy/cc-switch adapters laterapps/api/src/storage- S3-compatible object storage adapter boundaryapps/api/src/vector- vector index adapter boundaryapps/api/src/shared- API-local shared utilities
- 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.
# 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 devCurrent ports planned by the skeleton:
- Web: http://localhost:5173
- API: http://localhost:3000
- PostgreSQL: localhost:5432
- Redis: localhost:6379
- MinIO API: http://localhost:9000
- MinIO console: http://localhost:9001
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.
-
Prepare local environment files:
cp apps/api/.env.example apps/api/.env # optional: cp infra/.env.example infra/.env -
Start infrastructure:
pnpm dev:infra
-
Generate Prisma client after dependencies are installed:
pnpm db:generate
-
Run the local development migration:
pnpm db:migrate
For non-interactive deployment-style migration execution, use:
pnpm db:deploy
-
Check migration status:
pnpm db:status
-
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_migrationstable. -
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 checksPhase 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, andSnapshotas 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, andPOST /mind-maps/:mindMapId/branches/:branchId/nodes/:nodeId/move. - Installed-dependency validation currently passes with
pnpm --filter @ai-mind-map/api testfor the Phase 1 domain/API unit tests.
Phase 2 adds the review gate for proposed graph changes before they update official versions:
- Prisma schema and migration define
CandidateChangeSetandCandidateOperation, including pending/applied/partially-applied/rejected/superseded status fields, operation payload JSON, supersession links, and appliedChangeLoglinks. - 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
ChangeLogrows withcandidate_change_setsource 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, andPATCH /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.
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 checkCurrent sample tests:
apps/api/tests/unit/smoke.test.tsverifies the API domain boundary placeholder.apps/web/tests/unit/App.test.tsxsmoke-renders the React app shell withreact-dom/serverso it does not require a browser DOM.packages/shared/tests/unit/metadata.test.tsverifies shared project metadata used by app smoke tests.
Quality configuration files:
vitest.workspace.tsplus app/packagevitest.config.tsfiles for unit tests.eslint.config.jsfor TypeScript strict linting and React hooks rules.prettier.config.jsand.prettierignorefor formatting.scripts/check-quality-gate.mjsfor 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.