# robertoraggi/cplusplus architecture

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

- Interactive diagram: https://gitdiagram.com/robertoraggi/cplusplus
- Repository: https://github.com/robertoraggi/cplusplus

## Overview

cxx-frontend is a work-in-progress C++26/C23 compiler frontend. Its user workflow is to submit source for preprocessing, parsing and analysis, then inspect or transform the resulting AST or emit code; the product also exposes a language server and a browser playground. The README documents an MLIR-based code-generation pipeline and playground integration. Internal links between native compiler stages are based on the repository’s module structure; sampled excerpts do not establish every call edge.

Main entry points: [`src/frontend/cxx/frontend.cc`](https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/frontend.cc) (Native Frontend), [`packages/cxx-frontend/src/Parser.ts`](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-frontend/src/Parser.ts) (Parser API), [`packages/cxx-playground/src/App.tsx`](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/App.tsx) (Playground UI), [`src/frontend/cxx/cxx.cc`](https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/cxx.cc) (C++ CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend Core"]
  node_cli["C++ CLI<br/>[cxx.cc]"]
  node_native_frontend["Native Frontend<br/>[frontend.cc]"]
  node_preprocessor["Preprocessor<br/>[preprocessor.cc]"]
  node_lexer_parser["Lexer and Parser<br/>[parser.cc]"]
  node_ast["AST and Rewriter<br/>[ast_rewriter.cc]"]
  node_js_api["WASM API<br/>[api.cc]"]
  node_parser_api["Parser API<br/>[Parser.ts]"]
end

subgraph group_analysis["Semantic Analysis"]
  node_semantic["Semantic Analysis<br/>[type_checker.cc]"]
  node_linker["Linker<br/>[linker.cc]"]
end

subgraph group_outputs["Code Generation"]
  node_codegen["Code Generator<br/>[codegen.cc]"]
  node_mlir["MLIR Backend<br/>[mlir_emitter.cc]"]
end

subgraph group_language["Language Services"]
  node_lsp_server["LSP Server<br/>[lsp_server.cc]"]
  node_lsp_worker["LSP Worker<br/>[lsp.worker.ts]"]
  node_lsp_client["LSP Client<br/>[lsp-client.ts]"]
end

subgraph group_playground["Browser Playground"]
  node_playground["Playground UI<br/>[App.tsx]"]
  node_editor["Code Editor<br/>[code-editor.tsx]"]
  node_output_view["Output View<br/>[output-code.tsx]"]
end

node_developer(("Developer"))
node_browser(("Browser User"))

node_developer -->|"submits source"| node_cli
node_cli -->|"invokes frontend"| node_native_frontend
node_native_frontend -->|"processes source"| node_preprocessor
node_native_frontend -->|"parses source"| node_lexer_parser
node_native_frontend -->|"analyzes source"| node_semantic
node_native_frontend -->|"links units"| node_linker
node_parser_api -->|"creates unit"| node_js_api
node_js_api -->|"calls native"| node_native_frontend
node_parser_api -->|"exposes transforms"| node_ast
node_parser_api -->|"emits code"| node_codegen
node_codegen -->|"emits MLIR"| node_mlir
node_browser -->|"uses"| node_playground
node_playground -->|"shows editor"| node_editor
node_editor -->|"submits source"| node_parser_api
node_parser_api -->|"returns output"| node_output_view
node_playground -->|"starts language tools"| node_lsp_client
node_lsp_client -->|"sends requests"| node_lsp_worker
node_lsp_worker -->|"serves LSP"| node_lsp_server

click node_cli "https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/cxx.cc"
click node_native_frontend "https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/frontend.cc"
click node_preprocessor "https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/preprocessor.cc"
click node_lexer_parser "https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/parser.cc"
click node_ast "https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/ast_rewriter.cc"
click node_semantic "https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/type_checker.cc"
click node_linker "https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/linker.cc"
click node_js_api "https://github.com/robertoraggi/cplusplus/blob/main/src/js/cxx/api.cc"
click node_parser_api "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-frontend/src/Parser.ts"
click node_codegen "https://github.com/robertoraggi/cplusplus/blob/main/src/codegen/cxx/codegen/codegen.cc"
click node_mlir "https://github.com/robertoraggi/cplusplus/blob/main/src/mlir/cxx/mlir/mlir_emitter.cc"
click node_lsp_server "https://github.com/robertoraggi/cplusplus/blob/main/src/lsp/cxx/lsp/lsp_server.cc"
click node_lsp_worker "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/lsp.worker.ts"
click node_lsp_client "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/lib/lsp-client.ts"
click node_playground "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/App.tsx"
click node_editor "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/code-editor.tsx"
click node_output_view "https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/output-code.tsx"

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_native_frontend,node_preprocessor,node_lexer_parser,node_ast,node_js_api,node_parser_api,node_browser toneBlue
class node_semantic,node_linker toneAmber
class node_codegen,node_mlir toneMint
class node_lsp_server,node_lsp_worker,node_lsp_client toneRose
class node_playground,node_editor,node_output_view,node_developer toneIndigo
```

## Components

### Frontend Core

- [C++ CLI](https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/cxx.cc): `src/frontend/cxx/cxx.cc`
- [Native Frontend](https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/frontend.cc): `src/frontend/cxx/frontend.cc`
- [Preprocessor](https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/preprocessor.cc): `src/parser/cxx/preprocessor.cc`
- [Lexer and Parser](https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/parser.cc): `src/parser/cxx/parser.cc`
- [AST and Rewriter](https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/ast_rewriter.cc): `src/parser/cxx/ast_rewriter.cc`
- [WASM API](https://github.com/robertoraggi/cplusplus/blob/main/src/js/cxx/api.cc): `src/js/cxx/api.cc`
- [Parser API](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-frontend/src/Parser.ts): `packages/cxx-frontend/src/Parser.ts`

### Semantic Analysis

- [Semantic Analysis](https://github.com/robertoraggi/cplusplus/blob/main/src/parser/cxx/type_checker.cc): `src/parser/cxx/type_checker.cc`
- [Linker](https://github.com/robertoraggi/cplusplus/blob/main/src/frontend/cxx/linker.cc): `src/frontend/cxx/linker.cc`

### Code Generation

- [Code Generator](https://github.com/robertoraggi/cplusplus/blob/main/src/codegen/cxx/codegen/codegen.cc): `src/codegen/cxx/codegen/codegen.cc`
- [MLIR Backend](https://github.com/robertoraggi/cplusplus/blob/main/src/mlir/cxx/mlir/mlir_emitter.cc): `src/mlir/cxx/mlir/mlir_emitter.cc`

### Language Services

- [LSP Server](https://github.com/robertoraggi/cplusplus/blob/main/src/lsp/cxx/lsp/lsp_server.cc): `src/lsp/cxx/lsp/lsp_server.cc`
- [LSP Worker](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/lsp.worker.ts): `packages/cxx-playground/src/lsp.worker.ts`
- [LSP Client](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/lib/lsp-client.ts): `packages/cxx-playground/src/lib/lsp-client.ts`

### Browser Playground

- [Playground UI](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/App.tsx): `packages/cxx-playground/src/App.tsx`
- [Code Editor](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/code-editor.tsx): `packages/cxx-playground/src/code-editor.tsx`
- [Output View](https://github.com/robertoraggi/cplusplus/blob/main/packages/cxx-playground/src/output-code.tsx): `packages/cxx-playground/src/output-code.tsx`

### Other components

- **Developer**
- **Browser User**

## Connections

- Developer → C++ CLI: submits source
- C++ CLI → Native Frontend: invokes frontend
- Native Frontend → Preprocessor: processes source
- Native Frontend → Lexer and Parser: parses source
- Native Frontend → Semantic Analysis: analyzes source
- Native Frontend → Linker: links units
- Parser API → WASM API: creates unit
- WASM API → Native Frontend: calls native
- Parser API → AST and Rewriter: exposes transforms
- Parser API → Code Generator: emits code
- Code Generator → MLIR Backend: emits MLIR
- Browser User → Playground UI: uses
- Playground UI → Code Editor: shows editor
- Code Editor → Parser API: submits source
- Parser API → Output View: returns output
- Playground UI → LSP Client: starts language tools
- LSP Client → LSP Worker: sends requests
- LSP Worker → LSP Server: serves LSP
