How zhxiaogg/fluorite works
Main Components
a) Schema Input Layer:
• YAML/JSON Schema Definitions
• Schema Parser/Validator
b) Code Generation Core:
• ABI (Abstract Binary Interface) Layer
• Language-specific Generators
• Type System
c) Output Layer:
• Package Writers
• Generated Code Files
Detailed Component Breakdown
a) Input Processing:
• To a Schema Parser component
• Fluorite Definition Parser (fluorite/definition.yaml)
b) Core Processing:
• Separate modules for:
• Type System (code_gen/abi/type_info.rs)
• Generator Interface (code_gen/generator.rs)
• Language-specific Generators:
• Rust Generator
• TypeScript Generator (marked as WIP)
c) Output Generation:
• Package Writer components for each target language
• Build Integration (build.rs support)
Specific Implementation Details
• Blue rectangles: Core components
• Green rectangles: Language-specific generators
• Yellow diamonds: Input/Output files
• Orange ovals: Runtime components
Flow Directions
Schema Definition Files → Parser → CodeGen Engine → Language Generators → Output Files
Important Subsystems
a) Type System:
• Primitive Types
• Collection Types
• User-defined Types
• Type Info Management
b) Generator System:
• Pre-processor
• Context Management
• Type Writer
• Package Writer
Integration Points
Highlight:
• Build System Integration
• Runtime Library Connection
• Serde Integration Points
Key Architectural Patterns to Emphasize
• Visitor Pattern for type handling
• Factory Pattern for generator creation
• Strategy Pattern for different language backends
Technical Details
• Supported input formats (YAML/JSON)
• Output language support (Rust, TypeScript)
• Build integration methods
• Runtime dependencies
Remember to show both the compile-time (codegen) and runtime (fluorite runtime) components separately, as they operate at different phases of the system's lifecycle.
This architecture should clearly demonstrate how Fluorite transforms schema definitions into type-safe code while maintaining extensibility for additional language targets.