nestjs-doctorGitHub

Pipeline Overview

How nestjs-doctor works from CLI invocation to final output.

Flow

CLI Entry
src/cli/index.ts
Load Config
src/core/config-loader.ts
Detect Project
src/core/project-detector.ts
Collect Files
src/core/file-collector.ts
Parse AST
src/engine/ast-parser.ts
Build Module Graph
src/engine/module-graph.ts
Resolve Providers
src/engine/type-resolver.ts
Run Rules
src/engine/rule-runner.ts
Filter Diagnostics
src/core/filter-diagnostics.ts
Calculate Score
src/scorer/index.ts
Output
src/cli/output/

Directory Map

DirectoryResponsibility
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.

#StageSourceScope
1Config Loadingsrc/core/config-loader.tsOnce
2Project Detectionsrc/core/project-detector.tsPer project
3File Collectionsrc/core/file-collector.tsPer project
4AST Parsingsrc/engine/ast-parser.tsPer project
5Module Graphsrc/engine/module-graph.tsPer project
6Provider Resolutionsrc/engine/type-resolver.tsPer project
7Rule Executionsrc/engine/rule-runner.tsPer project
8Diagnostic Filteringsrc/core/filter-diagnostics.tsPer project
9Scoringsrc/scorer/index.tsPer project + combined
10Outputsrc/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.