Pipeline Overview
How nestjs-doctor works from CLI invocation to final output.
Flow
CLI Entry
src/cli/index.tsLoad Config
src/core/config-loader.tsDetect Project
src/core/project-detector.tsCollect Files
src/core/file-collector.tsParse AST
src/engine/ast-parser.tsBuild Module Graph
src/engine/module-graph.tsResolve Providers
src/engine/type-resolver.tsRun Rules
src/engine/rule-runner.tsFilter Diagnostics
src/core/filter-diagnostics.tsCalculate Score
src/scorer/index.tsOutput
src/cli/output/Directory Map
| Directory | Responsibility |
|---|---|
src/cli/ | CLI flags, entry point, output formatters |
src/core/ | Config loading, file collection, project detection, diagnostic filtering |
src/engine/ | AST parsing, module graph, provider resolution, rule execution |
src/rules/ | All 40 rules organized by category (security/, correctness/, architecture/, performance/) |
src/scorer/ | Score calculation, severity weights, score labels |
src/types/ | 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/core/config-loader.ts | Once |
| 2 | Project Detection | src/core/project-detector.ts | Per project |
| 3 | File Collection | src/core/file-collector.ts | Per project |
| 4 | AST Parsing | src/engine/ast-parser.ts | Per project |
| 5 | Module Graph | src/engine/module-graph.ts | Per project |
| 6 | Provider Resolution | src/engine/type-resolver.ts | Per project |
| 7 | Rule Execution | src/engine/rule-runner.ts | Per project |
| 8 | Diagnostic Filtering | src/core/filter-diagnostics.ts | Per project |
| 9 | Scoring | src/scorer/index.ts | Per project + combined |
| 10 | Output | src/cli/output/ | Once |
Orchestrator
The scan() and scanMonorepo() functions in src/core/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: custom rule resolution and file collection run concurrently (
Promise.all), and project detection runs in parallel with rule execution. - 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 four tabs: summary, diagnostics, an interactive module graph (nodes, directed edges, circular dependency highlighting), and a custom rule lab.