Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Interface inference issue... #78

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions C4InterFlow.Automation/C4InterFlow.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow.Automation</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>1.1.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/C4InterFlow.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
Expand Down
7 changes: 6 additions & 1 deletion C4InterFlow.Cli/CLI Commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\Internet Banking System\

draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\Internet Banking System\CSV\Architecture\Json" --aac-reader-strategy "C4InterFlow.Automation.Readers.JsonAaCReaderStrategy,C4InterFlow.Automation" --interfaces BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces.* --business-processes BigBankPlc.BusinessProcesses.* --levels-of-details context container --output-dir "C:\C4InterFlow\Samples\Internet Banking System\CSV\Diagrams"

draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Architecture" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces ECommercePlatform.SoftwareSystems.*.Interfaces.* ECommercePlatform.SoftwareSystems.*.Containers.*.Interfaces.* --levels-of-details context container --output-dir "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Diagrams"



draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Architecture" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces ECommercePlatform.SoftwareSystems.*.Interfaces.* ECommercePlatform.SoftwareSystems.*.Containers.*.Interfaces.* --levels-of-details context container --output-dir "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Diagrams"

draw-diagrams --aac-input-paths "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Architecture" --aac-reader-strategy "C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation" --interfaces ECommercePlatform.SoftwareSystems.BuyingAndMerchandisingApp.Interfaces.CreatePurchaseOrder --levels-of-details context --scopes software-system-interface --types c4-sequence --output-dir "C:\C4InterFlow\Samples\E-Commerce Platform\Yaml\Diagrams"
2 changes: 1 addition & 1 deletion C4InterFlow.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"C4InterFlow.Cli": {
"commandName": "Project",
"commandLineArgs": "draw-diagrams --aac-input-paths \"C:\\C4InterFlow\\Samples\\Internet Banking System\\CSV\\Architecture\\Json\" --aac-reader-strategy \"C4InterFlow.Automation.Readers.JsonAaCReaderStrategy,C4InterFlow.Automation\" --interfaces BigBankPlc.SoftwareSystems.*.Containers.*.Interfaces.* --business-processes BigBankPlc.BusinessProcesses.* --levels-of-details context container --output-dir \"C:\\C4InterFlow\\Samples\\Internet Banking System\\CSV\\Diagrams\"\r\n"
"commandLineArgs": "draw-diagrams --aac-input-paths \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Architecture\" --aac-reader-strategy \"C4InterFlow.Automation.Readers.YamlAaCReaderStrategy,C4InterFlow.Automation\" --interfaces ECommercePlatform.SoftwareSystems.BuyingAndMerchandisingApp.Interfaces.CreatePurchaseOrder --levels-of-details context --scopes software-system-interface --types c4-sequence --output-dir \"C:\\C4InterFlow\\Samples\\E-Commerce Platform\\Yaml\\Diagrams\""
}
}
}
4 changes: 2 additions & 2 deletions C4InterFlow/C4InterFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<Deterministic>true</Deterministic>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
</PropertyGroup>

<PropertyGroup>
<PackageId>C4InterFlow</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>1.1.0</PackageVersion>
<Authors>Slava Vedernikov</Authors>
<Description>Revolutionise your Application Architecture Documentation with C4InterFlow. Designed for Architects and Engineers, this tool leverages the widely-recognised C4 Model (Architecture Visualisation framework), enhanced with unique features like Interface and Flow, to describe your Application Architecture as Code. Experience an intuitive, efficient way to document complex systems, ensuring clarity and consistency across your teams and products.</Description>
<Copyright>Copyright 2024 Slava Vedernikov</Copyright>
Expand Down
62 changes: 49 additions & 13 deletions C4InterFlow/Structures/Flow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace C4InterFlow.Structures
{
public record Flow
{
private static readonly Regex ComponentsRegex = new Regex(@"\.Components\.[^.]*");
private static readonly Regex ContainersRegex = new Regex(@"\.Containers\.[^.]*");

public enum FlowType
{
None,
Expand Down Expand Up @@ -191,7 +194,7 @@ private void CleanUpInferredContainerFlows()

flows.ForEach(x =>
{
if(x.Flows == null || x.Flows.Count == 0 || x.Owner.Contains(".Components."))
if(x.Flows == null || x.Flows.Count == 0 || ComponentsRegex.IsMatch(x.Owner))
{
x.Type = FlowType.None;
}
Expand Down Expand Up @@ -230,20 +233,36 @@ private void CleanUpInferredSoftwareSystemFlows()
flows.ForEach(x =>
{
if (x.Flows == null ||
x.Flows.Count == 0 ||
x.Owner.Contains(".Components.") ||
x.Owner.Contains(".Containers."))
x.Flows.Count == 0 ||
ComponentsRegex.IsMatch(x.Owner) ||
ContainersRegex.IsMatch(x.Owner))
{
x.Type = FlowType.None;
}
});
}
private void InferContainerInterfaces(Flow flow, string currentScope)
{
if(flow.Type == FlowType.Use)
if (flow.Type == FlowType.Use)
{
flow.Expression = new Regex(@"\.Components\.[^.]*").Replace(flow.Expression, string.Empty);
flow.SetOwner(new Regex(@"\.Components\.[^.]*").Replace(flow.Owner, string.Empty), true);
var inferredExpression = ComponentsRegex.Replace(flow.Expression, string.Empty);
var inferredOwner = ComponentsRegex.Replace(flow.Owner, string.Empty);

if (flow.Expression.Equals(inferredExpression) && flow.Owner.Equals(inferredOwner))
{
if (flow.Flows != null)
{
foreach (var segment in flow.Flows)
{
InferContainerInterfaces(segment, currentScope);
}
}

return;
}

flow.Expression = inferredExpression;
flow.SetOwner(inferredOwner, true);

var newScope = Utils.GetContainerAlias(flow.Expression);

Expand Down Expand Up @@ -272,7 +291,7 @@ private void InferContainerInterfaces(Flow flow, string currentScope)
}
else if (flow.Type == FlowType.Return || flow.Type == FlowType.ThrowException)
{
if(flow.Owner.Contains(".Components."))
if(ComponentsRegex.IsMatch(flow.Owner))
{
flow.Type = FlowType.None;
}
Expand All @@ -293,11 +312,28 @@ private void InferSoftwareSystemInterfaces(Flow flow, string currentScope)
{
if (flow.Type == FlowType.Use)
{
flow.Expression = new Regex(@"\.Components\.[^.]*").Replace(flow.Expression, string.Empty);
flow.SetOwner(new Regex(@"\.Components\.[^.]*").Replace(flow.Owner, string.Empty), true);
var inferredExpression = ComponentsRegex.Replace(flow.Expression, string.Empty);
var inferredOwner = ComponentsRegex.Replace(flow.Owner, string.Empty);

inferredExpression = ContainersRegex.Replace(inferredExpression, string.Empty);
inferredOwner = ContainersRegex.Replace(inferredOwner, string.Empty);

if (flow.Expression.Equals(inferredExpression) && flow.Owner.Equals(inferredOwner))
{
if (flow.Flows != null)
{
foreach (var segment in flow.Flows)
{
InferSoftwareSystemInterfaces(segment, currentScope);
}
}

return;
}

flow.Expression = inferredExpression;
flow.SetOwner(inferredOwner, true);

flow.Expression = new Regex(@"\.Containers\.[^.]*").Replace(flow.Expression, string.Empty);
flow.SetOwner(new Regex(@"\.Containers\.[^.]*").Replace(flow.Owner, string.Empty), true);

var newScope = Utils.GetSoftwareSystemAlias(flow.Expression);

Expand All @@ -321,7 +357,7 @@ private void InferSoftwareSystemInterfaces(Flow flow, string currentScope)
}
else if (flow.Type == FlowType.Return || flow.Type == FlowType.ThrowException)
{
if (flow.Owner.Contains(".Components.") || flow.Owner.Contains(".Containers."))
if (ComponentsRegex.IsMatch(flow.Owner) || ContainersRegex.IsMatch(flow.Owner))
{
flow.Type = FlowType.None;
}
Expand Down
2 changes: 1 addition & 1 deletion Samples/ToDoApp/draw-diagrams.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off
:: Possible values: TRUE, FALSE
set "redraw-all=TRUE"
set "redraw-all=FALSE"
:::::::::::::::::::::::::::::::

set "aac-root-namespace=ToDoAppExample"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ group Start
Rel(TraderX.SoftwareSystems.TraderX.Containers.WebGUI, TraderX.SoftwareSystems.TraderX.Containers.TradeFeed, "Receive Updates To Trades")
Rel(TraderX.SoftwareSystems.TraderX.Containers.WebGUI, TraderX.SoftwareSystems.TraderX.Containers.TradeFeed, "Receive Updates To Positions")
Rel(TraderX.SoftwareSystems.TraderX.Containers.WebGUI, TraderX.SoftwareSystems.TraderX.Containers.WebClient, "Send Trade And Position Status Updates")
group Send Trade And Position Status Updates
Rel(TraderX.SoftwareSystems.TraderX.Containers.WebClient, TraderX.SoftwareSystems.TraderX.Containers.WebClient, "Update Trade And Position Status View")
end
end
end
group Trader - Cancel Trade
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ group Start
TraderX.SoftwareSystems.TraderX.Containers.WebGUI -> TraderX.SoftwareSystems.TraderX.Containers.TradeFeed : Receive Updates To Trades
TraderX.SoftwareSystems.TraderX.Containers.WebGUI -> TraderX.SoftwareSystems.TraderX.Containers.TradeFeed : Receive Updates To Positions
TraderX.SoftwareSystems.TraderX.Containers.WebGUI -> TraderX.SoftwareSystems.TraderX.Containers.WebClient : Send Trade And Position Status Updates
group Send Trade And Position Status Updates
TraderX.SoftwareSystems.TraderX.Containers.WebClient -> TraderX.SoftwareSystems.TraderX.Containers.WebClient : Update Trade And Position Status View
end
end
end
group Trader - Cancel Trade
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ System_Boundary(TraderX.SoftwareSystems.TraderX, "TraderX")
Boundary_End()

Rel(C4InterFlow.SoftwareSystems.ExternalSystem, TraderX.SoftwareSystems.TraderX.Containers.WebClient, "Send Trade And Position Status Updates")
group Send Trade And Position Status Updates
Rel(TraderX.SoftwareSystems.TraderX.Containers.WebClient, TraderX.SoftwareSystems.TraderX.Containers.WebClient, "Update Trade And Position Status View")
end


@enduml
Loading