Documentation
¶
Overview ¶
Package usecases contains the application use cases (orchestration logic).
This layer defines the business workflows that coordinate domain entities with external concerns (file I/O, rendering, etc.). Use cases do NOT contain business logic—that belongs in the domain layer.
Each use case:
- Defines one complete workflow (e.g., "Generate a diagram")
- Uses ports (interfaces) to depend on external concerns
- Never depends directly on specific implementations
- Maps to Gherkin scenarios: "Given → When → Then"
Ports (interfaces) defined here:
- ConfigParser: Read and parse configuration files
- LayoutEngine: Arrange nodes using layout algorithms
- Pathfinder: Calculate paths between nodes
- Renderer: Generate output (SVG, PNG, etc.)
- FileReader/FileWriter: Abstract file system access
Adapters (in internal/adapters/) implement ports
Use cases map to Gherkin "When" steps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigParser ¶
type ConfigParser interface {
// Parse reads a config file and returns a validated Diagram.
// Maps to: "Given I have a diagram config 'file.layli'"
Parse(path string) (*domain.Diagram, error)
}
ConfigParser reads configuration files and returns domain diagrams. Implementations: YAML parser, JSON parser, etc.
type FileReader ¶
FileReader abstracts file system reads (for testing).
type FileWriter ¶
FileWriter abstracts file system writes (for testing).
type GenerateDiagram ¶
type GenerateDiagram struct {
// contains filtered or unexported fields
}
GenerateDiagram orchestrates the complete diagram generation workflow. Maps to a complete Gherkin scenario: Given → When → Then
func NewGenerateDiagram ¶
func NewGenerateDiagram( parser ConfigParser, layout LayoutEngine, pathfinder Pathfinder, renderer Renderer, ) *GenerateDiagram
NewGenerateDiagram creates a new GenerateDiagram use case.
func (*GenerateDiagram) Execute ¶
func (uc *GenerateDiagram) Execute(configPath, outputPath string) error
Execute runs the complete diagram generation pipeline.
Steps:
- Parse configuration (Given)
- Validate diagram (Given)
- Arrange layout (When)
- Calculate paths (When)
- Render output (Then)
type LayoutEngine ¶
type LayoutEngine interface {
// Arrange positions all nodes in the diagram.
// Maps to: "When I arrange using 'flow-square' layout"
Arrange(diagram *domain.Diagram) error
}
LayoutEngine arranges nodes within a diagram. Implementations: FlowSquare, TopoSort, Tarjan, Absolute
type Pathfinder ¶
type Pathfinder interface {
// FindPaths calculates paths for all edges in the diagram.
// Maps to: "And calculate paths for all edges"
FindPaths(diagram *domain.Diagram) error
}
Pathfinder calculates edge paths between nodes. Implementations: Dijkstra, A*, etc.