# vztpv/scj3 architecture

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

- Interactive diagram: https://gitdiagram.com/vztpv/scj3
- Repository: https://github.com/vztpv/scj3

## Overview

##### Project Type and Core Components
- Scanning (SIMD-based)
- Parsing (Multi-threaded)
- Saving (Multi-threaded)

##### Main Components

A. Core Components:

- Scanner     |     |    Parser     |     |    Writer     |
- (SIMD-based)   |---->| (Multi-thread)|---->| (Multi-thread)|

B. Dependencies Layer:

- simdjson  |    | mimalloc |    | ThreadPool |    |   fmt   |
- (SIMD ops) |    |  (Memory)|    |(Task Mgmt) |    |(Format) |

##### Key Elements to Emphasize

- Blue: Core processing components (Scanner, Parser, Writer)
- Green: External dependencies
- Yellow: Data flow paths
- Gray: Support components

##### Component Relationships

Following interactions:
**Input JSON ─→ Scanner ─→ Parser ─→ Document Object ─→ Writer ─→ Output JSON**

##### Threading Model

- Thread Pool     |

- Worker 1  |   |

- Worker 2  |   |

- ...    |   |

##### Detailed Component Breakdown

Specific elements:
**Document**
- Value
- Structured Types
- Array
- Object
- Primitive Types
- Number
- String
- Boolean

##### Implementation Notes

Annotations indicating:
- C++14+ requirement
- 64-bit architecture requirement
- SIMD optimization points
- Thread pool usage points
- Memory management strategy (mimalloc)

##### Data Flow Markers

- → Synchronous operations
- ⇢ Asynchronous operations
- ⇄ Bidirectional communication

Remember to include these specific technical details:
- SIMD scanning operations
- Thread pool management for parsing
- Parallel writing capabilities
- Memory management system
- Document object structure
- Error handling paths

This architecture should emphasize the high-performance aspects of the system while maintaining clarity about the data flow and processing stages.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Component]:::component --- L2[Dependency]:::dependency
        L3[Process Flow]:::flow --- L4[Threading]:::threading
        L5[Document Structure]:::document
    end

    subgraph "Core Processing Pipeline"
        Input[Input JSON]:::flow --> Scanner
        Scanner[SIMD Scanner]:::component --> Parser
        Parser[Multi-threaded Parser]:::component --> DocObj[Document Object]:::document
        DocObj --> Writer[Multi-threaded Writer]:::component
        Writer --> Output[Output JSON]:::flow
    end

    subgraph "Threading System"
        ThreadPool[Thread Pool Manager]:::threading
        Worker1[Worker Thread 1]:::threading
        Worker2[Worker Thread 2]:::threading
        WorkerN[Worker Thread N]:::threading
        ThreadPool --> Worker1
        ThreadPool --> Worker2
        ThreadPool --> WorkerN
    end

    subgraph "Document Structure"
        Value[Value]:::document
        StructTypes[Structured Types]:::document
        PrimTypes[Primitive Types]:::document
        Array[Array]:::document
        Object[Object]:::document
        Number[Number]:::document
        String[String]:::document
        Boolean[Boolean]:::document

        Value --> StructTypes
        Value --> PrimTypes
        StructTypes --> Array
        StructTypes --> Object
        PrimTypes --> Number
        PrimTypes --> String
        PrimTypes --> Boolean
    end

    subgraph "Dependencies"
        SimdJson[SIMDJSON]:::dependency
        Mimalloc[Mimalloc]:::dependency
        Fmt[FMT Library]:::dependency
    end

    %% Component Relationships
    SimdJson --> Scanner
    Mimalloc --> Parser
    ThreadPool --> Parser
    ThreadPool --> Writer
    Fmt --> Writer

    %% Technical Requirements
    Requirements[Requirements:<br/>- C++14+<br/>- 64-bit Architecture<br/>- SIMD Support]:::note

    %% Click Events
    click Scanner "https://github.com/vztpv/scj3/blob/main//_simdjson.h"
    click ThreadPool "https://github.com/vztpv/scj3/blob/main//ThreadPool.h"
    click Parser "https://github.com/vztpv/scj3/blob/main//claujson.h"
    click Requirements "https://github.com/vztpv/scj3/blob/main//README.md"
    click Input "https://github.com/vztpv/scj3/blob/main//main.cpp"
    click Requirements "https://github.com/vztpv/scj3/blob/main//CMakeLists.txt"
    click Requirements "https://github.com/vztpv/scj3/blob/main//.github/workflows/cmake.yml"
    click Requirements "https://github.com/vztpv/scj3/blob/main//claujson.pdf"

    classDef component fill:#3498db,stroke:#2980b9,color:white
    classDef dependency fill:#2ecc71,stroke:#27ae60,color:white
    classDef flow fill:#f1c40f,stroke:#f39c12,color:black
    classDef threading fill:#e74c3c,stroke:#c0392b,color:white
    classDef document fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef note fill:#ecf0f1,stroke:#bdc3c7,color:black
```
