# datumbrain/nulltypes architecture

> Architecture diagram of the GitHub repository datumbrain/nulltypes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datumbrain/nulltypes
- Repository: https://github.com/datumbrain/nulltypes

## Overview

##### Project Type Analysis
This is a utility library/module that provides custom nullable data types for Go applications, specifically designed to work with SQL databases and JSON serialization. It's not a full application but rather a reusable component.

##### Key Components

A. Core Nullable Types Layer:
- NullString
- NullInt32
- NullInt64
- NullFloat64
- NullBool
- NullTime

B. Interface Layer:
- JSON Marshal/Unmarshal
- SQL Scanner/Valuer

C. External Integration Points:
- Database/SQL compatibility
- GORM compatibility
- JSON serialization
- Time zone handling

**┌─────────────────────────────────────────────┐**
- Client Application             │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Nulltypes Module                │
- ┬───────────────┬──────────┤
- Data Types    │  Interfaces   │ Time     │
- NullString  │  - JSON       │ Handling │
- NullInt32   │  - SQL        │ - UTC    │
- NullInt64   │              │ - Custom │
- NullFloat64 │              │  Zones   │
- NullBool    │              │          │
- NullTime    │              │          │
- ┴───────────────┴──────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- External Systems Integration          │
- ┬─────────────┬────────────────┤
- Database  │    GORM     │      JSON      │
- (SQL)    │            │  Serialization │
- ┴─────────────┴────────────────┘

##### Important Elements to Highlight
- Bidirectional relationship with database/sql package
- JSON marshalling/unmarshalling capability
- Time zone handling functionality
- GORM compatibility

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        App[Application Code]
    end

    subgraph NullTypes["Nulltypes Module"]
        subgraph DataTypes["Core Data Types"]
            NS["NullString"]
            NI32["NullInt32"]
            NI64["NullInt64"]
            NF64["NullFloat64"]
            NB["NullBool"]
            NT["NullTime"]
        end

        subgraph Interfaces["Interface Layer"]
            JSON["JSON Marshal/Unmarshal"]
            SQL["SQL Scanner/Valuer"]
        end

        subgraph TimeHandling["Time Handling"]
            TZ["Time Zone Management"]
            UTC["UTC Default"]
        end
    end

    subgraph External["External Systems"]
        DB[(Database)]
        GORM["GORM ORM"]
        JSONSer["JSON Serialization"]
    end

    %% Relationships
    App --> NS & NI32 & NI64 & NF64 & NB & NT
    NS & NI32 & NI64 & NF64 & NB & NT --> JSON
    NS & NI32 & NI64 & NF64 & NB & NT --> SQL
    NT --> TZ
    TZ --> UTC
    SQL --> DB
    SQL --> GORM
    JSON --> JSONSer

    %% Click Events
    click NS "https://github.com/datumbrain/nulltypes/blob/master/string.go"
    click NI32 "https://github.com/datumbrain/nulltypes/blob/master/int32.go"
    click NI64 "https://github.com/datumbrain/nulltypes/blob/master/int64.go"
    click NF64 "https://github.com/datumbrain/nulltypes/blob/master/float64.go"
    click NB "https://github.com/datumbrain/nulltypes/blob/master/bool.go"
    click NT "https://github.com/datumbrain/nulltypes/blob/master/time.go"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef dataType fill:#d4e6f1,stroke:#2874a6
    classDef interface fill:#d4efdf,stroke:#27ae60
    classDef external fill:#f9e79f,stroke:#d35400
    classDef time fill:#e8daef,stroke:#8e44ad

    class NS,NI32,NI64,NF64,NB,NT dataType
    class JSON,SQL interface
    class DB,GORM,JSONSer external
    class TZ,UTC time

    %% Legend
    subgraph Legend
        DT["Data Types"]:::dataType
        IF["Interfaces"]:::interface
        EX["External Systems"]:::external
        TM["Time Management"]:::time
    end
```
