# felipemarciano/orceipdf architecture

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

- Interactive diagram: https://gitdiagram.com/felipemarciano/orceipdf
- Repository: https://github.com/felipemarciano/orceipdf

## Overview

##### Project Type and Purpose
- This is a full-stack .NET application designed to generate PDF documents for budgets (“orçamentos”).
- The application follows a layered architecture with clear separations between presentation, application logic, domain, and data persistence.

##### File Structure
- The top-level projects (directories) indicate major layers:
- OrceiPdf.Web: Represents the presentation/UI layer (MVC controllers, views, view components, static assets, and configurations).
- OrceiPdf.Application: Contains business services and interfaces that encapsulate application logic.
- OrceiPdf.Domain: Holds domain models, enumerations, and domain interfaces which express the business rules and relationships.
- OrceiPdf.Repository: Implements repositories and Unit of Work patterns to interact with the database (including Entity Framework DbContext and migrations).
- OrceiPdf.IoC: Centralizes dependency injection configuration ensuring proper wiring of components.
- Notice also the presence of external tools/files for generating PDFs (under wkhtmltopdf) and several third-party libraries in the wwwroot folder (e.g., jQuery, Bootstrap, DataTables).

##### Using the README for Additional Insights

a. Main Components:
- Presentation Layer (OrceiPdf.Web):
- MVC Controllers (e.g., AccountController, ClienteController, EmpresaController, etc.).
- Views and View Components (e.g., components for ModalCrud, OrcamentoPdf, etc.).
- Frontend assets (CSS, JavaScript, libraries for UI/UX).
- PDF Generation integration (wkhtmltopdf executable).
- Application Layer (OrceiPdf.Application):
- Business services (ClienteService, EmpresaService, OrcamentoService, etc.) implementing business rules and coordinating actions.
- Service interfaces (IClienteService, IEmpresaService, etc.).
- Domain Layer (OrceiPdf.Domain):
- Domain models (Cliente, Empresa, Orcamento, OrcamentoItem, Produto, etc.).
- Business logic enums and base entities.
- Domain interfaces (IAsyncRepository, IUnitOfWork, etc.) to define core contracts.
- Data/Repository Layer (OrceiPdf.Repository):
- Repositories implementing data access for each domain entity.
- DbContext (OrceiPdfDbContext) and UnitOfWork classes to manage transactions.
- Database migrations indicating use of an ORM (likely Entity Framework).
- Dependency Injection (OrceiPdf.IoC):
- IoC container setup that binds the interfaces to their implementations across layers.
- External Services/Integrations:
- Utilization of third-party libraries (Bootstrap, jQuery, DataTables, Select2, etc.) from the wwwroot folder.

b. Relationships and Interactions:
- The Web layer (presentation) interacts with the Application services. For example, controllers call methods on ClienteService or OrcamentoService.
- The Application layer, in turn, leverages Domain models to enforce business rules.
- The Repository layer acts as the data access gateway and is accessed by either the Application layer or Domain-driven patterns; typically, infrastructure components are accessed indirectly via service or via dependency injection.
- The IoC container configures and injects these dependencies.
- External PDF generation (using wkhtmltopdf) is likely called from a specific PdfController or service within the Web layer.

c. Architectural Patterns and Technologies:
- Layered/Hexagonal Architecture: Clear separation between UI, business logic, domain, and persistence.
- Repository and Unit of Work: Abstract data access logic.
- Dependency Injection via IoC (centralized in OrceiPdf.IoC).
- MVC design for the Web project components.
- Use of external libraries for UI enhancement and PDF generation.
- Integration with Entity Framework for managing the relational database (inferred from DbContext and migrations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (OrceiPdf.Web)"
        P("OrceiPdf.Web (Presentation)"):::frontend
        PC("MVC Controllers"):::controllers
        V("Views"):::views
        VC("View Components"):::views
        FA("Frontend Assets"):::assets
        WK("wkhtmltopdf"):::external
    end

    %% Application Layer
    subgraph "Application Layer (OrceiPdf.Application)"
        A("OrceiPdf.Application (Business Services & Interfaces)"):::application
        SI("Service Interfaces"):::interfaces
        BS("Business Services"):::services
    end

    %% Domain Layer
    subgraph "Domain Layer (OrceiPdf.Domain)"
        D("OrceiPdf.Domain (Domain Models & Business Rules)"):::domain
        DM("Domain Models"):::models
        DE("Domain Interfaces & Enums"):::interfaces
    end

    %% Repository Layer
    subgraph "Repository Layer (OrceiPdf.Repository)"
        R("OrceiPdf.Repository (Data Access)"):::repository
        DB("OrceiPdfDbContext (EF DbContext)"):::database
        REP("Repositories"):::repository
        UOW("Unit Of Work"):::business
    end

    %% IoC / DI Container
    subgraph "IoC Container (OrceiPdf.IoC)"
        IoC("IoC Container & DI Setup"):::ioc
    end

    %% Connections between Presentation components
    PC -->|"calls"| BS
    PC -->|"calls"| WK
    PC --> V
    PC --> VC

    %% Application layer internal relation
    SI --> BS

    %% Connections from Application to Domain and Repository
    BS -->|"uses"| DM
    BS -->|"accesses"| REP

    %% Domain internal relation
    DM ---|"collaborates"| DE

    %% Repository internal relation
    DB --> REP
    REP --> UOW

    %% IoC wiring to layers
    IoC --- PC
    IoC --- SI
    IoC --- BS
    IoC --- REP
    IoC --- UOW
    IoC --- DB

    %% Click Events - Presentation Layer
    click P "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Web"
    click PC "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Web/Controllers"
    click V "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Web/Views"
    click VC "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Web/ViewComponents"
    click FA "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Web/wwwroot"
    click WK "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Web/wkhtmltopdf"

    %% Click Events - Application Layer
    click A "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Application"
    click SI "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Application/Interfaces"
    click BS "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Application/Services"

    %% Click Events - Domain Layer
    click D "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Domain"
    click DM "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Domain/Models"
    click DE "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Domain/Interfaces"

    %% Click Events - Repository Layer
    click R "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Repository"
    click DB "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Repository/Context/OrceiPdfDbContext.cs"
    click REP "https://github.com/felipemarciano/orceipdf/tree/main/OrceiPdf.Repository/Repository"
    click UOW "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.Repository/UoW/UnitOfWork.cs"

    %% Click Event - IoC Container
    click IoC "https://github.com/felipemarciano/orceipdf/blob/main/OrceiPdf.IoC/NativeInjectorBootStrapper.cs"

    %% Styles
    classDef frontend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef controllers fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef views fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef assets fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
    classDef application fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef interfaces fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
    classDef services fill:#d6d8db,stroke:#343a40,stroke-width:2px;
    classDef domain fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef models fill:#c3e6cb,stroke:#155724,stroke-width:2px;
    classDef repository fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef business fill:#d6d8db,stroke:#343a40,stroke-width:2px;
    classDef ioc fill:#e2e3e5,stroke:#383d41,stroke-width:2px;
```
