# sxijyoti/polyglot-parser architecture

> Architecture diagram of the GitHub repository sxijyoti/polyglot-parser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sxijyoti/polyglot-parser
- Repository: https://github.com/sxijyoti/polyglot-parser

## Overview

This is a C proof of concept that parses Python, JavaScript, and Ruby source into a shared symbol/dependency representation and exports unified JSON. The main workflow is CLI input → file/directory parsing → language adapters → IR and dependency graph → JSON output. The README also describes the graph as an input for Function Mesh and IntelliSense. Source excerpts establish the central orchestration and JavaScript extraction; some adapter dispatch details are not shown, so those links are marked unverified.

Main entry points: [`ir/ir.c`](https://github.com/sxijyoti/polyglot-parser/blob/main/ir/ir.c) (Symbol and dependency IR), [`src/parser.c`](https://github.com/sxijyoti/polyglot-parser/blob/main/src/parser.c) (Parse orchestration), [`adapters/adapters.c`](https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/adapters.c) (Language dispatch), [`exporter/mc_export.c`](https://github.com/sxijyoti/polyglot-parser/blob/main/exporter/mc_export.c) (JSON serialization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Input and API"]
  node_cli["CLI<br/>[main.c]"]
  node_parser["Parse orchestration<br/>[parser.c]"]
end

subgraph group_parsing["Language parsing"]
  node_adapter_dispatch["Language dispatch<br/>[adapters.c]"]
  node_js["JavaScript extraction<br/>[js_adapter.c]"]
  node_python["Python extraction<br/>[python_adapter.c]"]
  node_ruby["Ruby extraction<br/>[ruby_adapter.c]"]
end

subgraph group_model["Unified model"]
  node_ir["Symbol and dependency IR<br/>[ir.c]"]
  node_graph["Dependency graph<br/>[graph.c]"]
end

subgraph group_output["JSON output"]
  node_exporter["JSON serialization<br/>[mc_export.c]"]
end

node_developer(("CLI user"))
node_treesitter["Tree-sitter"]
node_json["Unified JSON"]
node_consumer(("IntelliSense / Function Mesh"))

node_developer -->|"invokes"| node_cli
node_cli -->|"requests parsing"| node_parser
node_parser -->|"dispatches files"| node_adapter_dispatch
node_adapter_dispatch -.->|"selects adapter"| node_js
node_adapter_dispatch -.->|"selects adapter"| node_python
node_adapter_dispatch -.->|"selects adapter"| node_ruby
node_js -->|"queries syntax"| node_treesitter
node_js -->|"adds symbols and dependencies"| node_ir
node_python -.->|"adds parsed data"| node_ir
node_ruby -.->|"adds parsed data"| node_ir
node_parser -->|"builds graph"| node_graph
node_graph -->|"reads dependencies and symbols"| node_ir
node_parser -->|"requests serialization"| node_exporter
node_exporter -->|"serializes symbols"| node_ir
node_exporter -->|"serializes edges"| node_graph
node_exporter -->|"produces"| node_json
node_cli -->|"prints or writes"| node_json
node_json -->|"consumed by"| node_consumer

click node_cli "https://github.com/sxijyoti/polyglot-parser/blob/main/src/main.c"
click node_parser "https://github.com/sxijyoti/polyglot-parser/blob/main/src/parser.c"
click node_adapter_dispatch "https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/adapters.c"
click node_js "https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/js_adapter.c"
click node_python "https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/python_adapter.c"
click node_ruby "https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/ruby_adapter.c"
click node_ir "https://github.com/sxijyoti/polyglot-parser/blob/main/ir/ir.c"
click node_graph "https://github.com/sxijyoti/polyglot-parser/blob/main/graph/graph.c"
click node_exporter "https://github.com/sxijyoti/polyglot-parser/blob/main/exporter/mc_export.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_parser,node_developer toneBlue
class node_adapter_dispatch,node_js,node_python,node_ruby toneAmber
class node_ir,node_graph toneMint
class node_exporter toneRose
class node_treesitter,node_json,node_consumer toneIndigo
```

## Components

### Input and API

- [CLI](https://github.com/sxijyoti/polyglot-parser/blob/main/src/main.c): `src/main.c`
- [Parse orchestration](https://github.com/sxijyoti/polyglot-parser/blob/main/src/parser.c): `src/parser.c`

### Language parsing

- [Language dispatch](https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/adapters.c): `adapters/adapters.c`
- [JavaScript extraction](https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/js_adapter.c): `adapters/js_adapter.c`
- [Python extraction](https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/python_adapter.c): `adapters/python_adapter.c`
- [Ruby extraction](https://github.com/sxijyoti/polyglot-parser/blob/main/adapters/ruby_adapter.c): `adapters/ruby_adapter.c`

### Unified model

- [Symbol and dependency IR](https://github.com/sxijyoti/polyglot-parser/blob/main/ir/ir.c): `ir/ir.c`
- [Dependency graph](https://github.com/sxijyoti/polyglot-parser/blob/main/graph/graph.c): `graph/graph.c`

### JSON output

- [JSON serialization](https://github.com/sxijyoti/polyglot-parser/blob/main/exporter/mc_export.c): `exporter/mc_export.c`

### Other components

- **CLI user**
- **Tree-sitter**
- **Unified JSON**
- **IntelliSense / Function Mesh**

## Connections

- CLI user → CLI: invokes (evidence: `README.md`)
- CLI → Parse orchestration: requests parsing (evidence: `src/main.c`)
- Parse orchestration → Language dispatch: dispatches files (evidence: `src/parser.c`)
- Language dispatch → JavaScript extraction: selects adapter
- Language dispatch → Python extraction: selects adapter
- Language dispatch → Ruby extraction: selects adapter
- JavaScript extraction → Tree-sitter: queries syntax (evidence: `adapters/js_adapter.c`)
- JavaScript extraction → Symbol and dependency IR: adds symbols and dependencies (evidence: `adapters/js_adapter.c`)
- Python extraction → Symbol and dependency IR: adds parsed data
- Ruby extraction → Symbol and dependency IR: adds parsed data
- Parse orchestration → Dependency graph: builds graph (evidence: `src/parser.c`)
- Dependency graph → Symbol and dependency IR: reads dependencies and symbols (evidence: `graph/graph.c`)
- Parse orchestration → JSON serialization: requests serialization (evidence: `src/parser.c`)
- JSON serialization → Symbol and dependency IR: serializes symbols (evidence: `exporter/mc_export.c`)
- JSON serialization → Dependency graph: serializes edges (evidence: `exporter/mc_export.c`)
- JSON serialization → Unified JSON: produces (evidence: `exporter/mc_export.c`)
- CLI → Unified JSON: prints or writes (evidence: `src/main.c`)
- Unified JSON → IntelliSense / Function Mesh: consumed by (evidence: `README.md`)
