# discordando/ivorosa-erp-backend architecture

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

- Interactive diagram: https://gitdiagram.com/discordando/ivorosa-erp-backend
- Repository: https://github.com/discordando/ivorosa-erp-backend

## Overview

IvoRosa ERP is a manufacturing and order-fulfillment backend with customer, product-model and dimension management, order lifecycle controls, and Brazilian NF-e issuance. The main workflow enters through the REST API, where application services create and manage orders, persist them through repository implementations, and can orchestrate invoice issuance through the Focus NFe gateway. The README documents additional fiscal lifecycle and industrial state-machine capabilities; unsampled subsystem links are omitted where source evidence is unavailable.

Main entry points: [`IvoRosa.Api`](https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Api) (REST Controllers), [`IvoRosa.Infrastructure/Data/AppDbContext.cs`](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Infrastructure/Data/AppDbContext.cs) (PostgreSQL Database), [`IvoRosa.Infrastructure/Repositories`](https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Infrastructure/Repositories) (Repository Adapters), [`IvoRosa.Application/Services/CustomerService.cs`](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/CustomerService.cs) (Customer Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_http["REST Controllers<br/>[IvoRosa.Api]"]
end

subgraph group_application["Application Workflows"]
  node_customers["Customer Management<br/>[CustomerService.cs]"]
  node_orders["Order Fulfillment<br/>[OrderService.cs]"]
  node_catalog["Models &amp; Dimensions<br/>[Services]"]
  node_invoicing["Invoice Orchestration<br/>[InvoiceService.cs]"]
end

subgraph group_domain["Business Domain"]
  node_customer_entity["Customer &amp; Address<br/>[Customer.cs]"]
  node_order_entity["Orders &amp; Items<br/>[Order.cs]"]
  node_catalog_entity["Vase Models &amp; Sizes<br/>[VaseModel.cs]"]
  node_invoice_entity["Invoice State<br/>[Invoice.cs]"]
end

subgraph group_infrastructure["Persistence &amp; Fiscal"]
  node_repositories["Repository Adapters<br/>[Repositories]"]
  node_database[("PostgreSQL Database<br/>[AppDbContext.cs]")]
  node_fiscal_client["Focus NFe Client<br/>[FocusNfeClient.cs]"]
end

node_user(("API Client"))
node_focus{{"Focus NFe / SEFAZ"}}

node_user -->|"sends requests"| node_http
node_http -->|"delegates customer"| node_customers
node_http -->|"delegates orders"| node_orders
node_http -->|"delegates catalog"| node_catalog
node_http -->|"delegates dimensions"| node_catalog
node_http -->|"delegates invoices"| node_invoicing
node_customers -->|"uses repositories"| node_repositories
node_orders -->|"loads and saves"| node_repositories
node_invoicing -->|"uses repositories"| node_repositories
node_invoicing -->|"requests fiscal work"| node_fiscal_client
node_repositories -->|"accesses entities"| node_database
node_fiscal_client -->|"sends NF-e requests"| node_focus
node_orders -->|"creates and updates"| node_order_entity
node_customers -->|"maps customer data"| node_customer_entity
node_database -->|"persists entities"| node_order_entity
node_database -->|"persists entities"| node_customer_entity
node_database -->|"persists entities"| node_catalog_entity
node_database -->|"persists entities"| node_invoice_entity
node_fiscal_client -->|"builds invoice payload"| node_order_entity

click node_http "https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Api"
click node_customers "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/CustomerService.cs"
click node_orders "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/OrderService.cs"
click node_catalog "https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Application/Services"
click node_invoicing "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/InvoiceService.cs"
click node_customer_entity "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Customer.cs"
click node_order_entity "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Order.cs"
click node_catalog_entity "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/VaseModel.cs"
click node_invoice_entity "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Invoice.cs"
click node_repositories "https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Infrastructure/Repositories"
click node_database "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Infrastructure/Data/AppDbContext.cs"
click node_fiscal_client "https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Infrastructure/External/FocusNfeClient.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_http,node_user toneBlue
class node_customers,node_orders,node_catalog,node_invoicing toneAmber
class node_customer_entity,node_order_entity,node_catalog_entity,node_invoice_entity toneMint
class node_repositories,node_database,node_fiscal_client toneRose
class node_focus toneIndigo
```

## Components

### HTTP API

- [REST Controllers](https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Api): `IvoRosa.Api`

### Application Workflows

- [Customer Management](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/CustomerService.cs): `IvoRosa.Application/Services/CustomerService.cs`
- [Order Fulfillment](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/OrderService.cs): `IvoRosa.Application/Services/OrderService.cs`
- [Models & Dimensions](https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Application/Services): `IvoRosa.Application/Services`
- [Invoice Orchestration](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Application/Services/InvoiceService.cs): `IvoRosa.Application/Services/InvoiceService.cs`

### Business Domain

- [Customer & Address](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Customer.cs): `IvoRosa.Domain/Entities/Customer.cs`
- [Orders & Items](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Order.cs): `IvoRosa.Domain/Entities/Order.cs`
- [Vase Models & Sizes](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/VaseModel.cs): `IvoRosa.Domain/Entities/VaseModel.cs`
- [Invoice State](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Domain/Entities/Invoice.cs): `IvoRosa.Domain/Entities/Invoice.cs`

### Persistence & Fiscal

- [Repository Adapters](https://github.com/discordando/ivorosa-erp-backend/tree/main/IvoRosa.Infrastructure/Repositories): `IvoRosa.Infrastructure/Repositories`
- [PostgreSQL Database](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Infrastructure/Data/AppDbContext.cs): `IvoRosa.Infrastructure/Data/AppDbContext.cs`
- [Focus NFe Client](https://github.com/discordando/ivorosa-erp-backend/blob/main/IvoRosa.Infrastructure/External/FocusNfeClient.cs): `IvoRosa.Infrastructure/External/FocusNfeClient.cs`

### Other components

- **API Client**
- **Focus NFe / SEFAZ**

## Connections

- API Client → REST Controllers: sends requests (evidence: `IvoRosa.Api/Order/OrderController.cs`)
- REST Controllers → Customer Management: delegates customer (evidence: `IvoRosa.Api/Customer/CustomerController.cs`)
- REST Controllers → Order Fulfillment: delegates orders (evidence: `IvoRosa.Api/Order/OrderController.cs`)
- REST Controllers → Models & Dimensions: delegates catalog (evidence: `IvoRosa.Api/VaseModel/VaseModelController.cs`)
- REST Controllers → Models & Dimensions: delegates dimensions (evidence: `IvoRosa.Api/Dimension/DimensionController.cs`)
- REST Controllers → Invoice Orchestration: delegates invoices (evidence: `IvoRosa.Api/InvoiceController/InvoiceController.cs`)
- Customer Management → Repository Adapters: uses repositories (evidence: `IvoRosa.Application/Services/CustomerService.cs`)
- Order Fulfillment → Repository Adapters: loads and saves (evidence: `IvoRosa.Application/Services/OrderService.cs`)
- Invoice Orchestration → Repository Adapters: uses repositories (evidence: `IvoRosa.Application/Services/InvoiceService.cs`)
- Invoice Orchestration → Focus NFe Client: requests fiscal work (evidence: `IvoRosa.Application/Services/InvoiceService.cs`)
- Repository Adapters → PostgreSQL Database: accesses entities (evidence: `IvoRosa.Infrastructure/Repositories/OrderRepository.cs`)
- Focus NFe Client → Focus NFe / SEFAZ: sends NF-e requests (evidence: `IvoRosa.Infrastructure/External/FocusNfeClient.cs`)
- Order Fulfillment → Orders & Items: creates and updates (evidence: `IvoRosa.Application/Services/OrderService.cs`)
- Customer Management → Customer & Address: maps customer data (evidence: `IvoRosa.Application/Services/CustomerService.cs`)
- PostgreSQL Database → Orders & Items: persists entities (evidence: `IvoRosa.Infrastructure/Data/AppDbContext.cs`)
- PostgreSQL Database → Customer & Address: persists entities (evidence: `IvoRosa.Infrastructure/Data/AppDbContext.cs`)
- PostgreSQL Database → Vase Models & Sizes: persists entities (evidence: `IvoRosa.Infrastructure/Data/AppDbContext.cs`)
- PostgreSQL Database → Invoice State: persists entities (evidence: `IvoRosa.Infrastructure/Data/AppDbContext.cs`)
- Focus NFe Client → Orders & Items: builds invoice payload (evidence: `IvoRosa.Infrastructure/External/FocusNfeClient.cs`)
