# oca/reporting-engine architecture

> Architecture diagram of the GitHub repository oca/reporting-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oca/reporting-engine
- Repository: https://github.com/oca/reporting-engine

## Overview

##### Main Components

a. Core Reporting Services:
- Base Report Engine Layer
- Report Format Handlers (PDF, CSV, XLSX, XML, etc.)
- Template Engine (QWeb, Py3o)
- SQL Query Engine

b. Specialized Report Modules:
- Business Intelligence Views
- Async Report Processing
- Security Features (Encryption, Signing)
- Export Services

c. Integration Components:
- Database Layer
- Odoo Core Integration
- External Services (LibreOffice, wkhtmltopdf)

**┌─ Presentation Layer ─────────────────────┐**
- Web Interface                          │
- Report Preview                         │
- Export Options                         │
- Business Logic Layer ───────────────────┤
- ┌─ Report Generation Services ─┐         │
- QWeb Engine               │         │
- XLSX Generator           │         │
- CSV Processor            │         │
- XML Builder              │         │
- ┘         │
- ┌─ Enhancement Services ──────┐         │
- PDF Watermarking         │         │
- Digital Signing          │         │
- Encryption              │         │
- ┘         │
- Data Access Layer ────────────────────┤
- SQL Request Abstract                  │
- BI View Editor                        │
- SQL Export                            │
- ┘

##### Connection Types

- Double lines: Data flow

##### Important Elements to Highlight

a. Module Relationships:
- How base_comment_template connects to other report modules
- Bi_sql_editor and bi_view_editor interaction
- Report_async's connection to various report types

b. Security Flow:
- Encryption/signing process flow
- Access control points
- Data validation checkpoints

c. External Dependencies:
- LibreOffice connection for report_py3o
- Database connectivity for SQL operations
- File system interaction for export operations

##### Implementation Details

Create subsections for:
- Template Management
- Report Generation Pipeline
- Export Processors
- Security Handlers

##### Notes

Annotations for:
- Critical paths
- Performance considerations
- Security checkpoints
- Scalability points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph PL[Presentation Layer]
        WI[Web Interface]
        RP[Report Preview]
        EO[Export Options]
    end

    subgraph BLL[Business Logic Layer]
        subgraph RGS[Report Generation Services]
            QE[QWeb Engine]
            XG["XLSX Generator"]:::xlsx
            CP["CSV Processor"]:::csv
            XB["XML Builder"]:::xml
            P3["Py3o Handler"]:::py3o
        end

        subgraph ES[Enhancement Services]
            WM["PDF Watermark"]:::watermark
            DS["Digital Signing"]:::signing
            EN["PDF Encryption"]:::encrypt
            PP["PDF Parameters"]:::params
            PC["PDF Cover"]:::cover
        end

        subgraph AUX[Auxiliary Services]
            RC["Report Context"]:::context
            RH["Report Helper"]:::helper
            XH["XLSX Helper"]:::xlsxhelper
            AR["Async Report"]:::async
            BT["Base Template"]:::template
        end
    end

    subgraph DAL[Data Access Layer]
        SRA["SQL Request Abstract"]:::sqlabs
        BVE["BI View Editor"]:::biview
        BSE["BI SQL Editor"]:::bisql
        SE["SQL Export"]:::sqlexport
        SEM["SQL Export Mail"]:::sqlmail
        SEE["SQL Export Excel"]:::sqlexcel
    end

    %% Connections
    WI --> RP
    RP --> EO

    %% Report Generation Connections
    QE --> WM
    QE --> DS
    QE --> EN
    XG --> EO
    CP --> EO
    XB --> EO
    P3 --> EO

    %% Enhancement Service Connections
    WM --> EO
    DS --> EO
    EN --> EO
    PP --> QE
    PC --> QE

    %% Auxiliary Connections
    RC --> QE
    RH --> QE
    XH --> XG
    AR --> |Async Processing| RGS
    BT --> QE

    %% Data Layer Connections
    SRA --> SE
    BVE --> BSE
    SE --> SEM
    SE --> SEE

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef csv fill:#97c2fc,stroke:#2d6ac7
    classDef xlsx fill:#97c2fc,stroke:#2d6ac7
    classDef xml fill:#97c2fc,stroke:#2d6ac7
    classDef py3o fill:#97c2fc,stroke:#2d6ac7
    classDef watermark fill:#ffb366,stroke:#cc7a00
    classDef signing fill:#ffb366,stroke:#cc7a00
    classDef encrypt fill:#ffb366,stroke:#cc7a00
    classDef params fill:#ffb366,stroke:#cc7a00
    classDef cover fill:#ffb366,stroke:#cc7a00
    classDef context fill:#b3b3cc,stroke:#666699
    classDef helper fill:#b3b3cc,stroke:#666699
    classDef xlsxhelper fill:#b3b3cc,stroke:#666699
    classDef async fill:#b3b3cc,stroke:#666699
    classDef template fill:#b3b3cc,stroke:#666699
    classDef sqlabs fill:#85e085,stroke:#33cc33
    classDef biview fill:#85e085,stroke:#33cc33
    classDef bisql fill:#85e085,stroke:#33cc33
    classDef sqlexport fill:#85e085,stroke:#33cc33
    classDef sqlmail fill:#85e085,stroke:#33cc33
    classDef sqlexcel fill:#85e085,stroke:#33cc33

    %% Click Events
    click CP "https://github.com/OCA/reporting-engine/tree/16.0/report_csv"
    click XG "https://github.com/OCA/reporting-engine/tree/16.0/report_xlsx"
    click XB "https://github.com/OCA/reporting-engine/tree/16.0/report_xml"
    click P3 "https://github.com/OCA/reporting-engine/tree/16.0/report_py3o"
    click BVE "https://github.com/OCA/reporting-engine/tree/16.0/bi_view_editor"
    click BSE "https://github.com/OCA/reporting-engine/tree/16.0/bi_sql_editor"
    click AR "https://github.com/OCA/reporting-engine/tree/16.0/report_async"
    click EN "https://github.com/OCA/reporting-engine/tree/16.0/report_qweb_encrypt"
    click DS "https://github.com/OCA/reporting-engine/tree/16.0/report_qweb_signer"
    click WM "https://github.com/OCA/reporting-engine/tree/16.0/report_qweb_pdf_watermark"
    click SRA "https://github.com/OCA/reporting-engine/tree/16.0/sql_request_abstract"
    click SE "https://github.com/OCA/reporting-engine/tree/16.0/sql_export"
    click SEE "https://github.com/OCA/reporting-engine/tree/16.0/sql_export_excel"
    click SEM "https://github.com/OCA/reporting-engine/tree/16.0/sql_export_mail"
    click BT "https://github.com/OCA/reporting-engine/tree/16.0/base_comment_template"
    click PP "https://github.com/OCA/reporting-engine/tree/16.0/report_qweb_parameter"
    click RC "https://github.com/OCA/reporting-engine/tree/16.0/report_context"
    click RH "https://github.com/OCA/reporting-engine/tree/16.0/report_generate_helper"
    click XH "https://github.com/OCA/reporting-engine/tree/16.0/report_xlsx_helper"
    click PC "https://github.com/OCA/reporting-engine/tree/16.0/report_qweb_pdf_cover"
```
