Architecture Overview
Understanding the internal architecture of DataGeneration.
High-Level Architecture
DSL JSON → Parser → DSL Tree → Visitor → Generated Data
- DSL Parsing: JSON is parsed into a tree of
DslNodeobjects - Validation: Tree is validated for correctness
- Visitor Pattern:
DataGenerationVisitortraverses the tree - Generation: Generators create data based on node types
- Output: Data is serialized to JSON, SQL, or custom formats
Core Components
DSL Tree
The DSL is represented as a tree of nodes:
RootNode- Top-level containerCollectionNode- Represents a collectionItemNode- Template for collection itemsGeneratedFieldNode- Field with generatorLiteralFieldNode- Static value fieldArrayFieldNode- Array fieldReferenceNode- Reference to another collection
Visitor Pattern
The DataGenerationVisitor traverses the DSL tree and generates data:
public interface DslNodeVisitor {
void visit(RootNode node);
void visit(CollectionNode node);
void visit(GeneratedFieldNode node);
// ... other node types
}
Generator Registry
All generators are registered in GeneratorRegistry:
GeneratorRegistry registry = new GeneratorRegistry();
registry.register("uuid", new UuidGenerator());
registry.register("name", new NameGenerator());
// ... etc
Generation Contexts
Two context implementations:
EagerGenerationContext- Generates all data upfrontLazyGenerationContext- Generates data on-demand
Design Patterns
Visitor Pattern
Used for traversing and processing the DSL tree without modifying node classes.
Builder Pattern
DslDataGenerator.Builder provides fluent API for configuration.
Strategy Pattern
FilteringBehavior enum allows different filtering strategies.
Proxy Pattern
Lazy generation uses proxy objects for on-demand field materialization.
Registry Pattern
GeneratorRegistry manages all available generators.
Next Steps
- Custom Generators - Extend the library
- Memory Optimization - Lazy vs eager generation
- Java API - Full API documentation