# gematik/poc-vsdm2 architecture

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

- Interactive diagram: https://gitdiagram.com/gematik/poc-vsdm2
- Repository: https://github.com/gematik/poc-vsdm2

## Overview

##### Project type and purpose
- This is a Java‑based Maven project that demonstrates a VSDM 2.0 mock server embedded in a test suite.
- It uses the Tiger testing framework to spin up a “Zion” mock HTTP server, run a Cucumber feature (`readVSD.feature`), and verify responses.

##### File structure
Top‐level elements:
- pom.xml → Maven build and test orchestrator
- tiger.yaml → Tiger environment definition (which servers to start, config mount points)
- vsdmUsers.yaml, vsdmAnswer.xml, poppTokenTemplate.json, ports.yaml → configuration & data files
- src/test/resources/features/readVSD.feature → Cucumber test definitions
- src/test/resources/*.p12 → key stores for token signing/verification
- src/ → (empty or placeholder for code; all logic lives in test suite and Tiger)

##### README insights
- Tiger reads `tiger.yaml`, starts the Zion server, mounts additional YAMLs under a virtual data tree.
- Tests use “TGR” commands to set variables, inject headers, call the server, and assert XML responses.
- Zion server matches incoming requests against configured `requestCriterions`, performs assignments (using RbelPath formulas), and returns templated XML responses seeded from `vsdmAnswer.xml` + `vsdmUsers.yaml`.

##### Main components
a) Developer Machine / CI
– Maven build & test runner
– Java 17 environment
b) Tiger Test Framework
– Parses `tiger.yaml`
– Orchestrates lifecycle (start/stop environment)
c) Zion Mock Server
– HTTP interface
– Request matching engine
– Assignment engine (RbelPath)
– Response templating engine
d) Configuration & Data Stores
– tiger.yaml (environment + server definitions + mounts)
– vsdmUsers.yaml (user data)
– vsdmAnswer.xml (response template)
– poppTokenTemplate.json (JWT template)
– P12 key stores for signing/verifying tokens
e) Test Suite
– Cucumber feature file (`readVSD.feature`)
– Step‐definitions invoking TGR commands
f) Reporting
– Serenity reports under `target/site/serenity`

##### Relationships & data flows
1) Developer/CI “mvn clean install” → Maven plugin
2) Maven → Tiger Test Framework starts
3) Tiger reads `tiger.yaml` → launches Zion server (on configured port)
4) Tiger mounts `vsdmUsers.yaml` under in‐memory data context
5) Test suite executes Cucumber steps:
- TGR set variable
- TGR inject header (reads `poppTokenTemplate.json`, P12 key store)
- HTTP GET → Zion server endpoint
6) Zion server on request:
- Match against `requestCriterions`
- Perform assignments (extract JWT body field via RbelPath to insurantId)
- Load `vsdmAnswer.xml`, substitute placeholders from `vsdmUsers.yaml`
- Return XML response
7) Test suite asserts expected response fields
8) Tiger stops environment → Serenity report generated

##### Architectural patterns & principles
- Mock‐server pattern (Zion) for POC/stub interactions
- Configuration‐driven design (all behavior defined in YAML/JSON/XML files)
- Data‐driven testing (Cucumber + external templates)
- Layered separation: orchestration (Tiger) vs. HTTP mock engine vs. data templates vs. test logic

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Orchestration"
        Maven["Maven Build & Test Runner"]:::orchestration
        Tiger["Tiger Test Framework"]:::orchestration
    end

    subgraph "Configuration & Data"
        YAML_ENV["tiger.yaml"]:::config
        PORTS["ports.yaml"]:::config
        USERS["vsdmUsers.yaml"]:::config
        ANSWER["vsdmAnswer.xml"]:::config
        JWT_TPL["poppTokenTemplate.json"]:::config
        P12_1["idpEnc.p12"]:::config
        P12_2["poppServer.p12"]:::config
        DOC["Documentation & Diagrams"]:::config
    end

    subgraph "Test Suite"
        FEATURE["readVSD.feature"]:::test
        Steps["Cucumber Steps (TGR commands)"]:::test
    end

    subgraph "Zion Mock Server"
        HTTP["HTTP Interface"]:::mock
        Match["Request Matching Engine"]:::mock
        Assign["Assignment Engine (RbelPath)"]:::mock
        Templating["Response Templating Engine"]:::mock
    end

    subgraph "Reporting"
        Report["Serenity Reports"]:::report
    end

    Maven -->|"mvn clean install"| Tiger
    Tiger -->|"reads tiger.yaml"| YAML_ENV
    Tiger -->|"start server"| HTTP
    Tiger -->|"mount vsdmUsers.yaml"| USERS
    Tiger -->|"mount vsdmAnswer.xml"| ANSWER

    FEATURE -->|"trigger Cucumber"| Steps
    Steps -->|"HTTP GET"| HTTP
    HTTP -->|"match request"| Match
    Match -->|"perform assignments"| Assign
    Assign -->|"substitute & return"| Templating
    Templating -->|"XML response"| Steps
    Steps -->|"assert & generate report"| Report

    Tiger -->|"stop environment"| Report

    click Maven "https://github.com/gematik/poc-vsdm2/blob/main/pom.xml"
    click Tiger "https://github.com/gematik/poc-vsdm2/blob/main/tiger.yaml"
    click YAML_ENV "https://github.com/gematik/poc-vsdm2/blob/main/tiger.yaml"
    click PORTS "https://github.com/gematik/poc-vsdm2/blob/main/ports.yaml"
    click USERS "https://github.com/gematik/poc-vsdm2/blob/main/vsdmUsers.yaml"
    click ANSWER "https://github.com/gematik/poc-vsdm2/blob/main/vsdmAnswer.xml"
    click JWT_TPL "https://github.com/gematik/poc-vsdm2/blob/main/poppTokenTemplate.json"
    click P12_1 "https://github.com/gematik/poc-vsdm2/blob/main/src/test/resources/idpEnc.p12"
    click P12_2 "https://github.com/gematik/poc-vsdm2/blob/main/src/test/resources/poppServer.p12"
    click FEATURE "https://github.com/gematik/poc-vsdm2/blob/main/src/test/resources/features/readVSD.feature"
    click DOC "https://github.com/gematik/poc-vsdm2/tree/main/doc/"

    classDef orchestration fill:#AED6F1,stroke:#21618C,color:#1B2631
    classDef mock fill:#F5B041,stroke:#B9770E,color:#1B2631
    classDef config fill:#ABEBC6,stroke:#239B56,color:#1B2631
    classDef test fill:#D7BDE2,stroke:#7D3C98,color:#1B2631
    classDef report fill:#E5E8E8,stroke:#566573,color:#1B2631
```
