Architecture

How Pulsar works under the hood

Pulsar is built around a multi-frontend pipeline that extracts code into an intermediate representation and runs rules against it.

Pipeline overview

TypeScript oxc parser ORM / SQL / RawSQL Nodes SQL strings SQL parser SQL Nodes Prisma schema Prisma parser Schema Nodes Unified IR Graph Rule Engine Formatterpretty / JSON

Frontends

Each frontend parses a different input format and produces typed IR nodes:

FrontendInputOutput
pulsar-frontend-oxcTypeScript/TSXOrmNode, SQLNode, RawSqlNode
pulsar-frontend-sqlSQL stringsSQLNode
pulsar-frontend-prismaPrisma schemaSchemaNode

IR Graph

All nodes are placed in a unified dependency graph (petgraph::Graph) with typed edges:

  • Generates — an ORM node generated a SQL node
  • Accesses — a SQL node accesses a schema table
  • MapsTo — a node maps directly to another (e.g., ORM → Schema)

Rule Engine

Rules implement the Rule trait and are registered in a BTreeMap keyed by rule ID. The engine iterates over all active rules and calls run(graph, source_text, file_path) for each one.

Formatters

Diagnostics are formatted by a DiagnosticFormatter trait. Two implementations exist:

  • PrettyFormatter — ESLint-style output with source context and highlighting
  • JsonFormatter — structured JSON for CI/CD tooling

Crates

Pulsar is organized as a Rust workspace with these crates:

CratePurpose
pulsar-cliCLI binary, config loading, command dispatch
pulsar-coreShared types: Diagnostic, Severity, SourceLocation
pulsar-irIR graph: SQLNode, OrmNode, RawSqlNode, SchemaNode, IrGraph
pulsar-frontend-oxcTypeScript extraction via oxc
pulsar-frontend-sqlSQL string parsing
pulsar-frontend-prismaPrisma schema parsing
pulsar-graphDrizzle chain resolution and node building
pulsar-rulesAll 12 rules and the rule engine
pulsar-diagOutput formatters

Diagnostics API

The rule engine produces diagnostics through a unified API that multiple consumers can use:

ConsumerFormat
CLIHuman-readable colored output (ESLint-style) with source context
LSPIn-editor diagnostics (future)
SARIFGitHub Code Scanning and CI integrations
GitHub ActionsAnnotations via warning/error workflow commands
JSONStructured output for custom tooling and dashboards

Technology

ToolRole
oxcTypeScript/JavaScript parsing (blazing fast, Rust-native)
sqlparser-rsSQL parsing with PostgreSQL dialect support
instaSnapshot-based testing for rule diagnostics

Last updated on

On this page