# andre-djsystem/modelagemrtc architecture

> Architecture diagram of the GitHub repository andre-djsystem/modelagemrtc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andre-djsystem/modelagemrtc
- Repository: https://github.com/andre-djsystem/modelagemrtc

## Overview

This repository is a Firebird SQL data model and resolver for choosing a cClassTrib during fiscal-document issuance. The principal workflow sends operation, product, issue date, document model, and participant to RESOLVE_CCLASSTRIB; it checks candidates in priority order, validates their validity period and document-model eligibility, and returns the classification and tax details. The README also documents NCM lookup for auditing and official-code, NCM-rule, and example-data loads. Source excerpts were unavailable, so relationships below are limited to those explicitly described in the README.

Main entry points: [`scripts/tabelas.sql`](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql) (Resolve cClassTrib)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_resolution["Resolution engine"]
  node_resolver["Resolve cClassTrib<br/>[tabelas.sql]"]
  node_validity["Validity check<br/>[tabelas.sql]"]
  node_modelcheck["Model check<br/>[tabelas.sql]"]
end

subgraph group_reference["Classification data"]
  node_top[("Operation type<br/>[tabelas.sql]")]
  node_topproduct[("Operation-product override<br/>[tabelas.sql]")]
  node_product[("Product and rule<br/>[tabelas.sql]")]
  node_participant[("Operation participant<br/>[tabelas.sql]")]
  node_mapping[("NCM/NBS rule mapping<br/>[tabelas.sql]")]
  node_official[("Official classifications<br/>[tabelas.sql]")]
end

subgraph group_audit["NCM audit"]
  node_ncmlookup["Lookup by NCM<br/>[tabelas.sql]"]
end

node_issuer(("Fiscal application"))
node_auditor(("Auditor or operator"))

node_issuer -->|"requests resolution"| node_resolver
node_resolver -->|"checks first"| node_top
node_resolver -->|"checks next"| node_topproduct
node_resolver -->|"checks next"| node_product
node_resolver -->|"checks fallback"| node_mapping
node_resolver -->|"matches participant"| node_participant
node_resolver -->|"validates candidates"| node_validity
node_resolver -->|"validates candidates"| node_modelcheck
node_resolver -->|"gets tax details"| node_official
node_auditor -->|"requests NCM lookup"| node_ncmlookup
node_ncmlookup -->|"lists applications"| node_mapping

click node_resolver "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_validity "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_modelcheck "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_top "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_topproduct "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_product "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_participant "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_mapping "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_official "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"
click node_ncmlookup "https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql"

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_resolver,node_validity,node_modelcheck toneBlue
class node_top,node_topproduct,node_product,node_participant,node_mapping,node_official toneAmber
class node_ncmlookup toneMint
class node_issuer,node_auditor toneIndigo
```

## Components

### Resolution engine

- [Resolve cClassTrib](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Validity check](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Model check](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`

### Classification data

- [Operation type](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Operation-product override](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Product and rule](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Operation participant](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [NCM/NBS rule mapping](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`
- [Official classifications](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`

### NCM audit

- [Lookup by NCM](https://github.com/andre-djsystem/modelagemrtc/blob/main/scripts/tabelas.sql): `scripts/tabelas.sql`

### Other components

- **Fiscal application**
- **Auditor or operator**

## Connections

- Fiscal application → Resolve cClassTrib: requests resolution (evidence: `README.md`)
- Resolve cClassTrib → Operation type: checks first (evidence: `README.md`)
- Resolve cClassTrib → Operation-product override: checks next (evidence: `README.md`)
- Resolve cClassTrib → Product and rule: checks next (evidence: `README.md`)
- Resolve cClassTrib → NCM/NBS rule mapping: checks fallback (evidence: `README.md`)
- Resolve cClassTrib → Operation participant: matches participant (evidence: `README.md`)
- Resolve cClassTrib → Validity check: validates candidates (evidence: `README.md`)
- Resolve cClassTrib → Model check: validates candidates (evidence: `README.md`)
- Resolve cClassTrib → Official classifications: gets tax details (evidence: `README.md`)
- Auditor or operator → Lookup by NCM: requests NCM lookup (evidence: `README.md`)
- Lookup by NCM → NCM/NBS rule mapping: lists applications (evidence: `README.md`)
