Struct Decomposition for Go. Type-Safe Without T.

Break structs into typed maps so infrastructure code can read, write, and transform fields without importing your types.

Get Started
import "github.com/zoobz-io/atom"

type User struct {
    ID      string
    Name    string
    Age     int64
    Balance float64
    Active  bool
}

atomizer, _ := atom.Use[User]()
a := atomizer.Atomize(&User{
    ID: "usr-1", Name: "Alice", Age: 30, Balance: 100.50, Active: true,
})

// Type-segregated maps — no interface{}, no reflection at access time
a.Strings["ID"]      // "usr-1"
a.Strings["Name"]    // "Alice"
a.Ints["Age"]        // 30
a.Floats["Balance"]  // 100.50
a.Bools["Active"]    // true

// Infrastructure code never imports User
storage.Save(a)          // storage works with typed maps
validator.Check(a)       // validator reads fields directly
migrator.Upgrade(a)      // migrator transforms field-by-field

// Reconstruct when you need the original type back
restored, _ := atomizer.Deatomize(a)
96%Test Coverage
A+Go Report
MITLicense
1.24+Go Version
v1.0.2Latest Release

Why Atom?

The bridge between your domain types and the infrastructure that operates on them.

Type Segregation

Fields sorted into Strings, Ints, Floats, Bools, Times, Bytes. Each map carries only its type — no interface{} maps.

Infrastructure Decoupling

Libraries accept atoms, not your structs. Storage, validation, and migration work without importing domain types.

Spec-Driven Introspection

Query field names, types, and table assignments at runtime. Know your data shape without the original struct.

Width Normalization

int8 through int64 all land in Ints. float32 and float64 in Floats. Overflow detected on reconstruction.

Three Performance Paths

Reflection for convenience, interfaces for control, code generation for speed. Same API, same result.

Nested Composition

Recursive atoms for complex object graphs. Each nested level carries its own Spec and typed maps.

Capabilities

Decompose, inspect, transform, and reconstruct Go structs through typed maps.

FeatureDescriptionLink
AtomizeDecompose any struct into typed maps with a single call. Registration is cached per type.Quickstart
DeatomizeReconstruct the original struct from an atom with width overflow detection.Basic Usage
Custom InterfacesImplement Atomizable/Deatomizable for computed fields, encryption, or schema migration.Interfaces
Named Typestype UserID string, type Status int — semantics preserved through round-trip decomposition.Custom Types
Nullable FieldsSeparate pointer tables with explicit nil handling. StringPtrs, IntPtrs, and friends.Tables
Field IntrospectionFields(), FieldsIn(table), TableFor(field), Spec() — full runtime queryability of your type layout.API

Articles

Browse the full atom documentation.

OverviewType-segregated atomic value decomposition for Go structs

Learn

QuickstartGet started with atom in 5 minutes
Core ConceptsUnderstanding atoms, tables, specs, and atomizers
ArchitectureInternal design and implementation of atom

Guides

Basic UsageCommon patterns for registration, atomization, and deatomization
Custom TypesWorking with named types, enums, and byte arrays
Nested StructsWorking with embedded and nested struct types
InterfacesCustom serialization with Atomizable and Deatomizable interfaces
TestingTesting strategies for atom-based code

Cookbook

Code GenerationEliminating reflection overhead with generated implementations
SerializationEncoding atoms for storage and transmission
Schema MigrationsHandling evolving data structures and backwards compatibility

Reference

API ReferenceComplete API documentation for the atom package
Tables ReferenceComplete reference for all storage table types
Testing ReferenceTest utilities and helpers for atom-based applications