Skip to content

feat: Relationship Cardinality & Data Flow Annotations (#289)#370

Merged
raifdmueller merged 5 commits into
mainfrom
289-feat-relationship-cardinality-data-flow-annotations
May 26, 2026
Merged

feat: Relationship Cardinality & Data Flow Annotations (#289)#370
raifdmueller merged 5 commits into
mainfrom
289-feat-relationship-cardinality-data-flow-annotations

Conversation

@paulefl
Copy link
Copy Markdown
Collaborator

@paulefl paulefl commented May 7, 2026

Fixes #289

Summary

Adds support for cardinality and data flow annotations on relationships, enabling precise communication of integration patterns and data relationship semantics in architecture models.

Changes

  • internal/model/types.go:
    • Added Cardinality field to Relationship struct (supports 1:1, 1:N, N:N)
    • Added DataFlow field to Relationship struct (supports sync, async, request/response, publish/subscribe)
    • Added ValidCardinalities and ValidDataFlows constant lists
  • internal/model/validate.go:
    • Extended validateRelationships() to validate cardinality values
    • Extended validateRelationships() to validate dataFlow values
    • Provides clear error messages for invalid values
  • internal/model/cardinality_test.go:
    • Comprehensive tests for valid/invalid cardinality values
    • Comprehensive tests for valid/invalid dataFlow values
    • Tests for annotation combinations

Design

  • Optional Fields: Both cardinality and dataFlow are optional, maintaining backward compatibility
  • Validation: Invalid values are caught during model validation
  • Flexible: Supports various integration patterns (synchronous, asynchronous, pub/sub)
  • Extensible: Easy to add new cardinality or data flow types

Example Usage

{
  "relationships": [
    {
      "from": "service1",
      "to": "service2",
      "label": "queries database",
      "cardinality": "1:N",
      "dataFlow": "sync"
    },
    {
      "from": "eventBus",
      "to": "consumers",
      "cardinality": "1:N",
      "dataFlow": "publish/subscribe"
    }
  ]
}

Test Plan

  • Unit tests: All cardinality and dataFlow values tested
  • Validation: Invalid cardinality and dataFlow values rejected
  • Backward compatibility: Relationships without annotations still valid
  • Build succeeds: go build ./cmd/bausteinsicht
  • Tests pass: go test ./internal/model/...

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@raifdmueller raifdmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The cardinality and data flow annotations are well-designed and backward-compatible. One issue before merging:

Schema missing enum constraints: The new cardinality and dataFlow fields are defined as plain strings in the JSON schema. Valid values like "1:1", "1:N", "sync", "async" should be listed as enum entries so IDE autocompletion and schema validation enforce them — otherwise the schema provides no guidance to users.

Minor: "sync" exists as both a DataFlow constant and a StepType constant in types.go — worth a comment to clarify they are independent domains.

Please add `"enum": [...]" to the cardinality and dataFlow schema definitions before merging.

paulefl and others added 2 commits May 26, 2026 19:56
- Add Cardinality field to Relationship struct (1:1, 1:N, N:N)
- Add DataFlow field to Relationship struct (sync, async, request/response, publish/subscribe)
- Add constants and validation lists for valid cardinality and data flow values
- Implement validation in validateRelationships() for cardinality and data flow values
- Add comprehensive unit tests for cardinality and data flow validation
- Support optional cardinality and data flow annotations on all relationships

Enables precise communication of integration patterns and data relationship semantics in architecture models.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Schema updated to reflect new relationship cardinality and data flow
annotation fields added in this feature.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@raifdmueller raifdmueller force-pushed the 289-feat-relationship-cardinality-data-flow-annotations branch from 8302a24 to 78191f9 Compare May 26, 2026 19:56
@github-actions
Copy link
Copy Markdown

📊 Test Report (Multi-OS)

Metric 🐧 Linux 🪟 Windows 🍎 macOS
Total Tests 805 805 805
✅ Passed 802 (99.6%) 802 (99.6%) 802 (99.6%)
❌ Failed 0 0 0
⏱️ Duration 7.16s 12.00s 6.79s
📦 Coverage 68.8% 68.7% 68.8%

💡 Full report: Download artifacts from this workflow run.

…e redundant Sprintf calls

Enum constraints for cardinality/dataFlow removed from schema since the generator
does not produce them — validation is enforced at the Go model level instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@raifdmueller raifdmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint fixes applied (fmt.Fprintf pattern), schema regenerated — enum validation remains in Go model validator.

@github-actions
Copy link
Copy Markdown

📊 Test Report (Multi-OS)

Metric 🐧 Linux 🪟 Windows 🍎 macOS
Total Tests 805 805 805
✅ Passed 802 (99.6%) 802 (99.6%) 802 (99.6%)
❌ Failed 0 0 0
⏱️ Duration 7.08s 13.27s 6.80s
📦 Coverage 68.8% 68.7% 68.7%

💡 Full report: Download artifacts from this workflow run.

…Status

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Test Report (Multi-OS)

Metric 🐧 Linux 🪟 Windows 🍎 macOS
Total Tests 805 805 805
✅ Passed 802 (99.6%) 802 (99.6%) 802 (99.6%)
❌ Failed 0 0 0
⏱️ Duration 7.19s 11.23s 6.85s
📦 Coverage 68.8% 68.7% 68.7%

💡 Full report: Download artifacts from this workflow run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

📊 Test Report (Multi-OS)

Metric 🐧 Linux 🪟 Windows 🍎 macOS
Total Tests 805 805 805
✅ Passed 802 (99.6%) 802 (99.6%) 802 (99.6%)
❌ Failed 0 0 0
⏱️ Duration 7.15s 10.06s 6.93s
📦 Coverage 68.8% 68.7% 68.7%

💡 Full report: Download artifacts from this workflow run.

@raifdmueller raifdmueller merged commit 19f2bf4 into main May 26, 2026
9 of 10 checks passed
@raifdmueller raifdmueller deleted the 289-feat-relationship-cardinality-data-flow-annotations branch May 26, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Relationship Cardinality & Data Flow Annotations

2 participants