# colondry/cobalt-language architecture

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

- Interactive diagram: https://gitdiagram.com/colondry/cobalt-language
- Repository: https://github.com/colondry/cobalt-language

## Overview

Cobalt is a compiled programming language and command-line tool: users supply .cb source to build or run, and the compiler translates it through lexing, parsing into an AST, and C++ generation before native compilation/execution. The README also advertises library management and standard-library facilities for base, math, encryption, networking, and system operations. Main orchestration and parser/lexer links are supported by excerpts or the SOURCE INDEX; unsampled subsystem links are omitted where caller-level evidence is unavailable.

Main entry points: [`bin/main.cpp`](https://github.com/colondry/cobalt-language/blob/main/bin/main.cpp) (CLI orchestration), [`bin/ast.hpp`](https://github.com/colondry/cobalt-language/blob/main/bin/ast.hpp) (AST model), [`bin/parser.cpp`](https://github.com/colondry/cobalt-language/blob/main/bin/parser.cpp) (Parser), [`bin/lexer.cpp`](https://github.com/colondry/cobalt-language/blob/main/bin/lexer.cpp) (Tokenizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Compiler CLI"]
  node_cli["CLI orchestration<br/>[main.cpp]"]
  node_libmgr["Library management<br/>[libmanage.cpp]"]
end

subgraph group_front["Language Front End"]
  node_lexer["Tokenizer<br/>[lexer.cpp]"]
  node_parser["Parser<br/>[parser.cpp]"]
  node_ast["AST model<br/>[ast.hpp]"]
  node_visitor["AST visitors<br/>[visitor.hpp]"]
end

subgraph group_backend["C++ Backend"]
  node_codegen["C++ generation<br/>[codeGen.cpp]"]
  node_vgen["Visitor generation<br/>[vgen.hpp]"]
  node_runtime["Cobalt runtime<br/>[inf.hpp]"]
end

subgraph group_libraries["Cobalt Libraries"]
  node_base["Base utilities<br/>[base.cpp]"]
  node_math["Math library<br/>[mathlib.cpp]"]
  node_encryption["Encryption library<br/>[polybius_sq.cpp]"]
  node_streamcipher["Stream cipher<br/>[stream_cipher.cpp]"]
  node_network["Network library<br/>[nbase.cpp]"]
  node_system["System library<br/>[sys.cpp]"]
  node_kernel["Kernel utilities<br/>[kern.hpp]"]
end

node_user(("Cobalt developer"))
node_cppcompiler["C++ compiler"]
node_native["Native executable"]

node_user -->|"builds or runs"| node_cli
node_cli -->|"tokenizes source"| node_lexer
node_cli -->|"parses tokens"| node_parser
node_lexer -->|"provides tokens"| node_parser
node_parser -->|"constructs AST"| node_ast
node_cli -->|"generates C++"| node_codegen
node_codegen -->|"visits AST"| node_ast
node_vgen -->|"visits AST"| node_ast
node_ast -->|"dispatches accepts"| node_visitor
node_cli -->|"compiles generated C++"| node_cppcompiler
node_cppcompiler -->|"produces executable"| node_native
node_cli -->|"runs executable"| node_native
node_cli -->|"manages libraries"| node_libmgr
node_base -->|"uses math API"| node_math
node_encryption -.-> node_streamcipher

click node_cli "https://github.com/colondry/cobalt-language/blob/main/bin/main.cpp"
click node_libmgr "https://github.com/colondry/cobalt-language/blob/main/bin/libmanage.cpp"
click node_lexer "https://github.com/colondry/cobalt-language/blob/main/bin/lexer.cpp"
click node_parser "https://github.com/colondry/cobalt-language/blob/main/bin/parser.cpp"
click node_ast "https://github.com/colondry/cobalt-language/blob/main/bin/ast.hpp"
click node_visitor "https://github.com/colondry/cobalt-language/blob/main/bin/visitor.hpp"
click node_codegen "https://github.com/colondry/cobalt-language/blob/main/bin/codeGen.cpp"
click node_vgen "https://github.com/colondry/cobalt-language/blob/main/bin/vgen.hpp"
click node_runtime "https://github.com/colondry/cobalt-language/blob/main/bin/Bin/inf.hpp"
click node_base "https://github.com/colondry/cobalt-language/blob/main/bin/lib/base/base.cpp"
click node_math "https://github.com/colondry/cobalt-language/blob/main/bin/lib/mathlib/mathlib.cpp"
click node_encryption "https://github.com/colondry/cobalt-language/blob/main/bin/lib/encryption/polybius_sq.cpp"
click node_streamcipher "https://github.com/colondry/cobalt-language/blob/main/bin/lib/encryption/stream_cipher.cpp"
click node_network "https://github.com/colondry/cobalt-language/blob/main/bin/lib/network/nbase.cpp"
click node_system "https://github.com/colondry/cobalt-language/blob/main/bin/lib/sys/sys.cpp"
click node_kernel "https://github.com/colondry/cobalt-language/blob/main/bin/lib/kern/kern.hpp"

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_libmgr toneBlue
class node_lexer,node_parser,node_ast,node_visitor toneAmber
class node_codegen,node_vgen,node_runtime toneMint
class node_base,node_math,node_encryption,node_streamcipher,node_network,node_system,node_kernel toneRose
class node_user,node_cppcompiler,node_native toneIndigo
```

## Components

### Compiler CLI

- [CLI orchestration](https://github.com/colondry/cobalt-language/blob/main/bin/main.cpp): `bin/main.cpp`
- [Library management](https://github.com/colondry/cobalt-language/blob/main/bin/libmanage.cpp): `bin/libmanage.cpp`

### Language Front End

- [Tokenizer](https://github.com/colondry/cobalt-language/blob/main/bin/lexer.cpp): `bin/lexer.cpp`
- [Parser](https://github.com/colondry/cobalt-language/blob/main/bin/parser.cpp): `bin/parser.cpp`
- [AST model](https://github.com/colondry/cobalt-language/blob/main/bin/ast.hpp): `bin/ast.hpp`
- [AST visitors](https://github.com/colondry/cobalt-language/blob/main/bin/visitor.hpp): `bin/visitor.hpp`

### C++ Backend

- [C++ generation](https://github.com/colondry/cobalt-language/blob/main/bin/codeGen.cpp): `bin/codeGen.cpp`
- [Visitor generation](https://github.com/colondry/cobalt-language/blob/main/bin/vgen.hpp): `bin/vgen.hpp`
- [Cobalt runtime](https://github.com/colondry/cobalt-language/blob/main/bin/Bin/inf.hpp): `bin/Bin/inf.hpp`

### Cobalt Libraries

- [Base utilities](https://github.com/colondry/cobalt-language/blob/main/bin/lib/base/base.cpp): `bin/lib/base/base.cpp`
- [Math library](https://github.com/colondry/cobalt-language/blob/main/bin/lib/mathlib/mathlib.cpp): `bin/lib/mathlib/mathlib.cpp`
- [Encryption library](https://github.com/colondry/cobalt-language/blob/main/bin/lib/encryption/polybius_sq.cpp): `bin/lib/encryption/polybius_sq.cpp`
- [Stream cipher](https://github.com/colondry/cobalt-language/blob/main/bin/lib/encryption/stream_cipher.cpp): `bin/lib/encryption/stream_cipher.cpp`
- [Network library](https://github.com/colondry/cobalt-language/blob/main/bin/lib/network/nbase.cpp): `bin/lib/network/nbase.cpp`
- [System library](https://github.com/colondry/cobalt-language/blob/main/bin/lib/sys/sys.cpp): `bin/lib/sys/sys.cpp`
- [Kernel utilities](https://github.com/colondry/cobalt-language/blob/main/bin/lib/kern/kern.hpp): `bin/lib/kern/kern.hpp`

### Other components

- **Cobalt developer**
- **C++ compiler**
- **Native executable**

## Connections

- Cobalt developer → CLI orchestration: builds or runs (evidence: `README.md`)
- CLI orchestration → Tokenizer: tokenizes source (evidence: `bin/main.cpp`)
- CLI orchestration → Parser: parses tokens (evidence: `bin/main.cpp`)
- Tokenizer → Parser: provides tokens
- Parser → AST model: constructs AST
- CLI orchestration → C++ generation: generates C++ (evidence: `bin/main.cpp`)
- C++ generation → AST model: visits AST
- Visitor generation → AST model: visits AST (evidence: `bin/vgen.hpp`)
- AST model → AST visitors: dispatches accepts (evidence: `bin/ast.hpp`)
- CLI orchestration → C++ compiler: compiles generated C++ (evidence: `README.md`)
- C++ compiler → Native executable: produces executable (evidence: `README.md`)
- CLI orchestration → Native executable: runs executable (evidence: `bin/main.cpp`)
- CLI orchestration → Library management: manages libraries (evidence: `bin/main.cpp`)
- Base utilities → Math library: uses math API (evidence: `bin/lib/base/base.cpp`)
- Encryption library → Stream cipher
