# orochasamuel/fiscalbr-net architecture

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

- Interactive diagram: https://gitdiagram.com/orochasamuel/fiscalbr-net
- Repository: https://github.com/orochasamuel/fiscalbr-net

## Overview

##### Main Components
- Core Library (FiscalBr.Common):
- Acts as the heart of the system.
- Contains shared classes, constants, enums, helper methods, attributes, and value objects that are inherited and used by the specialized libraries.
- Specialized Libraries/Modules:
- FiscalBr.Dimob: Manages DIMOB-related file headers and records.
- FiscalBr.ECF: Contains implementations for various “blocos” (sections) of the ECF (Escrituração Contábil Fiscal).
- FiscalBr.EFDContribuicoes: Handles the EFD Contribuições (formerly SPED Pis/Cofins).
- FiscalBr.EFDFiscal: Implements the structure for the EFD Fiscal, including many filing blocks.
- FiscalBr.Sintegra: Deals with Sintegra file formats.
- Test Suite:
- Located under the ‘tests’ folder, it ensures that each module and its interactions function as expected.

##### Relationships and Interactions
- The specialized libraries directly depend on and extend the core functionalities provided by FiscalBr.Common.
- Each fiscal module (Dimob, ECF, EFDContribuicoes, EFDFiscal, Sintegra) encapsulates its logic for generating file-specific records.
- The tests validate these modules by simulating the generation of files and verifying the outputs and error handling.

##### Important Architectural Patterns and Design Principles
- Layered Architecture:
- Base layer: FiscalBr.Common (domain definitions, common entities and base methods).
- Application layers: Each specialized fiscal module implements its own logic using the base layer.
- A separate testing layer validates each module.
- Use of Attributes and Interfaces:
- There are numerous attribute classes (for example, SpedCamposAttribute, DimobCamposAttribute) and interfaces (in the Sped folder) to enforce consistency in how records are created and written, ensuring loose coupling and extensibility.
- Separation of Concerns:
- Each project (or NuGet package) focuses on a specific domain of fiscal output, easing maintenance and independent versioning.

##### Relevant Technologies, Frameworks, or Libraries
- .NET platform (the solution is built in .NET, indicated by .csproj and solution files).
- NuGet: For packaging and distributing each library module.
- GitHub Actions/Workflows: For CI/CD (build-and-test, release-to-nuget), as seen in the .github folder.
- Unit testing frameworks integrated within the ‘tests’ directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Layer
    subgraph "Core Layer"
        C["FiscalBr.Common"]:::core
    end

    %% Specialized Modules Layer
    subgraph "Specialized Modules"
        D["FiscalBr.Dimob"]:::module
        E["FiscalBr.ECF"]:::module
        F["FiscalBr.EFDContribuicoes"]:::module
        G["FiscalBr.EFDFiscal"]:::module
        H["FiscalBr.Sintegra"]:::module
    end

    %% Testing Layer
    subgraph "Testing & CI/CD"
        T["Test Suite"]:::test
    end

    %% Dependencies from specialized modules to Core
    D -->|"depends"| C
    E -->|"depends"| C
    F -->|"depends"| C
    G -->|"depends"| C
    H -->|"depends"| C

    %% Test interactions with Core and all modules
    T -->|"tests"| C
    T -->|"tests"| D
    T -->|"tests"| E
    T -->|"tests"| F
    T -->|"tests"| G
    T -->|"tests"| H

    %% Click Events for mapped components
    click C "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.Common"
    click D "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.Dimob"
    click E "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.ECF"
    click F "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.EFDContribuicoes"
    click G "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.EFDFiscal"
    click H "https://github.com/orochasamuel/fiscalbr-net/blob/master/src/FiscalBr.Sintegra"
    click T "https://github.com/orochasamuel/fiscalbr-net/tree/master/tests"

    %% Styles
    classDef core fill:#a2d9ce,stroke:#2e4053,stroke-width:2px;
    classDef module fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef test fill:#f5b7b1,stroke:#c0392b,stroke-width:2px,stroke-dasharray: 5, 5;
```
