# test-fullautomation/python-jsonpreprocessor architecture

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

- Interactive diagram: https://gitdiagram.com/test-fullautomation/python-jsonpreprocessor
- Repository: https://github.com/test-fullautomation/python-jsonpreprocessor

## Overview

##### Project Type and Purpose
- This is a standalone, open-source Python3 library (tool) called **JsonPreprocessor**.
- Purpose: Extend JSON handling with features like comments, imports, parameter overrides, and return a Python dict.

##### File Structure Analysis
- Top-level code folder:
- **JsonPreprocessor/** – core package module with CJsonPreprocessor.py (main logic), version.
- Build & packaging scripts:
- **setup.py**, **requirements.txt**, **genpackagedoc.py**, **additions/CExtendedSetup.py**
- Configuration:
- **config/** – repository and RobotFramework AIO JSON configurations.
- **packagedoc/** – GenPackageDoc configuration for PDF docs.
- Samples & tests:
- **sample/** – sample Python scripts and JSONs demonstrating features.
- **test/** and **atest/** – unit tests (pytest) and acceptance tests; extensive JSONP testcases.
- Docs & CI:
- **JsonPreprocessor/JsonPreprocessor.pdf** – prebuilt PDF.
- **.github/workflows/** – CI for publishing to PyPI and triggering runs.

##### Architectural Components
- a. **Core Library Module**
– CJsonPreprocessor (parses JSONP, strips/handles comments, resolves imports, applies overrides)
– Internal sub-modules (e.g., parser, importer, override resolver)
- b. **Public API / CLI**
– `setup.py install` exposes library; or import `JsonPreprocessor.CJsonPreprocessor` in Python
- c. **Configuration Manager**
– Reads `config/repository_config.json` and RobotFramework release configs
- d. **Documentation Generator**
– GenPackageDoc invoked by `genpackagedoc.py` using `packagedoc/packagedoc_config.json`
– Requires external LaTeX (`GENDOC_LATEXPATH`)
- e. **Test Harness**
– Pytest runner scripts (atest/* and test/pytest/*)
– Test data under `atest/testdata` and `test/testfiles`
- f. **Sample & Examples**
– Demonstrate usage via Python scripts and JSON files

##### Component Relationships & Data Flows
- User (or CI) installs package → exposes **JsonPreprocessor API**
↳ Application code or CLI loads **CJsonPreprocessor**
→ **Parser** reads JSONP file →
↳ **Importer** follows import statements & inlines nested files →
↳ **Override Resolver** applies parameter overrides →
↳ Final Python dict output
- Documentation pipeline: `genpackagedoc.py` ← reads source & packagedoc config → runs LaTeX → produces PDF
- Test pipeline: pytest workflows invoke test runners → feed JSONP testcases → validate output against expected dicts
- Packaging/CI: GitHub Actions → build & publish to PyPI using `setup.py` and `python-publish.yml`

##### Architectural Patterns & Design Principles
- Modularity: clear separation between parsing, importing, overriding
- Single Responsibility: each module handles one JSONP feature
- Extensibility: new preprocess directives can be added via sub-modules
- Configuration-driven: repository & doc generation behavior controlled by JSON configs
- Test-driven: comprehensive test suite covering every feature case

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input
    JSONPFiles["JSONP Files (with comments, imports, overrides)"]:::external

    %% Public API / CLI
    CLI["Public API / CLI"]:::external
    CLI -->|"invokes"| Core

    %% Core Library
    subgraph "Core Library Module"
        direction TB
        CInit["__init__.py"]:::core
        CVer["version.py"]:::core
        CJP["CJsonPreprocessor.py"]:::core
        subgraph "Sub-modules"
            direction TB
            Parser["Parser"]:::core
            Importer["Importer"]:::core
            Override["Override Resolver"]:::core
        end
    end
    CInit --> CJP
    CVer --> CJP
    JSONPFiles --> Parser
    Parser --> Importer
    Importer --> Override
    Override -->|"outputs"| Dict["Python dict"]:::external

    %% Configuration Manager
    subgraph "Configuration Manager"
        direction TB
        RepoConfigPY["CRepositoryConfig.py"]:::config
        RepoConfigJSON["repository_config.json"]:::config
        RFConfig["release_items_JsonPreprocessor.json"]:::config
    end
    RepoConfigPY --> Core
    RepoConfigJSON --> Core
    RFConfig --> Core

    %% Documentation Generator
    subgraph "Documentation Generator"
        direction TB
        GenDocScript["genpackagedoc.py"]:::external
        DocConfig["packagedoc_config.json"]:::config
        AdditionalDocs["additional_docs/*.rst/.tex"]:::config
        LaTeX["LaTeX Engine"]:::external
        PDF["JsonPreprocessor.pdf"]:::external
    end
    GenDocScript -->|"reads"| DocConfig
    GenDocScript -->|"reads"| AdditionalDocs
    GenDocScript --> LaTeX
    LaTeX --> PDF

    %% Test Harness
    subgraph "Test Harness"
        direction TB
        AT["Acceptance Tests (atest/)"]:::ci
        UT["Unit Tests (test/pytest/)"]:::ci
        CT["Component Tests"]:::ci
    end
    AT -->|"feeds JSONP testcases"| Core
    UT -->|"feeds JSONP testcases"| Core
    CT -->|"feeds JSONP testcases"| Core

    %% Samples & Examples
    subgraph "Sample & Examples"
        direction TB
        S1["001_sample_comments.py"]:::external
        S2["003_sample_import.py"]:::external
        S3["005_sample_python_syntax.py"]:::external
        S4["007_sample_use_of_variables.py"]:::external
        SJSON["json_with_*.json"]:::external
    end
    S1 --> Core
    S2 --> Core
    S3 --> Core
    S4 --> Core
    SJSON --> Core

    %% Packaging Helper
    CExtended["CExtendedSetup.py"]:::external
    CExtended --> setup

    %% Packaging & Publish
    setup["setup.py"]:::external
    setup -->|"build/publish"| PyPI["PyPI"]:::external

    %% CI/CD
    subgraph "CI/CD Pipelines"
        direction TB
        GHBuild["python-publish.yml"]:::ci
        GHTrigger["trigger_aio.yml"]:::ci
    end
    GHBuild --> setup
    GHTrigger --> AT
    GHTrigger --> UT
    GHTrigger --> CT

    %% Click Events
    click CJP "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/JsonPreprocessor/CJsonPreprocessor.py"
    click CInit "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/JsonPreprocessor/__init__.py"
    click CVer "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/JsonPreprocessor/version.py"
    click setup "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/setup.py"
    click CExtended "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/additions/CExtendedSetup.py"
    click RepoConfigPY "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/config/CRepositoryConfig.py"
    click RepoConfigJSON "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/config/repository_config.json"
    click RFConfig "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/config/robotframework_aio/release_items_JsonPreprocessor.json"
    click GenDocScript "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/genpackagedoc.py"
    click DocConfig "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/packagedoc/packagedoc_config.json"
    click AdditionalDocs "https://github.com/test-fullautomation/python-jsonpreprocessor/tree/develop/packagedoc/additional_docs"
    click S1 "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/sample/001_sample_comments.py"
    click S2 "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/sample/003_sample_import.py"
    click S3 "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/sample/005_sample_python_syntax.py"
    click S4 "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/sample/007_sample_use_of_variables.py"
    click SJSON "https://github.com/test-fullautomation/python-jsonpreprocessor/tree/develop/sample/json"
    click AT "https://github.com/test-fullautomation/python-jsonpreprocessor/tree/develop/atest"
    click UT "https://github.com/test-fullautomation/python-jsonpreprocessor/tree/develop/test/pytest"
    click CT "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/test/component_test.py"
    click GHBuild "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/.github/workflows/python-publish.yml"
    click GHTrigger "https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/.github/workflows/trigger_aio.yml"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000
    classDef external fill:#90EE90,stroke:#000
    classDef ci fill:#FFA500,stroke:#000
    classDef config fill:#D3D3D3,stroke:#000
```
