# csuc/prc-csv2xml architecture

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

- Interactive diagram: https://gitdiagram.com/csuc/prc-csv2xml
- Repository: https://github.com/csuc/prc-csv2xml

## Overview

##### Project Type & Purpose
- The project is a data transformation tool that converts CSV (and possibly Excel) data into XML following the CERIF schema standard.
- Its core functionality is exposed as a command-line interface (CLI) and is executed via Apache Spark, leveraging libraries like picocli for CLI parsing, Spark Excel for handling Excel files, and Typesafe Config for configuration management.

##### Analyzing the File Structure
- Two main Maven modules exist:
▪ euroCRIS-cerif-definitions: Contains the CERIF XSD resource (e.g., CERIF_1.6_2.xsd) and acts as a schema definitions library.
▪ transformation: Contains the core Java source code, including packages for CLI (org.csuc.cli), marshalling logic (org.csuc.marshal) and supporting utilities (org.csuc.utils), along with a typesafe semantics layer.
- Additional directories such as docker hold configurations (Dockerfile, docker-compose, run scripts) indicating container deployment steps.
- The presence of GitHub workflows, issue templates, and build scripts (build.sh) indicates CI/CD integration and scripted builds.

a. CLI/Entry Point:
- Main CLI entry point as the class org.csuc.cli.Cerif.
- How the CLI interacts with the transformation engine by parsing command-line arguments (input file, output file, ruct code, etc.).
b. Transformation Engine:
- A core transformation component that processes input data (CSV/Excel).
- Sub-components or packages responsible for marshalling (conversion to domain objects) and generating XML, leveraging classes like Marshaller, Department, Publication, etc.
- Integration with Apache Spark processing, which is launched via the spark-submit command.
c. Schema Definitions Module:
- Use for validating or styling the generated XML.
d. External Libraries & Frameworks:
- Use of Apache Spark (data processing engine).
- Picocli (CLI argument parsing), Spark Excel (handling Excel inputs) and Typesafe Config (configuration).
e. Build & Deployment:
- Maven as the build tool managing multiple modules (roots defined by pom.xml files).
- Docker as a containerization layer covering pre-built images as defined in the docker directory.
f. CI/CD & Versioning:

##### Relationships & Data Flow
- That the engine leverages the Schema Definitions module to validate/align processed data with CERIF standards.
- That the engine outputs an XML file.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Process
    U["User Input"]:::user

    subgraph "Core Transformation"
        CLI["CLI Entry Point (org.csuc.cli.Cerif)"]:::cli
        subgraph "Transformation Engine"
            TE["Core Engine"]:::engine
            M["Marshalling (org.csuc.marshal)"]:::engine
            UTL["Utilities (org.csuc.utils)"]:::engine
            TS["Typesafe Semantics (org.csuc.typesafe)"]:::engine
        end
        SD["Schema Definitions (CERIF Schema)"]:::schema
        XML["XML Output"]:::output
        SP["Apache Spark Framework"]:::external
    end

    %% External Dependencies
    subgraph "External Dependencies"
        PC["picocli"]:::external
        SE["Spark Excel"]:::external
        TC["Typesafe Config"]:::external
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        MV["Maven Build System"]:::build
        DK["Docker Deployment"]:::build
        CI["CI/CD Pipeline (GitHub Actions)"]:::ci
    end

    %% Relationships - Core Process
    U -->|"provides args"| CLI
    CLI -->|"invokes"| TE
    TE -->|"delegatesTo"| M
    TE -->|"delegatesTo"| UTL
    TE -->|"delegatesTo"| TS
    TE -->|"launches"| SP
    TE -->|"validatesWith"| SD
    SD -->|"suppliesSchema"| XML
    TE -->|"produces"| XML

    %% Relationships - External Dependencies
    CLI -->|"parsesArgsVia"| PC
    TE -->|"readsExcelVia"| SE
    TE -->|"loadsConfigVia"| TC

    %% Relationships - Build & Deployment
    CI -->|"triggers"| MV
    MV -->|"packages"| CLI
    MV -->|"packages"| TE
    MV -->|"buildsArtifactsFor"| DK

    %% Class definitions for colors
    classDef user fill:#dddddd,stroke:#333,stroke-width:2px;
    classDef cli fill:#f9c2ff,stroke:#333,stroke-width:2px;
    classDef engine fill:#bbdefb,stroke:#333,stroke-width:2px;
    classDef schema fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef external fill:#fff59d,stroke:#333,stroke-width:2px;
    classDef build fill:#b2ebf2,stroke:#333,stroke-width:2px;
    classDef ci fill:#f8bbd0,stroke:#333,stroke-width:2px;
    classDef output fill:#e8f5e9,stroke:#333,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/csuc/prc-csv2xml/blob/master/transformation/src/main/java/org/csuc/cli/Cerif.java"
    click M "https://github.com/csuc/prc-csv2xml/tree/master/transformation/src/main/java/org/csuc/marshal"
    click UTL "https://github.com/csuc/prc-csv2xml/tree/master/transformation/src/main/java/org/csuc/utils"
    click TS "https://github.com/csuc/prc-csv2xml/tree/master/transformation/src/main/java/org/csuc/typesafe"
    click SD "https://github.com/csuc/prc-csv2xml/blob/master/euroCRIS-cerif-definitions/src/main/resources/CERIF_1.6_2.xsd"
    click MV "https://github.com/csuc/prc-csv2xml/blob/master/pom.xml"
    click DK "https://github.com/csuc/prc-csv2xml/tree/master/docker"
    click CI "https://github.com/csuc/prc-csv2xml/blob/master/.github/workflows/main.yml"
```
