HomeArchitecture
System Design

System Architecture

8 packages. Strict unidirectional data flow. Zero circular dependencies. Built as a Turborepo + pnpm monorepo with TypeScript end-to-end.

Data Flow Pipeline

Data flows in one direction: Source → Parse → Graph → Query. No shortcuts, no circular dependencies.

SOURCE
Parser

Tree-sitter extracts functions, classes, imports, routes, DB ops, env vars, and events from TS, JS, Python, Rust, SQL, Markdown.

STORAGE
Graph

Nodes & edges ingested into Neo4j via batch UNWIND upserts. QueryCache with 30s TTL. Exponential retry backoff.

SYNC
Watcher

Chokidar monitors file changes with 500ms debounce. Incremental re-parse — only changed files are re-indexed.

ACCESS
MCP / CLI

AI agents query via 21 MCP tools (+ 9 resources, 6 prompts). Developers use 38 CLI commands. Viz dashboard for interactive exploration.

8 Packages

Each package has a single responsibility and strict boundaries. The dependency graph is unidirectional: core → parser/graph → watcher/mcp-server → cli.

@nomik/core
Foundation

Types, config (Zod), errors, logger (Pino)

@nomik/parser
Parsing

Tree-sitter multi-lang extraction

@nomik/graph
Storage

Neo4j driver, queries, cache, retry

@nomik/watcher
Live Updates

Chokidar file watcher with debounce

@nomik/mcp-server
AI Interface

21 AI tools, 9 resources, 6 prompts, role-scoped access, sampling

@nomik/viz
Visualization

React + Three.js/Cytoscape.js dashboard

@nomik/github-bot
CI Integration

PR impact analysis webhook, auto-comments blast radius

@nomik-ai/cli
User Interface

38 commands, standalone bundle

Module Responsibilities

ModuleDepends OnExposes
@nomik/coreNothing (leaf)Types, Config, Logger
@nomik/parsercoreparseFile(), parseProject()
@nomik/graphcoreGraphService, createGraphService
@nomik/watchercore, parser, graphcreateWatcher()
@nomik/mcp-servercore, graph21 MCP tools + 9 resources + 6 prompts
@nomik/vizcore (types only)Web dashboard
@nomik/github-botcore, graph, parserPR impact webhook
@nomik-ai/cliAll packages38 CLI commands

Design Principles

🔒

Strict Boundaries

No circular dependencies. core is the leaf dependency. Each package has a single, well-defined responsibility.

🔄

Pipeline Architecture

Parsing and ingestion are separate steps with backpressure. File changes flow through watcher → parser → graph.

📊

Observability

Structured logging via Pino everywhere. Every operation is traceable with timestamps and context.

🎯

Typed Errors

NomikError with code, severity, and recoverable flag. No untyped exceptions — every failure path is explicit.

🏗️

Multi-Project Isolation

projectId injected at every layer — nodes, edges, queries, mutations. One Neo4j instance serves multiple projects.

Performance First

Batch UNWIND upserts, QueryCache with 30s TTL, exponential retry backoff. 100K-line projects scan in under 60s.

Technology Stack

Single-language stack. TypeScript covers every layer — parser (Tree-sitter), graph (Neo4j driver), MCP server (Anthropic SDK), CLI (Commander), visualization (React + Three.js). One language = one team owns everything.
ComponentTechnologyWhy
ParserTree-sitter (official TS bindings)Incremental, multi-language, battle-tested
Graph DBNeo4j Community (Bolt)Cypher queries, APOC traversals, free
MCP SDK@modelcontextprotocol/sdkReference implementation by Anthropic
CLICommander.jsStandard Node.js CLI framework
VisualizationReact + Cytoscape.js + Three.js2D/3D interactive graph exploration
BuildTurborepo + tsup + pnpmFast builds, workspace caching, disk-efficient