julianpeeters/avrohugger
58.4
Adequate · 20 September 2026
5k
lines of production code
Scala
primary language
1
measurement over time
What this system is
Avrohugger is a code generation tool that converts Apache Avro schemas and protocols into Scala source code. It supports two primary output modes: a 'Standard' format that generates idiomatic Scala case classes and enums, and a 'Specific' format that produces classes implementing Avro's SpecificRecordBase interface. The system handles complex type mappings, including logical types like dates and decimals, and provides a command-line interface for batch processing.
How it got here
2015 — AvroHugger core and CLI implementation
18 changes.
This period focused on introducing the Avrohugger code generator and its command-line interface, enabling the generation of Scala code from Avro schemas. The work involved implementing core generation formats, including Standard and SpecificRecord outputs, while refactoring internal parsers and converters to support complex schema structures and logical types. Extensive test coverage was added to validate the correctness of the generated code across various schema features and Scala versions.
2016 — Scala 3 support and code generation refactoring
18 changes.
The project refactored its code generation architecture to support Scala 3 features, including native union types and enums, while introducing standardized abstractions for format handling. This period also expanded the Standard format with opt-in ADT generation, FIXED type support, and multiple enum styles, alongside comprehensive updates to test coverage and Scala 2.13 compatibility.
2017–2023 — Deterministic compilation and logical type support
17 changes.
The project introduced a new module to ensure deterministic Avro schema compilation order, resolving platform-specific filesystem issues. Significant work was done to refactor code generation logic and expand support for Avro logical types, allowing custom mappings for dates, times, and decimals. Extensive test coverage was added to verify these features across multiple Scala versions and complex type scenarios.
2024–2026 — Test coverage expansion
4 changes.
This period focused on expanding test coverage for the Avro code generator by adding expected output files for various complex scenarios. The work verified correct handling of fully qualified names for fixed types, date/time logical type mappings, Scala 3 union types, and specific record generation features like annotations and interfaces.
Features
Add ClassStore for tracking generated case classes
A new ClassStore component has been introduced to manage and track generated case classes. It uses a thread-safe ConcurrentHashMap to store mappings between Avro schema full names and their corresponding Scala symbols, ensuring that duplicate class definitions are avoided during code generation.
avrohugger-core/src/main/scala/stores · high confidence
Avrohugger code generator core and CLI tool introduced
The repository now includes the core \Generator\ class and a command-line \GeneratorTool\ that integrates with Apache Avro tools to generate Scala code from Avro schemas, protocols, and data files. The generator supports multiple output formats (Standard and Specific) and allows customization of type mappings for primitives, complex types, and logical types (such as dates, timestamps, decimals, and UUIDs). It also supports Scala 3 enums and configurable union types, providing users with flexible code generation options for their Avro data models.
repository · high confidence
Introduce Specific format code generation implementation
Added the core implementation for the 'Specific' code generation format, including the \SpecificImporter\ for managing Scala imports (such as Shapeless coproducts and tagged decimals), \SpecificScalaTreehugger\ for generating Scala source code trees, and \SpecificJavaTreehugger\ for generating Java code strings. This enables the tool to generate Scala case classes and Java records based on Avro schemas and protocols using the Specific format conventions.
avrohugger-core/src/main/scala/format/specific · high confidence
Introduce avrohugger-filesorter module for deterministic schema compilation order
A new \avrohugger-filesorter\ module has been added to ensure that Avro schema files (\.avsc\) and IDL files (\.avdl\) are compiled in a deterministic, dependency-respecting order. This addresses platform-specific filesystem ordering issues (e.g., alphabetical on macOS vs. undefined on some Linux distributions) that previously caused compilation failures when records referenced other types. The module includes \AvscFileSorter\ for JSON schemas, \AvdlFileSorter\ for IDL imports, \ReferredTypeFinder\ for parsing type references, and \TypeComparator\ for matching namespaces and names, ensuring dependent types are processed before the types that use them.
avrohugger-filesorter/src/main · high confidence
Introduce field name mangling and new code-generation formats
The code generator now escapes Avro field names that conflict with Scala reserved keywords (such as 'class', 'def', 'val') by wrapping them in backticks, preventing compilation errors in the generated Scala code. Additionally, two new output formats are introduced: 'Standard', which generates idiomatic Scala case classes and supports various enum styles (Java, Scala 3, Scala Enumeration, and string-based), and 'SpecificRecord', which generates classes extending Avro's SpecificRecordBase and hard-codes Java enums for compatibility. These changes expand the tool's capability to produce valid, type-safe Scala code from Avro schemas while maintaining backward compatibility with existing generation patterns.
avrohugger-core/src/main/scala/format · high confidence
New command-line tool for Avro code generation
A new CLI entry point (Main.scala and Runner.scala) has been added to the avrohugger-tools module, exposing the Standard and SpecificRecord generators as command-line tools. Users can now invoke code generation directly from the terminal, with the tool listing available formats and handling execution errors gracefully.
avrohugger-tools/src/main · high confidence
Standard format now supports Scala 3 union types and enums
The Standard code generation format has been updated to support Scala 3 features, including generating Scala 3 union types for Avro unions (replacing the previous Shapeless-based coproduct approach) and generating Scala 3 Enum definitions for Avro enums. This change introduces new importer and treehugger components (\StandardImporter\, \StandardScalaTreehugger\, \StandardJavaTreehugger\) that handle these specific Scala 3 code structures, allowing users to generate code compatible with Scala 3's native union and enum syntax.
avrohugger-core/src/main/scala/format/standard · high confidence
Standard format now supports opt-in ADT generation, FIXED types, and multiple enum styles
The Standard format's code generation has been expanded to support generating sealed traits (ADTs) for protocols with multiple subtypes, which is now an opt-in feature controlled by the \protocol\ type matcher. It also adds support for Avro FIXED types as named, top-level value classes and introduces several new enum generation styles, including Scala 3 enums, case object companion enums, and a custom \EnumAsScalaString\ style. Additionally, users can now opt-in to generating companion objects that include the schema for both case classes and FIXED types.
avrohugger-core/src/main/scala/format/standard/avrohuggers · high confidence
Support for custom type mappings and default values for date, time, and decimal fields
The avrohugger code generator now allows users to configure how Avro logical types (date, time, timestamp, and decimal) map to Scala types and their default values. This change introduces new matchers in the \matchers/custom\ package that support mapping date and time fields to Java 8 \java.time\ classes (such as \LocalDate\, \LocalTime\, \Instant\, \ZonedDateTime\, and \LocalDateTime\) in addition to legacy \java.sql\ types and underlying primitives. It also adds support for Scala \BigDecimal\ with shapeless-tagged precision and scale for decimal fields, enabling type-safe decimal handling. Furthermore, the generator now correctly produces default values for these custom types, ensuring that generated records initialize these fields appropriately based on the selected mapping strategy.
avrohugger-core/src/main/scala/matchers/custom · high confidence
Architecture
Refactored code generation into standardized format abstractions
The code generation logic in avrohugger-core has been restructured around new abstract traits (Importer, JavaTreehugger, ScalaTreehugger, and SourceFormat) to standardize how different output formats handle schema processing. This change introduces dedicated import resolution for FIXED and ENUM types, separates Java enum generation (via Avro's SpecificCompiler) from Scala code generation, and unifies the compilation unit creation process, ensuring consistent handling of nested schemas and type matching across formats.
avrohugger-core/src/main/scala/format/abstractions · high confidence
Behavioural changes
Introduce Protocolhugger and Schemahugger abstractions with Scala 2.13 compatibility
The avrohugger-core module now includes new abstraction traits, Protocolhugger and Schemahugger, which define the interface for converting Avro protocols and schemas into Scala code trees. These abstractions standardize the code generation process by accepting a target Scala partial version, enabling better support for different Scala versions. Additionally, the implementation updates deprecated Java collection conversions to use scala.jdk.CollectionConverters, ensuring compatibility with Scala 2.13+ and removing reliance on deprecated APIs.
avrohugger-core/src/main/scala/format/abstractions/avrohuggers · high confidence
Introduce schema dependency inspection and nested schema extraction
The code generator now includes new internal utilities to better analyze Avro schema structures. A new DependencyInspector object handles the identification of referred namespaces and type names within complex schema types like arrays, maps, and unions. Additionally, a NestedSchemaExtractor object has been added to traverse and collect nested record, enum, and fixed schemas, ensuring they are processed in the correct topological order. These changes support more robust handling of nested schemas and align with modern Scala collection conversion practices.
avrohugger-core/src/main/scala/input · high confidence
New file and string input parsers with improved IDL import handling
The parser layer has been restructured to introduce dedicated parsers for file-based and string-based inputs, replacing the previous monolithic approach. FileInputParser now handles .avro, .avsc, .avpr, and .avdl files, featuring robust retry logic for file reading and improved handling of IDL imports by stripping imported types from protocols to prevent namespace collisions. StringInputParser adds support for parsing inline schema, protocol, and IDL strings, attempting each format in sequence. Additionally, a new ScalaDocParser extracts documentation from Scala source code to support generating Avro documentation from ScalaDoc comments.
avrohugger-core/src/main/scala/input/parsers · high confidence
Protocol-based ADT generation is now opt-in
The behavior for generating Scala code from Avro protocols has changed: protocols containing multiple schemas are no longer automatically converted into Scala Algebraic Data Types (sealed traits). Instead, this generation is now controlled by the \typeMatcher.avroScalaTypes.protocol\ setting, allowing users to explicitly enable or disable ADT generation for protocols.
avrohugger-core/src/main/scala/format/specific/avrohuggers · high confidence
Refactor code generation into dedicated File, String, and ScalaDoc generators
The code generation logic in avrohugger-core has been restructured to separate concerns. A new FileGenerator handles writing generated Scala code to disk from schemas, protocols, and file inputs, including deduplication of schemas. A StringGenerator manages in-memory generation of code strings from the same inputs, handling parsing and output formatting. Additionally, a ScalaDocGenerator object has been introduced to properly attach Avro documentation (schema-level and field-level) to the generated Scala classes, traits, enums, and value classes, ensuring that generated code includes appropriate Scaladoc comments.
avrohugger-core/src/main/scala/generators · high confidence
Refactored SpecificRecord Java/Scala conversion logic into dedicated converter objects
The conversion logic for the SpecificRecord format has been reorganized into three new files: JavaConverter, ScalaConverter, and SchemaAccessors. This change extracts the code responsible for generating the Java-to-Scala and Scala-to-Java conversion methods (get/put) from the main generator, making the conversion process more modular. The new structure explicitly handles type mappings for complex Avro types including unions, arrays, maps, fixed (decimal), bytes, and logical types like timestamps and dates, while also supporting Scala 2.13 collection converters.
avrohugger-core/src/main/scala/format/specific/converters · high confidence
Refactored SpecificRecord get/put methods to use Scala switch and Java/Scala converters
The \get\ and \put\ methods in generated SpecificRecord classes now utilize Scala's \@switch\ annotation for indexed field access, improving performance and code structure. The implementation delegates field value retrieval and assignment to dedicated \JavaConverter\ and \ScalaConverter\ utilities, ensuring consistent type handling for logical types and custom formats. This change replaces previous inline logic with a standardized conversion pipeline, affecting how field data is read from and written to the underlying Avro schema.
avrohugger-core/src/main/scala/format/specific/methods · high confidence
Refactored Standard format code generation to use dedicated tree builders
The Standard format's code generation logic has been restructured into dedicated tree-building components (StandardCaseClassTree, StandardObjectTree, StandardTraitTree) to improve modularity and support new capabilities. Case classes are now generated as final by default, and those with more than 22 fields are generated as simple classes instead of case classes to avoid parameter limit issues. The format now supports generating Scala 3 enums, case object companion-style enums, and Algebraic Data Types (ADTs) from protocols. Additionally, companion objects for schemas are generated opt-in, and the codebase has been updated to use modern Scala collection converters (CollectionConverters) replacing deprecated JavaConversions/JavaConverters.
avrohugger-core/src/main/scala/format/standard/trees · high confidence
Refactored specific format code generation to support sealed traits, final case classes, and decimal logical types
The specific format generator has been restructured into dedicated tree builders (SpecificCaseClassTree, SpecificObjectTree, SpecificTraitTree) to improve code generation capabilities. Generated case classes are now final by default to enhance performance and safety, and records with more than 22 fields are generated as standard classes instead of case classes to avoid arity limits. The generator now supports creating sealed traits (ADTs) from Avro protocols and includes proper handling for decimal logical types via custom conversion logic in companion objects. Additionally, RPC protocol messages are now correctly mapped to trait methods with appropriate callback signatures.
avrohugger-core/src/main/scala/format/specific/trees · high confidence
Refactored type and default-value matching logic for unions, logical types, and custom types
The \matchers\ package has been restructured into three new files—\TypeMatcher\, \DefaultParamMatcher\, and \DefaultValueMatcher\—to centralize and improve the handling of Avro schema conversions. This change introduces support for multiple union strategies (Shapeless Coproduct, Option/Either, and Scala 3 native unions), ensuring that default parameter values and JSON-derived default values are correctly generated for complex types like unions, fixed decimals, and logical types (date, time, timestamp). It also standardizes the use of \CustomDefaultParamMatcher\ and \CustomNamespaceMatcher\ to respect user-defined type customizations and namespace overrides across all generated code.
avrohugger-core/src/main/scala/matchers · high confidence
Test coverage
Added comprehensive test coverage for the SpecificRecord generator; Added comprehensive test suite for Standard format code generation; Added expected test outputs for specific record generation; Added test case for date/time field mapping to Int/Long; Added test cases for Avro protocol and message generation; Added test expectation for Country record with nested City types; Added test expectation for ExternalDependency case class; Added test expectation for Twitter schema generation; Added test expectation for nullable decimal handling; Added test expectations for Scala 3 union types in Avro code generation; Added test expectations for logical type code generation; Added test expectations for logical type support in SpecificRecord generation; Added test expectations for unions with coproducts; Added test fixtures for Avro fixed types with fully qualified names; Added test fixtures for Avro logical types in SpecificRecord generation; Added test fixtures for Avro protocol and message generation; Added test fixtures for Avro schema validation and code generation; Added test fixtures for IDL logical types; Added test fixtures for Java enum and Scala case class generation; Added test fixtures for complex union types with Shapeless Coproducts; Added test fixtures for external dependency and enum schema generation; Added test fixtures for final case classes and Seq array types; Added test fixtures for generated Scala case classes; Added test fixtures for generated case classes with final modifier and Seq array types; Added test fixtures for proto-specific Avro code generation; Added test fixtures for specific Avro record generation; Added test for SpecificRecord case class generation; Added test infrastructure for Avrohugger code generation; Added test suite for AvroHugger command-line tools; Added tests for Avro schema file sorting with fixed types and IDL imports; Added tests for Scala 2.11, 2.12, 2.13, and 3.3 array-specific record generation; Added tests for final case class generation in Scala output; Expanded test coverage for Avro schema generation; Standard format test fixtures updated for code generation features; Updated test expectation for MyRecord generation; Updated test fixtures for comment handling and case class generation.
Dependencies
Upgrade to Avro 1.12.1 and Scala 3.3.8
The build configuration has been updated to use Apache Avro version 1.12.1 and Scala 3.3.8 as the primary version, while maintaining cross-compilation support for Scala 2.12.21 and 2.13.18. This change also updates the treehugger dependency to 0.5.0 and adjusts test dependencies (specs2) to version 5.9.1 for Scala 3, ensuring compatibility with the newer Scala runtime and Avro library.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 58.
Lenses
- Code Health 89
- Architecture 100
- Maturity 57
- Readiness 46
- Security 75
Changes since last survey
- 300 commits — 251 feature/other, 49 fixes
By area
- avrohugger-core/src — 106 commits
- (root) — 104 commits
- (repo) — 58 commits
- .github/workflows — 23 commits
- project/build.properties — 7 commits
- avrohugger-tools/src — 2 commits
Notable commits
- fix: * Added support for Fixed data type (for STANDARD format only) with logical type Decimal. No case class is generated for fixed - applied in place as BigDecimal. * Version of Scala for cross-compilation updated to 2.12.11 * Added test for Fixed data type.
- fix: Add support for fixed data type (with logical type decimal) for Standard and SpecificRecord formats. Logical type decimal is mapped to BigDecimal of Scala, and bare fixed is mapped to Array[Byte].
- fix: Bump dependency versions, fix tests
- fix: Fix #147 - Use a separate temp directory
- fix: Fix : standard : fixing import resolution for fixed types
- fix: Fix CI version matrix
- fix: Fix README.md example
- fix: Fix Specific bytes default param, Specific enum in union
- fix: Fix conflicts
- fix: Fix conflicts, generate FIXED bytes into case class wrapper
- fix: Fix for #176
- fix: Fix merge conflict by bumping version to SNAPSHOT
- fix: Fix merge conflicts
- fix: Fix remaining deprecation warnings, skip a few scavro tests
- fix: Fix some deprecation warnings
- fix: Fix test for Fixed datatype|
- fix: Fix tests
- fix: Fix this()-method for identical record name
- fix: Fix topological sort
- fix: Generate FIXED as named, top-level value class
- …and 280 more
Architecture
- 0 containers · 1 bounded contexts · 0 dependency edges (baseline)
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
julianpeeters/avrohugger was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 8aa3d6fd7eab478aff74bfe6a496249d4b97fe7f — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.