# freertos/corejson architecture

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

- Interactive diagram: https://gitdiagram.com/freertos/corejson
- Repository: https://github.com/freertos/corejson

## Overview

##### Project type and purpose
- This is a standalone C library (“coreJSON”) for parsing and querying JSON on low-memory embedded devices.
- It strictly enforces ECMA-404, is MISRA-checked, has CBMC proofs for memory safety, unit tests with Unity, fuzzing integration (ClusterFuzzLite), and documentation via Doxygen.

##### File structure
- Top-level “source/” holds the core implementation (core_json.c) and public headers in source/include.
- “test/unit-test/” contains CMake scripts and Unity tests.
- “test/cbmc/proofs/” contains CBMC harnesses and proofs for formal verification.
- “.clusterfuzzlite/” holds Dockerfile, build scripts, fuzzer configs for automated fuzz testing.
- “docs/doxygen/” holds configuration and styling for HTML API docs.
- “tools/coverity/” and “tools/unity/” hold static-analysis and test-framework configs.
- GitHub workflows in “.github/workflows/” orchestrate CI, fuzzing, docs generation, and releases.

##### Key insights from the README
- The library’s API (JSON_Validate, JSON_Search, etc.) is the core functionality.
- Build uses C90/C99-compatible compilers, optional replacement headers for stdbool/stdint.
- Documentation generation via Doxygen.
- Unit tests require CMake, Ruby (for Unity), and CBMC proofs require the CBMC toolchain.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source Code"
        CoreC["core_json.c"]:::source
        CoreHeader["core_json.h"]:::source
        BoolReadme["stdbool.readme"]:::source
        IntReadme["stdint.readme"]:::source
    end
    subgraph "Build & Packaging"
        CMake["CMake Scripts"]:::tool
        Paths["jsonFilePaths.cmake"]:::tool
        LIB["Library Artifact<br/>(.a/.so)"]:::tool
    end
    subgraph "Unit Test Framework"
        UTest["core_json_utest.c"]:::test
        UnityDir["Unity Framework"]:::tool
        UnityBuild["unity_build.cmake"]:::tool
        CatchAssert["catch_assert.h"]:::tool
        UnitExe["Unit Test Executable"]:::tool
        TestRunner["Test Runner"]:::tool
    end
    subgraph "Formal Verification"
        CBMCValidate["JSON_Validate_harness.c"]:::test
        CBMCSearch["JSON_SearchConst_harness.c"]:::test
        CBMCIte["JSON_Iterate_harness.c"]:::test
        CBMCMk["CBMC Makefiles"]:::tool
        Contracts["contracts & annex headers"]:::test
        ProofResults["Proof Results"]:::tool
    end
    subgraph "Fuzz Testing"
        Dockerfile["Dockerfile"]:::tool
        BuildSh["build.sh"]:::tool
        YAML["project.yaml"]:::tool
        Fuzzer["validate_fuzzer.c"]:::test
        FuzzResults["Fuzzing Results"]:::tool
    end
    subgraph "Documentation"
        DoxyConf["config.doxyfile"]:::test
        Style["style.css"]:::test
        Layout["layout.xml"]:::test
        Pages["pages.dox"]:::test
        SizeTable["size_table.md"]:::test
        HTMLDocs["HTML API Documentation"]:::tool
    end
    subgraph "Static Analysis Tools"
        Coverity["misra.config"]:::tool
        MemStat["memory_statistics_config.json"]:::tool
    end
    subgraph "Tooling"
        UnityCreate["create_test.cmake"]:::tool
        UnityCov["coverage.cmake"]:::tool
    end
    subgraph "CI/CD Pipelines"
        CI["ci.yml"]:::ci
        CFLite["cflite_pr.yml"]:::ci
        Dox["doxygen.yml"]:::ci
        Release["release.yml"]:::ci
    end
    subgraph "CI Triggers"
        PR["On PR"]:::ci
        Push["On Push/Tag"]:::ci
    end

    CoreC --> CMake
    CoreHeader --> CMake
    BoolReadme --> CMake
    IntReadme --> CMake
    CMake --> Paths
    Paths --> LIB

    CoreC --> UTest
    CoreHeader --> UTest
    BoolReadme --> UTest
    IntReadme --> UTest
    UTest --> UnityBuild
    UnityBuild --> UnitExe
    UnitExe --> TestRunner

    CoreC --> CBMCValidate
    CoreC --> CBMCSearch
    CoreC --> CBMCIte
    CoreHeader --> CBMCValidate
    Contracts --> CBMCValidate
    Contracts --> CBMCSearch
    Contracts --> CBMCIte
    CBMCValidate --> CBMCMk
    CBMCSearch --> CBMCMk
    CBMCIte --> CBMCMk
    CBMCMk --> ProofResults

    CoreC --> Fuzzer
    Dockerfile --> Fuzzer
    BuildSh --> Fuzzer
    YAML --> Fuzzer
    Fuzzer --> FuzzResults

    CoreC --> DoxyConf
    CoreHeader --> DoxyConf
    DoxyConf --> HTMLDocs
    Style --> HTMLDocs
    Layout --> HTMLDocs
    Pages --> HTMLDocs
    SizeTable --> HTMLDocs

    CoreC --> Coverity
    CoreHeader --> Coverity
    Coverity --> MemStat

    UnityCreate --> UTest
    UnityCov --> UTest

    PR --> CI
    PR --> CFLite
    PR --> Dox
    Push --> CI
    Push --> Release
    Push --> Dox

    classDef source fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef test fill:#C8E6C9,stroke:#2E7D32,color:#2E7D32
    classDef tool fill:#E0E0E0,stroke:#424242,color:#424242
    classDef ci fill:#FFE0B2,stroke:#E65100,color:#E65100

    click CoreC "https://github.com/freertos/corejson/blob/main/source/core_json.c"
    click CoreHeader "https://github.com/freertos/corejson/blob/main/source/include/core_json.h"
    click BoolReadme "https://github.com/freertos/corejson/blob/main/source/include/stdbool.readme"
    click IntReadme "https://github.com/freertos/corejson/blob/main/source/include/stdint.readme"
    click CMake "https://github.com/freertos/corejson/blob/main/test/CMakeLists.txt"
    click Paths "https://github.com/freertos/corejson/blob/main/jsonFilePaths.cmake"
    click UTest "https://github.com/freertos/corejson/blob/main/test/unit-test/core_json_utest.c"
    click UnityDir "https://github.com/freertos/corejson/tree/main/test/unit-test/Unity"
    click UnityBuild "https://github.com/freertos/corejson/blob/main/test/unit-test/unity_build.cmake"
    click CatchAssert "https://github.com/freertos/corejson/blob/main/test/unit-test/catch_assert.h"
    click CBMCValidate "https://github.com/freertos/corejson/blob/main/test/cbmc/proofs/JSON_Validate/JSON_Validate_harness.c"
    click CBMCSearch "https://github.com/freertos/corejson/blob/main/test/cbmc/proofs/JSON_SearchConst/JSON_SearchConst_harness.c"
    click CBMCIte "https://github.com/freertos/corejson/blob/main/test/cbmc/proofs/JSON_Iterate/JSON_Iterate_harness.c"
    click CBMCMk "https://github.com/freertos/corejson/tree/main/test/cbmc/proofs/Makefile"
    click Contracts "https://github.com/freertos/corejson/blob/main/test/cbmc/include/core_json_contracts.h"
    click Dockerfile "https://github.com/freertos/corejson/tree/main/.clusterfuzzlite/Dockerfile"
    click BuildSh "https://github.com/freertos/corejson/blob/main/.clusterfuzzlite/build.sh"
    click YAML "https://github.com/freertos/corejson/blob/main/.clusterfuzzlite/project.yaml"
    click Fuzzer "https://github.com/freertos/corejson/blob/main/.clusterfuzzlite/validate_fuzzer.c"
    click DoxyConf "https://github.com/freertos/corejson/blob/main/docs/doxygen/config.doxyfile"
    click Style "https://github.com/freertos/corejson/blob/main/docs/doxygen/style.css"
    click Layout "https://github.com/freertos/corejson/blob/main/docs/doxygen/layout.xml"
    click Pages "https://github.com/freertos/corejson/blob/main/docs/doxygen/pages.dox"
    click SizeTable "https://github.com/freertos/corejson/blob/main/docs/doxygen/include/size_table.md"
    click Coverity "https://github.com/freertos/corejson/blob/main/tools/coverity/misra.config"
    click MemStat "https://github.com/freertos/corejson/blob/main/.github/memory_statistics_config.json"
    click UnityCreate "https://github.com/freertos/corejson/blob/main/tools/unity/create_test.cmake"
    click UnityCov "https://github.com/freertos/corejson/blob/main/tools/unity/coverage.cmake"
    click CI "https://github.com/freertos/corejson/blob/main/.github/workflows/ci.yml"
    click CFLite "https://github.com/freertos/corejson/blob/main/.github/workflows/cflite_pr.yml"
    click Dox "https://github.com/freertos/corejson/blob/main/.github/workflows/doxygen.yml"
    click Release "https://github.com/freertos/corejson/blob/main/.github/workflows/release.yml"
```
