# spectreconsole/spectre.console architecture

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

## Overview

Spectre.Console is a .NET library for building styled, interactive console applications. An application writes renderables through the console API; renderables are measured and converted into segments, then the console backend emits text and terminal control sequences. The repository also contains dedicated subsystems for prompts, live displays and progress, structured widgets, JSON and image extensions, and terminal styling/capability detection. The sampled sources establish the rendering and test-console paths; links to several unsampled subsystems are shown as unverified rather than asserted as observed calls.

Main entry points: [`src/Spectre.Console/AnsiConsole.cs`](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/AnsiConsole.cs) (Console API), [`src/Spectre.Console/Rendering/IRenderable.cs`](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/IRenderable.cs) (Renderable contract), [`src/Spectre.Console.Ansi/AnsiWriter.cs`](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Ansi/AnsiWriter.cs) (ANSI writer), [`src/Spectre.Console.Testing/TestConsole.cs`](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Testing/TestConsole.cs) (Test console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["Console runtime"]
  node_console_api["Console API<br/>[AnsiConsole.cs]"]
  node_console_contract["Console contract<br/>[IAnsiConsole.cs]"]
  node_profile["Console profile<br/>[Profile.cs]"]
  node_capabilities["Capabilities<br/>[Capabilities.cs]"]
  node_backend["Console backends"]
  node_test_console["Test console<br/>[TestConsole.cs]"]
end

subgraph group_render["Rendering and widgets"]
  node_pipeline["Render pipeline<br/>[RenderPipeline.cs]"]
  node_renderable["Renderable contract<br/>[IRenderable.cs]"]
  node_segments["Rendered segments<br/>[Segment.cs]"]
  node_text_paragraph["Text and paragraphs<br/>[Paragraph.cs]"]
  node_markup["Markup<br/>[Markup.cs]"]
  node_structured_widgets["Structured widgets"]
end

subgraph group_terminal["Terminal styling"]
  node_ansi_writer["ANSI writer<br/>[AnsiWriter.cs]"]
  node_style_colors["Styles and colors<br/>[Style.cs]"]
end

subgraph group_interaction["Interactive displays"]
  node_prompts["Prompts<br/>[Prompts]"]
  node_live["Live displays<br/>[LiveDisplay.cs]"]
  node_progress["Progress reporting<br/>[Progress.cs]"]
end

subgraph group_extensions["Extensions"]
  node_json["JSON rendering<br/>[JsonParser.cs]"]
  node_image["Canvas images<br/>[CanvasImage.cs]"]
end

node_application(("Application"))
node_terminal_output(("Terminal"))

node_application -->|"writes through"| node_console_api
node_console_api -.->|"accepts renderables"| node_renderable
node_renderable -->|"processes through"| node_pipeline
node_renderable -->|"renders as"| node_segments
node_text_paragraph -->|"produces"| node_segments
node_console_api -.->|"uses profile"| node_profile
node_profile -->|"holds capabilities"| node_capabilities
node_console_api -.->|"dispatches to"| node_backend
node_backend -.->|"emits terminal codes"| node_ansi_writer
node_ansi_writer -->|"encodes styling"| node_style_colors
node_markup -.->|"parses styles"| node_style_colors
node_console_api -.->|"offers prompts"| node_prompts
node_console_api -.->|"offers live output"| node_live
node_live -.->|"includes progress"| node_progress
node_application -->|"uses widgets"| node_structured_widgets
node_application -->|"styles text with"| node_markup
node_json -.->|"renders as"| node_renderable
node_image -->|"implements rendering"| node_renderable
node_test_console -->|"creates console"| node_console_api
node_test_console -->|"captures output"| node_terminal_output
node_ansi_writer -.->|"writes sequences"| node_terminal_output

click node_console_api "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/AnsiConsole.cs"
click node_console_contract "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/IAnsiConsole.cs"
click node_profile "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Profile.cs"
click node_capabilities "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Capabilities.cs"
click node_backend "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Internal/Backends/Ansi/AnsiConsoleBackend.cs"
click node_pipeline "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/RenderPipeline.cs"
click node_renderable "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/IRenderable.cs"
click node_segments "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/Segment.cs"
click node_text_paragraph "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Paragraph.cs"
click node_markup "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Markup.cs"
click node_structured_widgets "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Table/TableRendererContext.cs"
click node_ansi_writer "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Ansi/AnsiWriter.cs"
click node_style_colors "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Ansi/Style.cs"
click node_prompts "https://github.com/spectreconsole/spectre.console/tree/main/src/Spectre.Console/Prompts"
click node_live "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Live/LiveDisplay.cs"
click node_progress "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Live/Progress/Progress.cs"
click node_json "https://github.com/spectreconsole/spectre.console/blob/main/src/Extensions/Spectre.Console.Json/JsonParser.cs"
click node_image "https://github.com/spectreconsole/spectre.console/blob/main/src/Extensions/Spectre.Console.ImageSharp/CanvasImage.cs"
click node_test_console "https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Testing/TestConsole.cs"

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_console_api,node_console_contract,node_profile,node_capabilities,node_backend,node_test_console toneBlue
class node_pipeline,node_renderable,node_segments,node_text_paragraph,node_markup,node_structured_widgets toneAmber
class node_ansi_writer,node_style_colors toneMint
class node_prompts,node_live,node_progress toneRose
class node_json,node_image,node_application,node_terminal_output toneIndigo
```

## Components

### Console runtime

- [Console API](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/AnsiConsole.cs): `src/Spectre.Console/AnsiConsole.cs`
- [Console contract](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/IAnsiConsole.cs): `src/Spectre.Console/IAnsiConsole.cs`
- [Console profile](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Profile.cs): `src/Spectre.Console/Profile.cs`
- [Capabilities](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Capabilities.cs): `src/Spectre.Console/Capabilities.cs`
- [Console backends](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Internal/Backends/Ansi/AnsiConsoleBackend.cs): `src/Spectre.Console/Internal/Backends/Ansi/AnsiConsoleBackend.cs`
- [Test console](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Testing/TestConsole.cs): `src/Spectre.Console.Testing/TestConsole.cs`

### Rendering and widgets

- [Render pipeline](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/RenderPipeline.cs): `src/Spectre.Console/Rendering/RenderPipeline.cs`
- [Renderable contract](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/IRenderable.cs): `src/Spectre.Console/Rendering/IRenderable.cs`
- [Rendered segments](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Rendering/Segment.cs): `src/Spectre.Console/Rendering/Segment.cs`
- [Text and paragraphs](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Paragraph.cs): `src/Spectre.Console/Widgets/Paragraph.cs`
- [Markup](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Markup.cs): `src/Spectre.Console/Widgets/Markup.cs`
- [Structured widgets](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Widgets/Table/TableRendererContext.cs): `src/Spectre.Console/Widgets/Table/TableRendererContext.cs`

### Terminal styling

- [ANSI writer](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Ansi/AnsiWriter.cs): `src/Spectre.Console.Ansi/AnsiWriter.cs`
- [Styles and colors](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console.Ansi/Style.cs): `src/Spectre.Console.Ansi/Style.cs`

### Interactive displays

- [Prompts](https://github.com/spectreconsole/spectre.console/tree/main/src/Spectre.Console/Prompts): `src/Spectre.Console/Prompts`
- [Live displays](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Live/LiveDisplay.cs): `src/Spectre.Console/Live/LiveDisplay.cs`
- [Progress reporting](https://github.com/spectreconsole/spectre.console/blob/main/src/Spectre.Console/Live/Progress/Progress.cs): `src/Spectre.Console/Live/Progress/Progress.cs`

### Extensions

- [JSON rendering](https://github.com/spectreconsole/spectre.console/blob/main/src/Extensions/Spectre.Console.Json/JsonParser.cs): `src/Extensions/Spectre.Console.Json/JsonParser.cs`
- [Canvas images](https://github.com/spectreconsole/spectre.console/blob/main/src/Extensions/Spectre.Console.ImageSharp/CanvasImage.cs): `src/Extensions/Spectre.Console.ImageSharp/CanvasImage.cs`

### Other components

- **Application**
- **Terminal**

## Connections

- Application → Console API: writes through (evidence: `README.md`)
- Console API → Renderable contract: accepts renderables
- Renderable contract → Render pipeline: processes through (evidence: `src/Spectre.Console/Rendering/IRenderable.cs`)
- Renderable contract → Rendered segments: renders as (evidence: `src/Spectre.Console/Rendering/IRenderable.cs`)
- Text and paragraphs → Rendered segments: produces (evidence: `src/Spectre.Console/Widgets/Paragraph.cs`)
- Console API → Console profile: uses profile
- Console profile → Capabilities: holds capabilities (evidence: `src/Spectre.Console/Profile.cs`)
- Console API → Console backends: dispatches to
- Console backends → ANSI writer: emits terminal codes
- ANSI writer → Styles and colors: encodes styling (evidence: `src/Spectre.Console.Ansi/AnsiWriter.cs`)
- Markup → Styles and colors: parses styles (evidence: `src/Spectre.Console/Widgets/Markup.cs`)
- Console API → Prompts: offers prompts
- Console API → Live displays: offers live output
- Live displays → Progress reporting: includes progress
- Application → Structured widgets: uses widgets (evidence: `README.md`)
- Application → Markup: styles text with (evidence: `README.md`)
- JSON rendering → Renderable contract: renders as
- Canvas images → Renderable contract: implements rendering (evidence: `src/Extensions/Spectre.Console.ImageSharp/CanvasImage.cs`)
- Test console → Console API: creates console (evidence: `src/Spectre.Console.Testing/TestConsole.cs`)
- Test console → Terminal: captures output (evidence: `src/Spectre.Console.Testing/TestConsole.cs`)
- ANSI writer → Terminal: writes sequences
