# rust-lang/rustlings architecture

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

- Interactive diagram: https://gitdiagram.com/rust-lang/rustlings
- Repository: https://github.com/rust-lang/rustlings

## Overview

Rustlings is a terminal-based Rust learning tool: learners select an exercise, edit its source, run it, and advance as exercises pass. Its runtime also supports initializing exercise workspaces, checking all exercises, and developer commands for validating or maintaining exercise sets. The graph focuses on those product workflows and the exercise metadata/runtime layers. Several implementation files were only indexed or excerpted, so uncertain wiring is omitted rather than inferred.

Main entry points: [`src/main.rs`](https://github.com/rust-lang/rustlings/blob/main/src/main.rs) (CLI dispatcher), [`src/watch/state.rs`](https://github.com/rust-lang/rustlings/blob/main/src/watch/state.rs) (Run and feedback), [`src/init.rs`](https://github.com/rust-lang/rustlings/blob/main/src/init.rs) (Workspace setup), [`src/exercise.rs`](https://github.com/rust-lang/rustlings/blob/main/src/exercise.rs) (Exercise runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and setup"]
  node_cli["CLI dispatcher<br/>[main.rs]"]
  node_setup["Workspace setup<br/>[init.rs]"]
end

subgraph group_learning["Learning content"]
  node_embedded["Embedded content<br/>[embedded.rs]"]
  node_metadata["Exercise metadata<br/>[info_file.rs]"]
  node_exercise_files["Exercise prompts"]
  node_solutions["Solutions"]
end

subgraph group_runtime["Exercise runtime"]
  node_state["Learning state<br/>[app_state.rs]"]
  node_list_ui["Exercise browser<br/>[state.rs]"]
  node_runner["Exercise runner<br/>[exercise.rs]"]
  node_watch_ui["Run and feedback<br/>[state.rs]"]
  node_watch_events["Watch events<br/>[watch.rs]"]
  node_terminal["Terminal support<br/>[term.rs]"]
  node_editor["Editor integration<br/>[editor.rs]"]
end

subgraph group_maintenance["Exercise maintenance"]
  node_dev_commands["Developer commands<br/>[dev.rs]"]
  node_exercise_check["Exercise checks<br/>[check.rs]"]
  node_manifest["Cargo manifest update<br/>[cargo_toml.rs]"]
end

node_learner(("Learner"))
node_cargo["Cargo toolchain"]

node_learner -->|"uses"| node_cli
node_cli -->|"dispatches"| node_setup
node_setup -->|"loads"| node_embedded
node_setup -->|"parses"| node_metadata
node_setup -->|"updates"| node_manifest
node_embedded -->|"writes"| node_exercise_files
node_metadata -->|"describes"| node_exercise_files
node_learner -.->|"chooses exercise"| node_list_ui
node_list_ui -->|"renders"| node_state
node_cli -->|"creates"| node_state
node_cli -.->|"runs"| node_watch_ui
node_watch_ui -->|"runs exercise"| node_runner
node_runner -->|"builds and runs"| node_cargo
node_runner -.->|"compiles"| node_exercise_files
node_watch_ui -.->|"checks solution"| node_solutions
node_watch_events -.->|"delivers events"| node_watch_ui
node_watch_ui -.->|"renders feedback"| node_terminal
node_learner -.->|"edits in"| node_editor
node_cli -->|"dispatches"| node_dev_commands
node_dev_commands -->|"checks"| node_exercise_check
node_exercise_check -->|"runs exercises"| node_runner
node_exercise_check -.->|"checks solutions"| node_solutions

click node_cli "https://github.com/rust-lang/rustlings/blob/main/src/main.rs"
click node_setup "https://github.com/rust-lang/rustlings/blob/main/src/init.rs"
click node_embedded "https://github.com/rust-lang/rustlings/blob/main/src/embedded.rs"
click node_metadata "https://github.com/rust-lang/rustlings/blob/main/src/info_file.rs"
click node_exercise_files "https://github.com/rust-lang/rustlings/tree/main/exercises"
click node_solutions "https://github.com/rust-lang/rustlings/tree/main/solutions"
click node_state "https://github.com/rust-lang/rustlings/blob/main/src/app_state.rs"
click node_list_ui "https://github.com/rust-lang/rustlings/blob/main/src/list/state.rs"
click node_runner "https://github.com/rust-lang/rustlings/blob/main/src/exercise.rs"
click node_watch_ui "https://github.com/rust-lang/rustlings/blob/main/src/watch/state.rs"
click node_watch_events "https://github.com/rust-lang/rustlings/blob/main/src/watch.rs"
click node_terminal "https://github.com/rust-lang/rustlings/blob/main/src/term.rs"
click node_editor "https://github.com/rust-lang/rustlings/blob/main/src/editor.rs"
click node_dev_commands "https://github.com/rust-lang/rustlings/blob/main/src/dev.rs"
click node_exercise_check "https://github.com/rust-lang/rustlings/blob/main/src/dev/check.rs"
click node_manifest "https://github.com/rust-lang/rustlings/blob/main/src/cargo_toml.rs"

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_setup toneBlue
class node_embedded,node_metadata,node_exercise_files,node_solutions toneAmber
class node_state,node_list_ui,node_runner,node_watch_ui,node_watch_events,node_terminal,node_editor toneMint
class node_dev_commands,node_exercise_check,node_manifest toneRose
class node_learner,node_cargo toneIndigo
```

## Components

### CLI and setup

- [CLI dispatcher](https://github.com/rust-lang/rustlings/blob/main/src/main.rs): `src/main.rs`
- [Workspace setup](https://github.com/rust-lang/rustlings/blob/main/src/init.rs): `src/init.rs`

### Learning content

- [Embedded content](https://github.com/rust-lang/rustlings/blob/main/src/embedded.rs): `src/embedded.rs`
- [Exercise metadata](https://github.com/rust-lang/rustlings/blob/main/src/info_file.rs): `src/info_file.rs`
- [Exercise prompts](https://github.com/rust-lang/rustlings/tree/main/exercises): `exercises`
- [Solutions](https://github.com/rust-lang/rustlings/tree/main/solutions): `solutions`

### Exercise runtime

- [Learning state](https://github.com/rust-lang/rustlings/blob/main/src/app_state.rs): `src/app_state.rs`
- [Exercise browser](https://github.com/rust-lang/rustlings/blob/main/src/list/state.rs): `src/list/state.rs`
- [Exercise runner](https://github.com/rust-lang/rustlings/blob/main/src/exercise.rs): `src/exercise.rs`
- [Run and feedback](https://github.com/rust-lang/rustlings/blob/main/src/watch/state.rs): `src/watch/state.rs`
- [Watch events](https://github.com/rust-lang/rustlings/blob/main/src/watch.rs): `src/watch.rs`
- [Terminal support](https://github.com/rust-lang/rustlings/blob/main/src/term.rs): `src/term.rs`
- [Editor integration](https://github.com/rust-lang/rustlings/blob/main/src/editor.rs): `src/editor.rs`

### Exercise maintenance

- [Developer commands](https://github.com/rust-lang/rustlings/blob/main/src/dev.rs): `src/dev.rs`
- [Exercise checks](https://github.com/rust-lang/rustlings/blob/main/src/dev/check.rs): `src/dev/check.rs`
- [Cargo manifest update](https://github.com/rust-lang/rustlings/blob/main/src/cargo_toml.rs): `src/cargo_toml.rs`

### Other components

- **Learner**
- **Cargo toolchain**

## Connections

- Learner → CLI dispatcher: uses (evidence: `src/main.rs`)
- CLI dispatcher → Workspace setup: dispatches (evidence: `src/main.rs`)
- Workspace setup → Embedded content: loads (evidence: `src/init.rs`)
- Workspace setup → Exercise metadata: parses (evidence: `src/init.rs`)
- Workspace setup → Cargo manifest update: updates (evidence: `src/init.rs`)
- Embedded content → Exercise prompts: writes (evidence: `src/embedded.rs`)
- Exercise metadata → Exercise prompts: describes (evidence: `src/info_file.rs`)
- Learner → Exercise browser: chooses exercise
- Exercise browser → Learning state: renders (evidence: `src/list/state.rs`)
- CLI dispatcher → Learning state: creates (evidence: `src/main.rs`)
- CLI dispatcher → Run and feedback: runs
- Run and feedback → Exercise runner: runs exercise (evidence: `src/watch/state.rs`)
- Exercise runner → Cargo toolchain: builds and runs (evidence: `src/exercise.rs`)
- Exercise runner → Exercise prompts: compiles
- Run and feedback → Solutions: checks solution
- Watch events → Run and feedback: delivers events (evidence: `src/watch.rs`)
- Run and feedback → Terminal support: renders feedback
- Learner → Editor integration: edits in
- CLI dispatcher → Developer commands: dispatches (evidence: `src/main.rs`)
- Developer commands → Exercise checks: checks (evidence: `src/dev.rs`)
- Exercise checks → Exercise runner: runs exercises (evidence: `src/dev/check.rs`)
- Exercise checks → Solutions: checks solutions
