# havanlabsrfid/serializadorrfid architecture

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

- Interactive diagram: https://gitdiagram.com/havanlabsrfid/serializadorrfid
- Repository: https://github.com/havanlabsrfid/serializadorrfid

## Overview

##### Project type and purpose
- This is a C# class-library project (“CriptografiaRFID”) that implements GS1 EPC (Electronic Product Code) RFID serialization and deserialization algorithms, plus a simple console application (“Exemplo”) that consumes the library.
- Purpose: Given GS1 parameters (e.g. barcode, serial, partition) produce an EPC code in hex or parse an EPC back to GS1 fields.

##### File structure
- Top-level solution (.sln) contains two projects:
- CriptografiaRFID (class-library)
– Constantes: GS1 partition headers and default partition settings.
– DTO: simple DTO for EPC results.
– Helper: utility classes (barcode formatting, converters).
– EpcHelper.cs: entry point for serialization/deserialization methods.
– Interfaces: IGS1 defines generic GS1 serialization API.
– Modelos: concrete GS1 model classes (SGTIN_96, GRAI_96, GIAI_96) plus GS1 defaults.
– Properties, project/VS config files.
- Exemplo (console app)
– References CriptografiaRFID, shows usage of SerializarSgtin, SerializarGenerico, GetGS1.

##### README for additional insights
- README calls out the two main operations: SerializarSgtin(barcode, serial, partition) and SerializarGenerico(Parametro : GS1).
- Deserialization via GetGS1(epcHexadecimal).
- Links to external GS1 EPC standard documentation.

##### Detailed component breakdown
- Exemplo (Console App)
- EpcHelper
- SerializarSgtin(barcode, serial, partition)
- SerializarGenerico(Parametro)
- GetGS1(epcHex)
- HelperBarcode: barcode format/validate
- HelperConverter: numeric/bit conversions
- IGS1 Interface: Serialize(), Deserialize()
- SGTIN_96, GRAI_96, GIAI_96: algorithm implementations
- Constants: EpcHeaders, Partition definitions
- EPCSimplesDTO: fields for resulting EPC metadata

##### Final advice
- Data flow from input parameters through each layer to the final hex string or DTO.
- Use consistent iconography: folders/packages, classes, interfaces.
- Keep the Facade prominent to show how a consumer interacts with the library.
- Extensibility: show where new GS1 schemes could plug in (via IGS1).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client"
        Exemplo["Exemplo (Program.cs)"]:::client
    end

    %% Core Library Project
    CoreProj["CriptografiaRFID.csproj"]:::project

    %% CriptografiaRFID Library
    subgraph "CriptografiaRFID Library"
        %% Facade Layer
        EpcHelper["EpcHelper"]:::facade

        %% Utilities Layer
        subgraph "Utilities"
            HelperBarcode["HelperBarcode"]:::utility
            HelperConverter["HelperConverter"]:::utility
        end

        %% Interfaces Layer
        subgraph "Interfaces"
            IGS1["IGS1"]:::interface
        end

        %% Models Layer
        subgraph "Models"
            SGTIN_96["SGTIN_96"]:::model
            GRAI_96["GRAI_96"]:::model
            GIAI_96["GIAI_96"]:::model
        end

        %% Constants Layer
        subgraph "Constants"
            DefaultPartition["DefaultPartition"]:::constant
            EpcHeaders["EpcHeaders"]:::constant
            SGTINPartition["SGTINPartition"]:::constant
            GRAIPartition["GRAIPartition"]:::constant
            GIAIPartition["GIAIPartition"]:::constant
        end

        %% GS1 Defaults
        subgraph "GS1 Defaults"
            GS1Headers["Headers"]:::constant
            GS1Partition["Partition"]:::constant
            GS1DefaultsGS1["GS1"]:::constant
        end

        %% DTO Layer
        subgraph "DTO"
            EPCSimplesDTO["EPCSimplesDTO"]:::dto
        end
    end

    %% External Documentation
    GS1Doc["GS1 EPC Standard"]:::external

    %% Relationships
    Exemplo -->|calls SerializarSgtin/SerializarGenerico/GetGS1| EpcHelper
    EpcHelper -->|uses validate| HelperBarcode
    EpcHelper -->|uses convert| HelperConverter
    EpcHelper -->|implements via| IGS1
    SGTIN_96 -->|implements| IGS1
    GRAI_96 -->|implements| IGS1
    GIAI_96 -->|implements| IGS1
    SGTIN_96 -->|reads| DefaultPartition
    SGTIN_96 -->|reads| SGTINPartition
    SGTIN_96 -->|reads| EpcHeaders
    GRAI_96 -->|reads| DefaultPartition
    GRAI_96 -->|reads| GRAIPartition
    GRAI_96 -->|reads| EpcHeaders
    GIAI_96 -->|reads| DefaultPartition
    GIAI_96 -->|reads| GIAIPartition
    GIAI_96 -->|reads| EpcHeaders
    EpcHelper -->|packages result into| EPCSimplesDTO
    EPCSimplesDTO -->|returns| Exemplo
    EpcHelper -->|references| GS1Doc
    CoreProj -.-> EpcHelper

    %% Click Events
    click Exemplo "https://github.com/havanlabsrfid/serializadorrfid/blob/master/Exemplo/Program.cs"
    click CoreProj "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/CriptografiaRFID.csproj"
    click EpcHelper "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/EpcHelper.cs"
    click HelperBarcode "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Helper/HelperBarcode.cs"
    click HelperConverter "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Helper/HelperConverter.cs"
    click IGS1 "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Interfaces/IGS1.cs"
    click SGTIN_96 "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/EPC/SGTIN_96.cs"
    click GRAI_96 "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/EPC/GRAI_96.cs"
    click GIAI_96 "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/EPC/GIAI_96.cs"
    click DefaultPartition "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Constantes/DefaultPartition.cs"
    click EpcHeaders "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Constantes/EpcHeaders.cs"
    click SGTINPartition "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Constantes/SGTINPartition.cs"
    click GRAIPartition "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Constantes/GRAIPartition.cs"
    click GIAIPartition "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Constantes/GIAIPartition.cs"
    click GS1Headers "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/Gs1Defaults/Headers.cs"
    click GS1Partition "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/Gs1Defaults/Partition.cs"
    click GS1DefaultsGS1 "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/Modelos/Gs1Defaults/GS1.cs"
    click EPCSimplesDTO "https://github.com/havanlabsrfid/serializadorrfid/blob/master/CriptografiaRFID/DTO/EPCSimplesDTO.cs"

    %% Styles
    classDef facade fill:#add8e6,stroke:#000000
    classDef utility fill:#90ee90,stroke:#000000
    classDef interface fill:#dda0dd,stroke:#000000
    classDef model fill:#ffa500,stroke:#000000
    classDef constant fill:#d3d3d3,stroke:#000000
    classDef dto fill:#ffffff,stroke:#000000
    classDef external fill:#87cefa,stroke:#000000
    classDef client fill:#f0f8ff,stroke:#000000
    classDef project fill:#e6e6fa,stroke:#000000
```
