# pebal/sgcl architecture

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

- Interactive diagram: https://gitdiagram.com/pebal/sgcl
- Repository: https://github.com/pebal/sgcl

## Overview

SGCL is a header-only C++20 application platform rather than a single end-user application. Its central use is for a C++ program to include a module, build on managed objects and core types, and use higher-level facilities such as tasks, I/O, networking, and data processing. The graph highlights that foundation and several documented or tree-visible capability areas. Source excerpts are limited, so connections are included only where the README or source index supports them; many modules’ internal wiring is not shown.

Main entry points: [`sgcl/async/coroutine.h`](https://github.com/pebal/sgcl/blob/main/sgcl/async/coroutine.h) (Tasks and coroutines), [`sgcl/core/tracked_ptr.h`](https://github.com/pebal/sgcl/blob/main/sgcl/core/tracked_ptr.h) (Managed objects), [`sgcl/net/http/server.h`](https://github.com/pebal/sgcl/blob/main/sgcl/net/http/server.h) (HTTP server), [`sgcl/async/scheduler.h`](https://github.com/pebal/sgcl/blob/main/sgcl/async/scheduler.h) (Worker scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Memory and core"]
  node_managed_objects["Managed objects<br/>[tracked_ptr.h]"]
  node_allocation["Managed allocation<br/>[make_tracked.h]"]
  node_core_containers["Core containers<br/>[vector.h]"]
  node_core_strings["Strings<br/>[string.h]"]
  node_core_duration["Duration types<br/>[duration.h]"]
  node_core_function["Callable values<br/>[function.h]"]
end

subgraph group_async["Async runtime"]
  node_async_tasks["Tasks and coroutines<br/>[coroutine.h]"]
  node_async_scheduler["Worker scheduler<br/>[scheduler.h]"]
  node_async_channels["Channels and select<br/>[channel.h]"]
  node_async_cancellation["Cancellation and timers<br/>[stop_token.h]"]
  node_async_blocking["Blocking bridges<br/>[blocking.h]"]
end

subgraph group_io_network["I/O and networking"]
  node_io_streams["I/O streams<br/>[stream.h]"]
  node_socket_io["Sockets<br/>[socket.h]"]
  node_connections["Connections<br/>[connection.h]"]
  node_tls["TLS<br/>[tls.h]"]
  node_http_server["HTTP server<br/>[server.h]"]
end

subgraph group_formats["Data formats"]
  node_encoding["Structured encoding<br/>[json.h]"]
  node_image_codecs["Image codecs<br/>[decode.h]"]
  node_compression["Compression and archives<br/>[compress.h]"]
end

subgraph group_other_modules["Platform modules"]
  node_crypto["Cryptography<br/>[crypto.h]"]
  node_concurrent_collections["Concurrent collections<br/>[concurrent.h]"]
  node_time_localization["Time and localization<br/>[time.h]"]
  node_text_processing["Text processing<br/>[format.h]"]
end

node_developer(("C++ program"))

node_developer -->|"uses pointers"| node_managed_objects
node_developer -->|"starts tasks"| node_async_tasks
node_developer -.->|"uses streams"| node_io_streams
node_developer -.->|"uses networking"| node_socket_io
node_managed_objects -->|"owns allocation"| node_allocation
node_managed_objects -->|"backs storage"| node_core_containers
node_managed_objects -->|"backs strings"| node_core_strings
node_async_tasks -->|"enqueues tasks"| node_async_scheduler
node_async_scheduler -->|"runs coroutines"| node_async_tasks
node_async_tasks -.->|"coordinates through"| node_async_channels
node_async_tasks -.->|"supports cancellation"| node_async_cancellation
node_socket_io -->|"uses connections"| node_connections
node_http_server -->|"serves over"| node_connections
node_http_server -->|"accepts sockets"| node_socket_io
node_http_server -->|"supports TLS"| node_tls
node_async_scheduler -->|"uses task queue"| node_concurrent_collections
node_async_tasks -.->|"uses time values"| node_core_duration

click node_managed_objects "https://github.com/pebal/sgcl/blob/main/sgcl/core/tracked_ptr.h"
click node_allocation "https://github.com/pebal/sgcl/blob/main/sgcl/core/make_tracked.h"
click node_core_containers "https://github.com/pebal/sgcl/blob/main/sgcl/core/vector.h"
click node_core_strings "https://github.com/pebal/sgcl/blob/main/sgcl/core/string.h"
click node_core_duration "https://github.com/pebal/sgcl/blob/main/sgcl/core/duration.h"
click node_core_function "https://github.com/pebal/sgcl/blob/main/sgcl/core/function.h"
click node_async_tasks "https://github.com/pebal/sgcl/blob/main/sgcl/async/coroutine.h"
click node_async_scheduler "https://github.com/pebal/sgcl/blob/main/sgcl/async/scheduler.h"
click node_async_channels "https://github.com/pebal/sgcl/blob/main/sgcl/async/channel.h"
click node_async_cancellation "https://github.com/pebal/sgcl/blob/main/sgcl/async/stop_token.h"
click node_async_blocking "https://github.com/pebal/sgcl/blob/main/sgcl/async/blocking.h"
click node_io_streams "https://github.com/pebal/sgcl/blob/main/sgcl/io/stream.h"
click node_socket_io "https://github.com/pebal/sgcl/blob/main/sgcl/net/socket.h"
click node_connections "https://github.com/pebal/sgcl/blob/main/sgcl/net/connection.h"
click node_tls "https://github.com/pebal/sgcl/blob/main/sgcl/net/tls.h"
click node_http_server "https://github.com/pebal/sgcl/blob/main/sgcl/net/http/server.h"
click node_encoding "https://github.com/pebal/sgcl/blob/main/sgcl/encoding/json.h"
click node_image_codecs "https://github.com/pebal/sgcl/blob/main/sgcl/codec/decode.h"
click node_compression "https://github.com/pebal/sgcl/blob/main/sgcl/compress/compress.h"
click node_crypto "https://github.com/pebal/sgcl/blob/main/sgcl/crypto/crypto.h"
click node_concurrent_collections "https://github.com/pebal/sgcl/blob/main/sgcl/concurrent/concurrent.h"
click node_time_localization "https://github.com/pebal/sgcl/blob/main/sgcl/time/time.h"
click node_text_processing "https://github.com/pebal/sgcl/blob/main/sgcl/txt/format.h"

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_managed_objects,node_allocation,node_core_containers,node_core_strings,node_core_duration,node_core_function toneBlue
class node_async_tasks,node_async_scheduler,node_async_channels,node_async_cancellation,node_async_blocking toneAmber
class node_io_streams,node_socket_io,node_connections,node_tls,node_http_server toneMint
class node_encoding,node_image_codecs,node_compression toneRose
class node_crypto,node_concurrent_collections,node_time_localization,node_text_processing,node_developer toneIndigo
```

## Components

### Memory and core

- [Managed objects](https://github.com/pebal/sgcl/blob/main/sgcl/core/tracked_ptr.h): `sgcl/core/tracked_ptr.h`
- [Managed allocation](https://github.com/pebal/sgcl/blob/main/sgcl/core/make_tracked.h): `sgcl/core/make_tracked.h`
- [Core containers](https://github.com/pebal/sgcl/blob/main/sgcl/core/vector.h): `sgcl/core/vector.h`
- [Strings](https://github.com/pebal/sgcl/blob/main/sgcl/core/string.h): `sgcl/core/string.h`
- [Duration types](https://github.com/pebal/sgcl/blob/main/sgcl/core/duration.h): `sgcl/core/duration.h`
- [Callable values](https://github.com/pebal/sgcl/blob/main/sgcl/core/function.h): `sgcl/core/function.h`

### Async runtime

- [Tasks and coroutines](https://github.com/pebal/sgcl/blob/main/sgcl/async/coroutine.h): `sgcl/async/coroutine.h`
- [Worker scheduler](https://github.com/pebal/sgcl/blob/main/sgcl/async/scheduler.h): `sgcl/async/scheduler.h`
- [Channels and select](https://github.com/pebal/sgcl/blob/main/sgcl/async/channel.h): `sgcl/async/channel.h`
- [Cancellation and timers](https://github.com/pebal/sgcl/blob/main/sgcl/async/stop_token.h): `sgcl/async/stop_token.h`
- [Blocking bridges](https://github.com/pebal/sgcl/blob/main/sgcl/async/blocking.h): `sgcl/async/blocking.h`

### I/O and networking

- [I/O streams](https://github.com/pebal/sgcl/blob/main/sgcl/io/stream.h): `sgcl/io/stream.h`
- [Sockets](https://github.com/pebal/sgcl/blob/main/sgcl/net/socket.h): `sgcl/net/socket.h`
- [Connections](https://github.com/pebal/sgcl/blob/main/sgcl/net/connection.h): `sgcl/net/connection.h`
- [TLS](https://github.com/pebal/sgcl/blob/main/sgcl/net/tls.h): `sgcl/net/tls.h`
- [HTTP server](https://github.com/pebal/sgcl/blob/main/sgcl/net/http/server.h): `sgcl/net/http/server.h`

### Data formats

- [Structured encoding](https://github.com/pebal/sgcl/blob/main/sgcl/encoding/json.h): `sgcl/encoding/json.h`
- [Image codecs](https://github.com/pebal/sgcl/blob/main/sgcl/codec/decode.h): `sgcl/codec/decode.h`
- [Compression and archives](https://github.com/pebal/sgcl/blob/main/sgcl/compress/compress.h): `sgcl/compress/compress.h`

### Platform modules

- [Cryptography](https://github.com/pebal/sgcl/blob/main/sgcl/crypto/crypto.h): `sgcl/crypto/crypto.h`
- [Concurrent collections](https://github.com/pebal/sgcl/blob/main/sgcl/concurrent/concurrent.h): `sgcl/concurrent/concurrent.h`
- [Time and localization](https://github.com/pebal/sgcl/blob/main/sgcl/time/time.h): `sgcl/time/time.h`
- [Text processing](https://github.com/pebal/sgcl/blob/main/sgcl/txt/format.h): `sgcl/txt/format.h`

### Other components

- **C++ program**

## Connections

- C++ program → Managed objects: uses pointers
- C++ program → Tasks and coroutines: starts tasks
- C++ program → I/O streams: uses streams
- C++ program → Sockets: uses networking
- Managed objects → Managed allocation: owns allocation (evidence: `sgcl/core/make_tracked.h`)
- Managed objects → Core containers: backs storage (evidence: `sgcl/core/vector.h`)
- Managed objects → Strings: backs strings (evidence: `sgcl/core/string.h`)
- Tasks and coroutines → Worker scheduler: enqueues tasks (evidence: `sgcl/async/coroutine.h`)
- Worker scheduler → Tasks and coroutines: runs coroutines (evidence: `sgcl/async/scheduler.h`)
- Tasks and coroutines → Channels and select: coordinates through
- Tasks and coroutines → Cancellation and timers: supports cancellation
- Sockets → Connections: uses connections (evidence: `sgcl/net/socket.h`)
- HTTP server → Connections: serves over (evidence: `sgcl/net/http/server.h`)
- HTTP server → Sockets: accepts sockets (evidence: `sgcl/net/http/server.h`)
- HTTP server → TLS: supports TLS (evidence: `sgcl/net/http/server.h`)
- Worker scheduler → Concurrent collections: uses task queue (evidence: `sgcl/async/scheduler.h`)
- Tasks and coroutines → Duration types: uses time values
