# overtekk/codexion architecture

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

## Overview

Codexion simulates coders competing for shared dongles under FIFO or EDF scheduling. The runtime starts by validating the eight command-line parameters and initializing simulation state, then creates coder and monitor threads. Each coder requests dongles through the selected scheduler, compiles, releases dongles, then debugs and refactors; monitoring ends the run on burnout or when all coders meet the compile target. Mutex-protected state and serialized logs support concurrency. The README documents both scheduling policies; some lifecycle wiring is not shown in the excerpts, so those links are omitted.

Main entry points: [`coders/simulation/coder.c`](https://github.com/overtekk/codexion/blob/main/coders/simulation/coder.c) (Coder actions), [`coders/simulation/monitoring.c`](https://github.com/overtekk/codexion/blob/main/coders/simulation/monitoring.c) (Burnout monitor), [`coders/main.c`](https://github.com/overtekk/codexion/blob/main/coders/main.c) (Program entry), [`coders/simulation/scheduler_edf.c`](https://github.com/overtekk/codexion/blob/main/coders/simulation/scheduler_edf.c) (EDF scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Startup and state"]
  node_entry["Program entry<br/>[main.c]"]
  node_arguments["Argument validation<br/>[check_arguments.c]"]
  node_state["Simulation state<br/>[init_struct.c]"]
  node_thread_lifecycle["Thread lifecycle<br/>[create_thread.c]"]
end

subgraph group_runtime["Simulation runtime"]
  node_coder["Coder actions<br/>[coder.c]"]
  node_monitor["Burnout monitor<br/>[monitoring.c]"]
end

subgraph group_scheduling["Dongle scheduling"]
  node_dongles["Dongle management"]
  node_fifo["FIFO scheduler<br/>[scheduler_fifo.c]"]
  node_edf["EDF scheduler<br/>[scheduler_edf.c]"]
  node_fifo_queue["FIFO queue<br/>[chained_queue.c]"]
  node_edf_heap["EDF priority heap<br/>[heap_queue.c]"]
end

subgraph group_support["Synchronization and output"]
  node_mutexes["Mutex setup<br/>[create_mutex.c]"]
  node_state_access["State accessors<br/>[getter.c]"]
  node_logging["Simulation logs<br/>[logs.c]"]
end

node_user(("CLI user"))

node_user -->|"runs"| node_entry
node_entry -->|"validates input"| node_arguments
node_arguments -->|"initializes state"| node_state
node_entry -->|"initializes locks"| node_mutexes
node_entry -->|"starts and joins"| node_thread_lifecycle
node_coder -->|"selects FIFO"| node_fifo
node_coder -->|"selects EDF"| node_edf
node_coder -->|"releases dongles"| node_dongles
node_coder -->|"logs actions"| node_logging
node_fifo -.->|"manages queue"| node_fifo_queue
node_edf -->|"pushes and pops"| node_edf_heap
node_edf -->|"requests dongles"| node_dongles
node_monitor -->|"checks state"| node_state_access
node_monitor -->|"logs burnout"| node_logging
node_monitor -->|"wakes waiters"| node_fifo_queue
node_monitor -->|"wakes waiters"| node_edf_heap

click node_entry "https://github.com/overtekk/codexion/blob/main/coders/main.c"
click node_arguments "https://github.com/overtekk/codexion/blob/main/coders/utils/check_arguments.c"
click node_state "https://github.com/overtekk/codexion/blob/main/coders/utils/init_struct.c"
click node_thread_lifecycle "https://github.com/overtekk/codexion/blob/main/coders/thread_managements/create_thread.c"
click node_coder "https://github.com/overtekk/codexion/blob/main/coders/simulation/coder.c"
click node_monitor "https://github.com/overtekk/codexion/blob/main/coders/simulation/monitoring.c"
click node_dongles "https://github.com/overtekk/codexion/blob/main/coders/simulation/dongles_management.c"
click node_fifo "https://github.com/overtekk/codexion/blob/main/coders/simulation/scheduler_fifo.c"
click node_edf "https://github.com/overtekk/codexion/blob/main/coders/simulation/scheduler_edf.c"
click node_fifo_queue "https://github.com/overtekk/codexion/blob/main/coders/thread_managements/chained_queue.c"
click node_edf_heap "https://github.com/overtekk/codexion/blob/main/coders/thread_managements/heap_queue.c"
click node_mutexes "https://github.com/overtekk/codexion/blob/main/coders/thread_managements/create_mutex.c"
click node_state_access "https://github.com/overtekk/codexion/blob/main/coders/utils/getter.c"
click node_logging "https://github.com/overtekk/codexion/blob/main/coders/simulation/logs.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_entry,node_arguments,node_state,node_thread_lifecycle,node_user toneBlue
class node_coder,node_monitor toneAmber
class node_dongles,node_fifo,node_edf,node_fifo_queue,node_edf_heap toneMint
class node_mutexes,node_state_access,node_logging toneRose
```

## Components

### Startup and state

- [Program entry](https://github.com/overtekk/codexion/blob/main/coders/main.c): `coders/main.c`
- [Argument validation](https://github.com/overtekk/codexion/blob/main/coders/utils/check_arguments.c): `coders/utils/check_arguments.c`
- [Simulation state](https://github.com/overtekk/codexion/blob/main/coders/utils/init_struct.c): `coders/utils/init_struct.c`
- [Thread lifecycle](https://github.com/overtekk/codexion/blob/main/coders/thread_managements/create_thread.c): `coders/thread_managements/create_thread.c`

### Simulation runtime

- [Coder actions](https://github.com/overtekk/codexion/blob/main/coders/simulation/coder.c): `coders/simulation/coder.c`
- [Burnout monitor](https://github.com/overtekk/codexion/blob/main/coders/simulation/monitoring.c): `coders/simulation/monitoring.c`

### Dongle scheduling

- [Dongle management](https://github.com/overtekk/codexion/blob/main/coders/simulation/dongles_management.c): `coders/simulation/dongles_management.c`
- [FIFO scheduler](https://github.com/overtekk/codexion/blob/main/coders/simulation/scheduler_fifo.c): `coders/simulation/scheduler_fifo.c`
- [EDF scheduler](https://github.com/overtekk/codexion/blob/main/coders/simulation/scheduler_edf.c): `coders/simulation/scheduler_edf.c`
- [FIFO queue](https://github.com/overtekk/codexion/blob/main/coders/thread_managements/chained_queue.c): `coders/thread_managements/chained_queue.c`
- [EDF priority heap](https://github.com/overtekk/codexion/blob/main/coders/thread_managements/heap_queue.c): `coders/thread_managements/heap_queue.c`

### Synchronization and output

- [Mutex setup](https://github.com/overtekk/codexion/blob/main/coders/thread_managements/create_mutex.c): `coders/thread_managements/create_mutex.c`
- [State accessors](https://github.com/overtekk/codexion/blob/main/coders/utils/getter.c): `coders/utils/getter.c`
- [Simulation logs](https://github.com/overtekk/codexion/blob/main/coders/simulation/logs.c): `coders/simulation/logs.c`

### Other components

- **CLI user**

## Connections

- CLI user → Program entry: runs (evidence: `README.md`)
- Program entry → Argument validation: validates input (evidence: `coders/main.c`)
- Argument validation → Simulation state: initializes state (evidence: `coders/utils/check_arguments.c`)
- Program entry → Mutex setup: initializes locks (evidence: `coders/main.c`)
- Program entry → Thread lifecycle: starts and joins (evidence: `coders/main.c`)
- Coder actions → FIFO scheduler: selects FIFO (evidence: `coders/simulation/coder.c`)
- Coder actions → EDF scheduler: selects EDF (evidence: `coders/simulation/coder.c`)
- Coder actions → Dongle management: releases dongles (evidence: `coders/simulation/coder.c`)
- Coder actions → Simulation logs: logs actions (evidence: `coders/simulation/coder.c`)
- FIFO scheduler → FIFO queue: manages queue
- EDF scheduler → EDF priority heap: pushes and pops (evidence: `coders/simulation/scheduler_edf.c`)
- EDF scheduler → Dongle management: requests dongles (evidence: `coders/simulation/scheduler_edf.c`)
- Burnout monitor → State accessors: checks state (evidence: `coders/simulation/monitoring.c`)
- Burnout monitor → Simulation logs: logs burnout (evidence: `coders/simulation/monitoring.c`)
- Burnout monitor → FIFO queue: wakes waiters (evidence: `coders/simulation/monitoring.c`)
- Burnout monitor → EDF priority heap: wakes waiters (evidence: `coders/simulation/monitoring.c`)
