# insomnius/somnix architecture

> Architecture diagram of the GitHub repository insomnius/somnix, 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/insomnius/somnix
- Repository: https://github.com/insomnius/somnix

## Overview

Somnix is a design-stage compiled language, not an implemented compiler or runtime. The graph summarizes the README’s proposed source-to-execution workflow and its native, concurrency, and GPU capabilities. Component paths point only to the existing enclosing directories; the available evidence does not establish finer implementation boundaries or runtime call wiring.

Main entry points: [`runtime`](https://github.com/insomnius/somnix/tree/main/runtime) (C runtime), [`compiler`](https://github.com/insomnius/somnix/tree/main/compiler) (Type checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler and execution"]
  node_lexer["Lexer"]
  node_parser["Parser"]
  node_checker["Type checker"]
  node_interpreter["Reference interpreter"]
  node_cgen["C generator"]
  node_native["Native executable"]
end

subgraph group_concurrency["Concurrency runtime"]
  node_runtime["C runtime"]
  node_tasks["Thread-backed tasks"]
  node_channels["Typed channels"]
  node_waitgroups["Wait groups"]
end

subgraph group_gpu["GPU programming"]
  node_gpuapi["GPU operations"]
  node_cuda["CUDA kernels"]
  node_gpuexec["GPU execution"]
end

node_author(("Language user"))
node_source["Somnix source"]

node_author -->|"writes"| node_source
node_source -->|"lexes"| node_lexer
node_lexer -->|"tokens"| node_parser
node_parser -->|"checks"| node_checker
node_checker -->|"interprets"| node_interpreter
node_checker -->|"generates C"| node_cgen
node_interpreter -->|"validates against"| node_native
node_cgen -->|"generates"| node_native
node_runtime -->|"provides"| node_tasks
node_runtime -->|"provides"| node_channels
node_runtime -->|"provides"| node_waitgroups
node_gpuapi -->|"allocates, transfers, launches, synchronizes"| node_gpuexec
node_cuda -->|"generates kernels for"| node_gpuexec

click node_lexer "https://github.com/insomnius/somnix/tree/main/compiler"
click node_parser "https://github.com/insomnius/somnix/tree/main/compiler"
click node_checker "https://github.com/insomnius/somnix/tree/main/compiler"
click node_interpreter "https://github.com/insomnius/somnix/tree/main/compiler"
click node_cgen "https://github.com/insomnius/somnix/tree/main/compiler"
click node_runtime "https://github.com/insomnius/somnix/tree/main/runtime"
click node_tasks "https://github.com/insomnius/somnix/tree/main/runtime"
click node_channels "https://github.com/insomnius/somnix/tree/main/runtime"
click node_waitgroups "https://github.com/insomnius/somnix/tree/main/runtime"
click node_gpuapi "https://github.com/insomnius/somnix/tree/main/compiler"
click node_cuda "https://github.com/insomnius/somnix/tree/main/compiler"

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_lexer,node_parser,node_checker,node_interpreter,node_cgen,node_native,node_author toneBlue
class node_runtime,node_tasks,node_channels,node_waitgroups toneAmber
class node_gpuapi,node_cuda,node_gpuexec toneMint
class node_source toneIndigo
```

## Components

### Compiler and execution

- [Lexer](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- [Parser](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- [Type checker](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- [Reference interpreter](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- [C generator](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- **Native executable**

### Concurrency runtime

- [C runtime](https://github.com/insomnius/somnix/tree/main/runtime): `runtime`
- [Thread-backed tasks](https://github.com/insomnius/somnix/tree/main/runtime): `runtime`
- [Typed channels](https://github.com/insomnius/somnix/tree/main/runtime): `runtime`
- [Wait groups](https://github.com/insomnius/somnix/tree/main/runtime): `runtime`

### GPU programming

- [GPU operations](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- [CUDA kernels](https://github.com/insomnius/somnix/tree/main/compiler): `compiler`
- **GPU execution**

### Other components

- **Language user**
- **Somnix source**

## Connections

- Language user → Somnix source: writes
- Somnix source → Lexer: lexes
- Lexer → Parser: tokens
- Parser → Type checker: checks
- Type checker → Reference interpreter: interprets
- Type checker → C generator: generates C
- Reference interpreter → Native executable: validates against
- C generator → Native executable: generates
- C runtime → Thread-backed tasks: provides
- C runtime → Typed channels: provides
- C runtime → Wait groups: provides
- GPU operations → GPU execution: allocates, transfers, launches, synchronizes
- CUDA kernels → GPU execution: generates kernels for
