Pipeline Overview
How nestjs-doctor works from CLI invocation to final output.
Flow
Directory Map
| Directory | Responsibility |
|---|---|
src/cli/ | CLI flags, entry point, output formatters |
src/engine/ | Config loading, file collection, project detection, diagnostic filtering, AST parsing, module graph, provider resolution, rule execution, scoring |
src/engine/rules/definitions/ | All 43 rules organized by category (security/, correctness/, architecture/, performance/, schema/) |
src/report/ | HTML report generation (interactive dashboard, module graph, schema ER diagram) |
src/common/ | Shared type definitions (Diagnostic, Config, Result, errors) |
Steps
The pipeline has 10 stages. In a monorepo, stages 2-9 run once per sub-project.
| # | Stage | Source | Scope |
|---|---|---|---|
| 1 | Config Loading | src/engine/config/loader.ts | Once |
| 2 | Project Detection | src/engine/project-detector.ts | Per project |
| 3 | File Collection | src/engine/file-collector.ts | Per project |
| 4 | AST Parsing | src/engine/graph/ast-parser.ts | Per project |
| 5 | Module Graph | src/engine/graph/module-graph.ts | Per project |
| 6 | Provider Resolution | src/engine/graph/type-resolver.ts | Per project |
| 7 | Rule Execution | src/engine/rule-runner.ts | Per project |
| 8 | Diagnostic Filtering | src/engine/filter-diagnostics.ts | Per project |
| 9 | Scoring | src/engine/scorer/index.ts | Per project + combined |
| 10 | Output | src/cli/formatters/ | Once |
Orchestrator
The autoScan() and scanMonorepo() functions in src/engine/scanner.ts wire these stages together. The CLI calls one of these, and the Node.js API (diagnose(), diagnoseMonorepo()) wraps them with path validation.
Parallel Execution
The pipeline exploits concurrency where stages are independent:
- Single-project mode: config loading and custom rule resolution run first, then file collection and project detection run concurrently (
Promise.all). The remaining stages (AST parsing → module graph → providers → rule execution → scoring) run sequentially. - Monorepo mode: file collection for all sub-projects runs in parallel, and then each sub-project's full analysis (AST parsing through scoring) runs concurrently via
Promise.all.
HTML Report
Run npx nestjs-doctor . --report to generate an interactive HTML report. The output is a self-contained nestjs-doctor-report.html file that auto-opens in your browser. It includes five tabs: summary, diagnostics, an interactive module graph (nodes, directed edges, circular dependency highlighting), a schema ER diagram, and a custom rule lab.