# whitebeardit/next-cnpj architecture

> Architecture diagram of the GitHub repository whitebeardit/next-cnpj, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/whitebeardit/next-cnpj
- Repository: https://github.com/whitebeardit/next-cnpj

## Overview

next-CNPJ is a .NET library for validating traditional numeric and NTC 2025.001 alphanumeric CNPJ identifiers. A caller submits an identifier to the validator, which normalizes it, checks length and structure, identifies its format, applies configurable excluded-letter rules, and verifies check digits; it returns a detailed result or a boolean. The library also exposes format identification and CNPJ mask formatting as separate utilities. The graph reflects the sampled implementation and README; unsampled modules are not assumed to have additional runtime connections.

Main entry points: [`next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs) (CNPJ validator), [`next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs`](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs) (Format identifier), [`next-CNPJ/next-CNPJ/Core/Utilities/CnpjNormalizer.cs`](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/CnpjNormalizer.cs) (CNPJ normalizer), [`next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs`](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs) (Validation result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Validation API"]
  node_validator["CNPJ validator<br/>[CnpjValidator.cs]"]
  node_validator_interface["Validator contract<br/>[ICnpjValidator.cs]"]
  node_identifier["Format identifier"]
  node_identifier_interface["Identifier contract"]
end

subgraph group_domain["Validation Domain"]
  node_config["Validation configuration"]
  node_result["Validation result"]
  node_format["CNPJ format enum<br/>[CnpjFormat.cs]"]
end

subgraph group_utilities["CNPJ Utilities"]
  node_normalizer["CNPJ normalizer<br/>[CnpjNormalizer.cs]"]
  node_formatter["Mask formatter<br/>[CnpjFormatter.cs]"]
  node_calculator["Check-digit calculator"]
  node_ascii["ASCII converter<br/>[AsciiConverter.cs]"]
end

node_consumer(("Library caller"))

node_consumer -->|"submits CNPJ"| node_validator
node_validator -->|"normalizes input"| node_normalizer
node_validator -->|"identifies format"| node_identifier
node_validator -->|"checks letter rules"| node_config
node_validator -->|"validates digits"| node_calculator
node_validator -->|"returns details"| node_result
node_validator -->|"implements contract"| node_validator_interface
node_identifier -->|"normalizes input"| node_normalizer
node_identifier -->|"implements contract"| node_identifier_interface
node_identifier -->|"returns format"| node_format
node_result -->|"stores format"| node_format
node_formatter -->|"normalizes input"| node_normalizer
node_calculator -->|"converts characters"| node_ascii

click node_validator "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs"
click node_validator_interface "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/ICnpjValidator.cs"
click node_identifier "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs"
click node_identifier_interface "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/ICnpjFormatIdentifier.cs"
click node_config "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjConfiguration.cs"
click node_result "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs"
click node_format "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjFormat.cs"
click node_normalizer "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/CnpjNormalizer.cs"
click node_formatter "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/CnpjFormatter.cs"
click node_calculator "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/DigitVerifierCalculator.cs"
click node_ascii "https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/AsciiConverter.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_validator,node_validator_interface,node_identifier,node_identifier_interface toneBlue
class node_config,node_result,node_format toneAmber
class node_normalizer,node_formatter,node_calculator,node_ascii toneMint
class node_consumer toneIndigo
```

## Components

### Validation API

- [CNPJ validator](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs): `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`
- [Validator contract](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/ICnpjValidator.cs): `next-CNPJ/next-CNPJ/Core/Services/ICnpjValidator.cs`
- [Format identifier](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs): `next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs`
- [Identifier contract](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Services/ICnpjFormatIdentifier.cs): `next-CNPJ/next-CNPJ/Core/Services/ICnpjFormatIdentifier.cs`

### Validation Domain

- [Validation configuration](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjConfiguration.cs): `next-CNPJ/next-CNPJ/Core/Domain/CnpjConfiguration.cs`
- [Validation result](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs): `next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs`
- [CNPJ format enum](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Domain/CnpjFormat.cs): `next-CNPJ/next-CNPJ/Core/Domain/CnpjFormat.cs`

### CNPJ Utilities

- [CNPJ normalizer](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/CnpjNormalizer.cs): `next-CNPJ/next-CNPJ/Core/Utilities/CnpjNormalizer.cs`
- [Mask formatter](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/CnpjFormatter.cs): `next-CNPJ/next-CNPJ/Core/Utilities/CnpjFormatter.cs`
- [Check-digit calculator](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/DigitVerifierCalculator.cs): `next-CNPJ/next-CNPJ/Core/Utilities/DigitVerifierCalculator.cs`
- [ASCII converter](https://github.com/whitebeardit/next-cnpj/blob/main/next-CNPJ/next-CNPJ/Core/Utilities/AsciiConverter.cs): `next-CNPJ/next-CNPJ/Core/Utilities/AsciiConverter.cs`

### Other components

- **Library caller**

## Connections

- Library caller → CNPJ validator: submits CNPJ (evidence: `README.md`)
- CNPJ validator → CNPJ normalizer: normalizes input (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- CNPJ validator → Format identifier: identifies format (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- CNPJ validator → Validation configuration: checks letter rules (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- CNPJ validator → Check-digit calculator: validates digits (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- CNPJ validator → Validation result: returns details (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- CNPJ validator → Validator contract: implements contract (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjValidator.cs`)
- Format identifier → CNPJ normalizer: normalizes input (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs`)
- Format identifier → Identifier contract: implements contract (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs`)
- Format identifier → CNPJ format enum: returns format (evidence: `next-CNPJ/next-CNPJ/Core/Services/CnpjFormatIdentifier.cs`)
- Validation result → CNPJ format enum: stores format (evidence: `next-CNPJ/next-CNPJ/Core/Domain/CnpjValidationResult.cs`)
- Mask formatter → CNPJ normalizer: normalizes input (evidence: `next-CNPJ/next-CNPJ/Core/Utilities/CnpjFormatter.cs`)
- Check-digit calculator → ASCII converter: converts characters (evidence: `next-CNPJ/next-CNPJ/Core/Utilities/DigitVerifierCalculator.cs`)
