# injae/serdepp architecture

> Architecture diagram of the GitHub repository injae/serdepp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/injae/serdepp
- Repository: https://github.com/injae/serdepp

## Overview

##### Main Components Identification

The system should be divided into these primary components:

a) Core Serialization Engine
- Located in include/serdepp/serde.hpp
- Includes the main serialization/deserialization logic
- Contains meta-programming utilities

b) Attribute System
- Located in include/serdepp/attribute/
- Handles various serialization attributes
- Supports custom attribute creation

c) Adaptor Layer
- Located in include/serdepp/adaptor/
- Supports multiple format adaptors (JSON, YAML, TOML, etc.)
- Provides format-specific implementations

##### Component Relationships

**[Client Code]**
- ↓
**[Serde Core Engine] ←→ [Attribute System]**
- ↓
**[Adaptor Layer]**
- ↓
**[Format Libraries]**

##### Detailed Component Breakdown

a) Core Engine (Center):
- Serializer interface
- Deserializer interface
- Type reflection system
- Meta-programming utilities

b) Attribute System (Right Side):
- Default attributes
- Value/Struct handlers
- Custom attribute support
- Container attributes

c) Adaptor Layer (Bottom):
- JSON adaptors (nlohmann, rapidjson)
- YAML adaptor (yaml-cpp)
- TOML adaptor (toml11)
- FMT adaptor
- Stream adaptor

##### Data Flow Representation

- Blue: Serialization flow (Object → Format)
- Green: Deserialization flow (Format → Object)
- Gray: Internal communication

**[Format Support]**
- RapidJSON
- nlohmann::json
- YAML-cpp
- toml11
- fmt

**[Core Features]**
- Struct/Class Support
- Nested Types
- Enum Support
- Container Support
- Variant Support
- Pointer Support

##### Implementation Details

Relationship between:
- Serialization contexts
- Type traits
- Attribute processors
- Format adaptors

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        ClientCode[Client Code]
    end

    subgraph Core["Core Engine"]
        SerdeCore["Serialization Engine"]:::core
        Serializer["Serializer Interface"]:::core
        Deserializer["Deserializer Interface"]:::core
        MetaUtils["Meta-programming Utilities"]:::core
        TypeReflection["Type Reflection System"]:::core
        ErrorHandling["Error Handling"]:::core
    end

    subgraph AttributeSystem["Attribute System"]
        AttrProcessor["Attribute Processor"]:::attr
        DefaultAttrs["Default Attributes"]:::attr
        CustomAttrs["Custom Attributes"]:::attr
        ContainerAttrs["Container Attributes"]:::attr
        ValueHandlers["Value/Struct Handlers"]:::attr
    end

    subgraph AdaptorLayer["Adaptor Layer"]
        direction TB
        AdaptorInterface["Adaptor Interface"]:::adaptor
        subgraph Formats
            direction TB
            JsonAdaptor["JSON Adaptors"]:::format
            YamlAdaptor["YAML Adaptor"]:::format
            TomlAdaptor["TOML Adaptor"]:::format
            FmtAdaptor["FMT Adaptor"]:::format
            StreamAdaptor["Stream Adaptor"]:::format
        end
    end

    subgraph Features["Core Features"]
        StructSupport["Struct/Class Support"]:::feature
        NestedTypes["Nested Types"]:::feature
        EnumSupport["Enum Support"]:::feature
        ContainerSupport["Container Support"]:::feature
        VariantSupport["Variant Support"]:::feature
        PointerSupport["Pointer Support"]:::feature
    end

    %% Relationships
    ClientCode --> SerdeCore
    SerdeCore --> Serializer & Deserializer
    SerdeCore <--> AttrProcessor
    SerdeCore --> MetaUtils
    SerdeCore --> TypeReflection
    SerdeCore --> ErrorHandling
    
    AttrProcessor --> DefaultAttrs & CustomAttrs & ContainerAttrs & ValueHandlers
    
    Serializer & Deserializer --> AdaptorInterface
    AdaptorInterface --> JsonAdaptor & YamlAdaptor & TomlAdaptor & FmtAdaptor & StreamAdaptor
    
    SerdeCore --> Features

    %% Click Events
    click SerdeCore "https://github.com/injae/serdepp/blob/main/include/serdepp/serde.hpp"
    click Serializer "https://github.com/injae/serdepp/blob/main/include/serdepp/serializer.hpp"
    click MetaUtils "https://github.com/injae/serdepp/blob/main/include/serdepp/meta.hpp"
    click ErrorHandling "https://github.com/injae/serdepp/blob/main/include/serdepp/exception.hpp"
    click TypeReflection "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/reflection.hpp"
    click AttrProcessor "https://github.com/injae/serdepp/tree/main/include/serdepp/attribute/"
    click DefaultAttrs "https://github.com/injae/serdepp/blob/main/include/serdepp/attribute/default.hpp"
    click AdaptorInterface "https://github.com/injae/serdepp/tree/main/include/serdepp/adaptor/"
    click JsonAdaptor "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/nlohmann_json.hpp"
    click YamlAdaptor "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/yaml-cpp.hpp"
    click TomlAdaptor "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/toml11.hpp"
    click FmtAdaptor "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/fmt.hpp"
    click StreamAdaptor "https://github.com/injae/serdepp/blob/main/include/serdepp/adaptor/sstream.hpp"

    %% Styles
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef attr fill:#f3e5f5,stroke:#4a148c
    classDef adaptor fill:#e8f5e9,stroke:#1b5e20
    classDef format fill:#fff3e0,stroke:#e65100
    classDef feature fill:#fce4ec,stroke:#880e4f

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        AttrLegend["Attribute Components"]:::attr
        AdaptorLegend["Adaptor Components"]:::adaptor
        FormatLegend["Format Components"]:::format
        FeatureLegend["Feature Components"]:::feature
    end
```
