# nguyenchiemminhvu/castle architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenchiemminhvu/castle
- Repository: https://github.com/nguyenchiemminhvu/castle

## Overview

CASTLE is a header-only C++17 library for bounded, predictable embedded software. An application includes the headers for the job it needs, then uses fixed-capacity primitives and domain APIs that report ordinary failures through statuses rather than requiring exceptions. Its capabilities span core language support, containers, events and synchronization, mathematical utilities, and embedded protocols and integrations. The graph groups these capabilities rather than depicting an application-specific runtime pipeline; arrows are limited to relationships visible in the README or sampled source index. Some unsampled subsystems are represented at their exact source directories.

Main entry points: [`include/castle/events/event_handler.hpp`](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/events/event_handler.hpp) (Async event scheduler), [`include/castle/error/status.hpp`](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/error/status.hpp) (Status values), [`include/castle/container/array.hpp`](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/container/array.hpp) (Fixed-capacity containers), [`include/castle/callbacks/function.hpp`](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/callbacks/function.hpp) (Callable wrappers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundation["Core foundation"]
  node_compiler["Compiler abstraction<br/>[compiler.hpp]"]
  node_configuration["Configuration and types<br/>[config.hpp]"]
  node_traits["Type traits<br/>[traits.hpp]"]
  node_errors["Error handling<br/>[error_handler.hpp]"]
  node_status["Status values<br/>[status.hpp]"]
end

subgraph group_primitives["Core primitives"]
  node_containers["Fixed-capacity containers<br/>[array.hpp]"]
  node_array_view["Non-owning views<br/>[array_view.hpp]"]
  node_callables["Callable wrappers<br/>[function.hpp]"]
  node_memory["Memory and lifetime<br/>[storage.hpp]"]
  node_utility["Utility types"]
  node_algorithms["Algorithms and iterators"]
end

subgraph group_coordination["Events and coordination"]
  node_time["Clocks and durations"]
  node_event_handler["Async event scheduler<br/>[event_handler.hpp]"]
  node_event_system["Events and signals"]
  node_sync["Synchronization"]
end

subgraph group_math["Math and geometry"]
  node_math_util["Math utilities"]
  node_geometry["Geometry and linear algebra"]
end

subgraph group_embedded["Embedded extensions"]
  node_diagnostics["Diagnostics"]
  node_filters["Signal filtering"]
  node_geodetic["Geodetic and geofence"]
  node_parsers["NMEA and UBX parsers"]
  node_nmea["NMEA protocol<br/>[nmea.hpp]"]
  node_protocols["Device protocols"]
  node_serialization["Serialization formats"]
  node_codecs_crypto["Codecs and cryptography"]
  node_io["Hardware and file I/O"]
end

node_application(("Firmware application"))

node_application -->|"uses"| node_containers
node_application -->|"uses"| node_callables
node_application -->|"uses"| node_errors
node_application -->|"uses"| node_status
node_parsers -->|"parses with"| node_nmea
node_geodetic -->|"uses"| node_geometry
node_event_handler -->|"stores callbacks"| node_callables
node_event_handler -->|"schedules by time"| node_time
node_event_handler -->|"reports status"| node_status
node_event_handler -->|"queues tasks"| node_containers

click node_compiler "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/compiler.hpp"
click node_configuration "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/config.hpp"
click node_traits "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/traits.hpp"
click node_errors "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/error_handler.hpp"
click node_status "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/error/status.hpp"
click node_containers "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/container/array.hpp"
click node_array_view "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/container/array_view.hpp"
click node_callables "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/callbacks/function.hpp"
click node_memory "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/memory/storage.hpp"
click node_utility "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/utility"
click node_algorithms "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/algorithm"
click node_time "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/chrono"
click node_event_handler "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/events/event_handler.hpp"
click node_event_system "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/events"
click node_sync "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/sync"
click node_math_util "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/math"
click node_geometry "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/math/geometry"
click node_diagnostics "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle_ext/diag/diagnostic_manager.hpp"
click node_filters "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/filter"
click node_geodetic "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/geodetic"
click node_parsers "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/parsers"
click node_nmea "https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle_ext/protocols/nmea/nmea.hpp"
click node_protocols "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/protocols"
click node_serialization "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/serialization"
click node_codecs_crypto "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/codecs"
click node_io "https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/io"

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_compiler,node_configuration,node_traits,node_errors,node_status toneBlue
class node_containers,node_array_view,node_callables,node_memory,node_utility,node_algorithms toneAmber
class node_time,node_event_handler,node_event_system,node_sync toneMint
class node_math_util,node_geometry toneRose
class node_diagnostics,node_filters,node_geodetic,node_parsers,node_nmea,node_protocols,node_serialization,node_codecs_crypto,node_io,node_application toneIndigo
```

## Components

### Core foundation

- [Compiler abstraction](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/compiler.hpp): `include/castle/core/compiler.hpp`
- [Configuration and types](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/config.hpp): `include/castle/core/config.hpp`
- [Type traits](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/traits.hpp): `include/castle/core/traits.hpp`
- [Error handling](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/core/error_handler.hpp): `include/castle/core/error_handler.hpp`
- [Status values](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/error/status.hpp): `include/castle/error/status.hpp`

### Core primitives

- [Fixed-capacity containers](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/container/array.hpp): `include/castle/container/array.hpp`
- [Non-owning views](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/container/array_view.hpp): `include/castle/container/array_view.hpp`
- [Callable wrappers](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/callbacks/function.hpp): `include/castle/callbacks/function.hpp`
- [Memory and lifetime](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/memory/storage.hpp): `include/castle/memory/storage.hpp`
- [Utility types](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/utility): `include/castle/utility`
- [Algorithms and iterators](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/algorithm): `include/castle/algorithm`

### Events and coordination

- [Clocks and durations](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/chrono): `include/castle/chrono`
- [Async event scheduler](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle/events/event_handler.hpp): `include/castle/events/event_handler.hpp`
- [Events and signals](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/events): `include/castle/events`
- [Synchronization](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/sync): `include/castle/sync`

### Math and geometry

- [Math utilities](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/math): `include/castle/math`
- [Geometry and linear algebra](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle/math/geometry): `include/castle/math/geometry`

### Embedded extensions

- [Diagnostics](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle_ext/diag/diagnostic_manager.hpp): `include/castle_ext/diag/diagnostic_manager.hpp`
- [Signal filtering](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/filter): `include/castle_ext/filter`
- [Geodetic and geofence](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/geodetic): `include/castle_ext/geodetic`
- [NMEA and UBX parsers](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/parsers): `include/castle_ext/parsers`
- [NMEA protocol](https://github.com/nguyenchiemminhvu/castle/blob/main/include/castle_ext/protocols/nmea/nmea.hpp): `include/castle_ext/protocols/nmea/nmea.hpp`
- [Device protocols](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/protocols): `include/castle_ext/protocols`
- [Serialization formats](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/serialization): `include/castle_ext/serialization`
- [Codecs and cryptography](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/codecs): `include/castle_ext/codecs`
- [Hardware and file I/O](https://github.com/nguyenchiemminhvu/castle/tree/main/include/castle_ext/io): `include/castle_ext/io`

### Other components

- **Firmware application**

## Connections

- Firmware application → Fixed-capacity containers: uses
- Firmware application → Callable wrappers: uses
- Firmware application → Error handling: uses
- Firmware application → Status values: uses
- NMEA and UBX parsers → NMEA protocol: parses with (evidence: `include/castle_ext/parsers/nmea_parser/nmea_parser.hpp`)
- Geodetic and geofence → Geometry and linear algebra: uses (evidence: `include/castle_ext/geodetic/geofence.hpp`)
- Async event scheduler → Callable wrappers: stores callbacks (evidence: `include/castle/events/event_handler.hpp`)
- Async event scheduler → Clocks and durations: schedules by time (evidence: `include/castle/events/event_handler.hpp`)
- Async event scheduler → Status values: reports status (evidence: `include/castle/events/event_handler.hpp`)
- Async event scheduler → Fixed-capacity containers: queues tasks (evidence: `include/castle/events/event_handler.hpp`)
