# usestrata/strata architecture

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

- Interactive diagram: https://gitdiagram.com/usestrata/strata
- Repository: https://github.com/usestrata/strata

## Overview

Strata is a self-hosted, statically typed language and native compiler for games and real-time software. The main workflow takes source through lexing, parsing, type checking, and code generation, then assembles and links a native program; it also supports C output, projects, and C interop. Separate capabilities include the embeddable compiler API and editor syntax highlighting. The README documents the compiler stages and capabilities, but most compiler implementation files were not sampled, so internal call relationships are not inferred.

Main entry points: [`compiler/src/stratac.strata`](https://github.com/usestrata/strata/blob/main/compiler/src/stratac.strata) (stratac CLI), [`compiler/src/checker.strata`](https://github.com/usestrata/strata/blob/main/compiler/src/checker.strata) (Type Checker), [`compiler/api/strata.h`](https://github.com/usestrata/strata/blob/main/compiler/api/strata.h) (C Embedding API), [`compiler/src/lexer.strata`](https://github.com/usestrata/strata/blob/main/compiler/src/lexer.strata) (Lexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler"]
  node_cli["stratac CLI<br/>[stratac.strata]"]
  node_lexer["Lexer<br/>[lexer.strata]"]
  node_parser["Parser<br/>[parser.strata]"]
  node_checker["Type Checker<br/>[checker.strata]"]
  node_modules["Module Loading<br/>[modules.strata]"]
  node_lowering["IR Lowering<br/>[lower.strata]"]
  node_optimizer["Optimizer<br/>[opt.strata]"]
end

subgraph group_targets["Code Generation"]
  node_native["Native Backend<br/>[native.strata]"]
  node_assembler["Assembler<br/>[asm.strata]"]
  node_linker["Linker<br/>[linker.strata]"]
  node_c_output["C Output<br/>[cheader.strata]"]
end

subgraph group_projects["Projects and Embedding"]
  node_project["Project Builds<br/>[project.strata]"]
  node_embed_api["C Embedding API<br/>[strata.h]"]
  node_cpp_api["C++ Wrapper<br/>[strata.hpp]"]
  node_cs_api["C&#35; Bindings<br/>[Strata.cs]"]
  node_runtime["Runtime Libraries"]
end

subgraph group_editors["Editor Support"]
  node_vscode["VS Code Grammar"]
  node_visualstudio["Visual Studio Support"]
end

node_developer(("Programmer"))
node_source["Strata Source"]
node_binary["Native Program"]

node_developer -->|"writes"| node_source
node_developer -->|"invokes"| node_cli
node_cli -->|"compiles source"| node_lexer
node_lexer -->|"tokens for"| node_parser
node_parser -->|"checks with"| node_checker
node_checker -.->|"supports imports"| node_modules
node_checker -.->|"lowers checked code"| node_lowering
node_lowering -.->|"optimizes IR"| node_optimizer
node_optimizer -->|"generates native code"| node_native
node_native -->|"emits assembly"| node_assembler
node_assembler -->|"produces object code"| node_linker
node_linker -->|"links executable"| node_binary
node_cli -->|"can target C"| node_c_output
node_cli -->|"builds projects"| node_project
node_developer -->|"embeds compiler"| node_embed_api
node_cpp_api -->|"wraps"| node_embed_api
node_cs_api -->|"calls API"| node_embed_api
node_project -.->|"uses libraries"| node_runtime
node_developer -->|"edits with"| node_vscode
node_developer -->|"edits with"| node_visualstudio

click node_cli "https://github.com/usestrata/strata/blob/main/compiler/src/stratac.strata"
click node_lexer "https://github.com/usestrata/strata/blob/main/compiler/src/lexer.strata"
click node_parser "https://github.com/usestrata/strata/blob/main/compiler/src/parser.strata"
click node_checker "https://github.com/usestrata/strata/blob/main/compiler/src/checker.strata"
click node_modules "https://github.com/usestrata/strata/blob/main/compiler/src/modules.strata"
click node_lowering "https://github.com/usestrata/strata/blob/main/compiler/src/lower.strata"
click node_optimizer "https://github.com/usestrata/strata/blob/main/compiler/src/opt.strata"
click node_native "https://github.com/usestrata/strata/blob/main/compiler/src/native.strata"
click node_assembler "https://github.com/usestrata/strata/blob/main/compiler/src/asm.strata"
click node_linker "https://github.com/usestrata/strata/blob/main/compiler/src/linker.strata"
click node_c_output "https://github.com/usestrata/strata/blob/main/compiler/src/cheader.strata"
click node_project "https://github.com/usestrata/strata/blob/main/compiler/src/project.strata"
click node_embed_api "https://github.com/usestrata/strata/blob/main/compiler/api/strata.h"
click node_cpp_api "https://github.com/usestrata/strata/blob/main/compiler/api/strata.hpp"
click node_cs_api "https://github.com/usestrata/strata/blob/main/compiler/api/Strata.cs"
click node_runtime "https://github.com/usestrata/strata/tree/main/compiler/lib"
click node_vscode "https://github.com/usestrata/strata/blob/main/editors/vscode/syntaxes/strata.tmLanguage.json"
click node_visualstudio "https://github.com/usestrata/strata/tree/main/editors/visualstudio"

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_lexer,node_parser,node_checker,node_modules,node_lowering,node_optimizer toneBlue
class node_native,node_assembler,node_linker,node_c_output toneAmber
class node_project,node_embed_api,node_cpp_api,node_cs_api,node_runtime toneMint
class node_vscode,node_visualstudio toneRose
class node_developer,node_source,node_binary toneIndigo
```

## Components

### Compiler

- [stratac CLI](https://github.com/usestrata/strata/blob/main/compiler/src/stratac.strata): `compiler/src/stratac.strata`
- [Lexer](https://github.com/usestrata/strata/blob/main/compiler/src/lexer.strata): `compiler/src/lexer.strata`
- [Parser](https://github.com/usestrata/strata/blob/main/compiler/src/parser.strata): `compiler/src/parser.strata`
- [Type Checker](https://github.com/usestrata/strata/blob/main/compiler/src/checker.strata): `compiler/src/checker.strata`
- [Module Loading](https://github.com/usestrata/strata/blob/main/compiler/src/modules.strata): `compiler/src/modules.strata`
- [IR Lowering](https://github.com/usestrata/strata/blob/main/compiler/src/lower.strata): `compiler/src/lower.strata`
- [Optimizer](https://github.com/usestrata/strata/blob/main/compiler/src/opt.strata): `compiler/src/opt.strata`

### Code Generation

- [Native Backend](https://github.com/usestrata/strata/blob/main/compiler/src/native.strata): `compiler/src/native.strata`
- [Assembler](https://github.com/usestrata/strata/blob/main/compiler/src/asm.strata): `compiler/src/asm.strata`
- [Linker](https://github.com/usestrata/strata/blob/main/compiler/src/linker.strata): `compiler/src/linker.strata`
- [C Output](https://github.com/usestrata/strata/blob/main/compiler/src/cheader.strata): `compiler/src/cheader.strata`

### Projects and Embedding

- [Project Builds](https://github.com/usestrata/strata/blob/main/compiler/src/project.strata): `compiler/src/project.strata`
- [C Embedding API](https://github.com/usestrata/strata/blob/main/compiler/api/strata.h): `compiler/api/strata.h`
- [C++ Wrapper](https://github.com/usestrata/strata/blob/main/compiler/api/strata.hpp): `compiler/api/strata.hpp`
- [C# Bindings](https://github.com/usestrata/strata/blob/main/compiler/api/Strata.cs): `compiler/api/Strata.cs`
- [Runtime Libraries](https://github.com/usestrata/strata/tree/main/compiler/lib): `compiler/lib`

### Editor Support

- [VS Code Grammar](https://github.com/usestrata/strata/blob/main/editors/vscode/syntaxes/strata.tmLanguage.json): `editors/vscode/syntaxes/strata.tmLanguage.json`
- [Visual Studio Support](https://github.com/usestrata/strata/tree/main/editors/visualstudio): `editors/visualstudio`

### Other components

- **Programmer**
- **Strata Source**
- **Native Program**

## Connections

- Programmer → Strata Source: writes (evidence: `README.md`)
- Programmer → stratac CLI: invokes (evidence: `README.md`)
- stratac CLI → Lexer: compiles source (evidence: `README.md`)
- Lexer → Parser: tokens for (evidence: `README.md`)
- Parser → Type Checker: checks with (evidence: `README.md`)
- Type Checker → Module Loading: supports imports
- Type Checker → IR Lowering: lowers checked code
- IR Lowering → Optimizer: optimizes IR
- Optimizer → Native Backend: generates native code (evidence: `README.md`)
- Native Backend → Assembler: emits assembly (evidence: `README.md`)
- Assembler → Linker: produces object code (evidence: `README.md`)
- Linker → Native Program: links executable (evidence: `README.md`)
- stratac CLI → C Output: can target C (evidence: `README.md`)
- stratac CLI → Project Builds: builds projects (evidence: `README.md`)
- Programmer → C Embedding API: embeds compiler (evidence: `compiler/api/strata.h`)
- C++ Wrapper → C Embedding API: wraps (evidence: `compiler/api/strata.hpp`)
- C# Bindings → C Embedding API: calls API (evidence: `compiler/api/Strata.cs`)
- Project Builds → Runtime Libraries: uses libraries
- Programmer → VS Code Grammar: edits with (evidence: `README.md`)
- Programmer → Visual Studio Support: edits with (evidence: `README.md`)
