Architecture Overview
A deep dive into the DevFlow architecture: the context detection pipeline, the module system design, the executor and the plugin interface.
Project Structure
src/
├── cli.ts # Commander CLI entry point
├── index.ts # Main exports
├── core/
│ ├── types.ts # All TypeScript types & interfaces
│ ├── logger.ts # Coloured logging, dry-run state
│ ├── fs-utils.ts # File I/O with dry-run awareness
│ ├── package-json.ts # Deep merge, mergePackageJson, addScript
│ ├── context.ts # Project detection (PM, TS, stack, monorepo)
│ └── executor.ts # buildPlan, executePlan, printPlan
├── modules/
│ ├── registry.ts # Module catalogue, conflict detection, resolution
│ ├── presets.ts # Preset configurations per stack/level
│ ├── git/ # Husky, lint-staged, commitlint, etc.
│ ├── quality/ # ESLint, Prettier, Biome, etc.
│ ├── testing/ # Vitest, Jest, Playwright, etc.
│ ├── ci/ # GitHub Actions, GitLab CI, etc.
│ ├── release/ # Release-it, Changesets, etc.
│ ├── security/ # Audit, Gitleaks, Trivy, etc.
│ ├── dx/ # .nvmrc, .env, VSCode, etc.
│ ├── docker/ # Dockerfile, compose, .dockerignore
│ ├── docs/ # README, CONTRIBUTING, LICENSE, etc.
│ └── monorepo/ # Nx, Turborepo, Workspaces
├── wizard/
│ └── index.ts # 6-step interactive wizard
└── test/
└── helpers.ts # Shared test utilitiesData Flow
CLI (Commander)
│
├── Flags? ──→ Resolve modules directly
│ │
└── No flags ──→ Wizard (6 steps)
│
▼
detectProject(root)
│
▼
Module selection + options
│
▼
resolveModules(ids) ── dependency expansion
│
▼
detectConflicts(ids) ── conflict check
│
▼
buildPlan(modules, ctx, options)
│
▼
printPlan(plan) ── show to user
│
▼
executePlan(plan, ctx) ── apply changes
│
▼
printSummary(summary)Design Principles
Pure Data Actions
Modules don't perform side effects. Their plan() method returns an array of ModuleAction objects — pure data describing what should happen:
create-file— file path + contentupdate-file— file path + transform functionmerge-package-json— deep merge payloadinstall— package names + dev flagadd-script— script name + commandrun-command— shell command
The Executor is the only component that performs I/O.
Idempotent by Default
All file creation actions use skipIfExists: true. The executor checks before writing. This makes DevFlow safe to re-run.
Stack-Aware Generation
Every module receives a ProjectContext with stack, package manager, TypeScript status, and monorepo info. Configs are generated to match your exact setup.
Testable
Since actions are pure data, modules can be tested without file system access. The test suite mocks the context and asserts on the generated action arrays.
Monorepo
Configure Turborepo, Nx or pnpm and yarn workspaces for a monorepo in one command, with a shared tsconfig.base.json and workspace scripts.
Module Interface
A technical reference for the DevFlow module interface: how modules detect existing configuration, build action plans and join the wizard.