LogicPaper is a high-performance document generation engine designed to automate complex reporting and contract workflows. It merges structured data (Excel/JSON) with Microsoft Office templates (.docx, .pptx) or text-based files (.md, .txt) using an advanced Jinja2-based strategy system.
The application follows an Enterprise Architecture (Hexagonal Architecture), utilizing FastAPI for high-concurrency requests, Redis for state management, and LibreOffice Headless for reliable PDF conversion.
Drag & Drop interface with real-time process logs.
Built-in guide for templating syntax.
- Asynchronous Batch Processing: Handles large datasets via background workers to prevent request timeouts.
- Multi-Format Support: Native rendering for Word, PowerPoint, Markdown, and Plain Text.
- Enterprise Integration API: Dedicated headless endpoints with X-API-Key authentication for ERP/CRM integration.
- State Persistence: Job tracking and session management powered by Redis.
- Complex Formatting Strategies: Custom filters for text manipulation, date arithmetic, localized currency, and conditional logic.
- Dynamic Asset Management: Automatic extraction, insertion, and resizing of images from ZIP archives.
- PDF Engine: Integrated LibreOffice for high-fidelity conversion of Office documents to PDF.
See how LogicPaper transforms raw data into professional documents instantly.
This is the mock data feeding the system:
{
"id": "CORP-001",
"company": "Acme Solutions Inc.",
"founded_date": "1998-05-12",
"revenue_q4": "1500000.00",
"is_public": "TRUE",
"compliance_check": "FALSE",
"auth_sig": "sig_valid.png"
}| Template (Input) | Generated Document (Output) |
|---|---|
| Model with Jinja2 Tags | Rendered PDF with Data |
![]() |
![]() |
| π View Template PDF | π View Result PDF |
LogicPaper follows Hexagonal Architecture (Ports and Adapters) principles, ensuring clean separation of concerns and testability.
graph TD
Client[Web Dashboard / API Client] -->|HTTP/JSON| FastAPI[FastAPI Web Server]
FastAPI -->|Enqueue Job| Worker[Background Worker]
Worker -->|State Management| Redis[(Redis State Store)]
Worker -->|Orchestration| Core[Batch Processing Core]
Core -->|Validation| Validator[Template Validator]
Core -->|Formatting| Strategies[Strategy Modules]
Core -->|Conversion| LibreOffice[LibreOffice Headless]
Worker -->|I/O Operations| Storage[/File System Adapter/]
LogicPaper/
βββ app/
β βββ core/ # Domain Layer (Pure Business Logic)
β β βββ config.py # Application Configuration (Pydantic Settings)
β β βββ engine.py # Document Rendering Engine
β β βββ formatter.py # Strategy Registry & Jinja2 Bridge
β β βββ ports.py # Abstract Interfaces (Ports)
β β βββ service.py # Batch Processing Orchestration
β β βββ validator.py # Template-Data Compatibility Checker
β β βββ reporter.py # Excel Report Generation
β β βββ strategies/ # Formatting Strategies (Strategy Pattern)
β β βββ base.py # Abstract Strategy Interface
β β βββ string_std.py # Text Manipulation
β β βββ number_std.py # Number & Currency Formatting
β β βββ date_std.py # Date/Time Operations
β β βββ boolean_std.py # Boolean Conversion
β β βββ logic_std.py # Conditional Logic
β β βββ mask_std.py # Data Privacy Masking
β β βββ image_std.py # Image Dimension Parsing
β β
β βββ integration/ # Infrastructure & Presentation Layers
β β βββ infrastructure.py # Adapters (FileSystem, LibreOffice)
β β βββ state.py # Redis Job Repository
β β βββ router.py # Headless API Endpoints
β β βββ dashboard_router.py # Web UI API Endpoints
β β βββ worker.py # Background Job Processors
β β βββ schemas.py # Pydantic Request/Response Models
β β βββ security.py # API Key Authentication
β β βββ sse.py # Server-Sent Events (Real-time Logs)
β β
β βββ dependencies.py # Dependency Injection Container
β βββ main.py # FastAPI Application Entry Point
β βββ utils.py # Shared Utilities & Schedulers
β
βββ static/ # Frontend UI (HTML/CSS/JS)
β βββ index.html # Main Dashboard
β βββ help.html # Documentation Page
β βββ assets/ # CSS, JS, Images
β
βββ persistent_templates/ # Template Library for API Access
βββ data/ # Docker Volume (Temporary Files)
βββ Dockerfile # Container Image Definition
βββ docker-compose.yml # Multi-Container Orchestration
βββ .env # Environment Configuration
- Hexagonal Architecture: Clean separation between domain and infrastructure
- Dependency Injection: FastAPI's DI system for loose coupling
- Strategy Pattern: Extensible formatting operations
- Repository Pattern: Abstract data persistence via ports
- Adapter Pattern: Infrastructure implementations of domain ports
- Docker Desktop (20.10+)
- Docker Compose
-
Clone the Repository
git clone https://github.com/rubensbraz/LogicPaper.git cd LogicPaper -
Configure Environment Create a
.envfile based on the provided configuration (ensureLOGICPAPER_API_KEYis set). -
Start Services
docker-compose up --build
-
Access
- UI Dashboard:
http://localhost:8000
- UI Dashboard:
LogicPaper provides a dedicated integration layer for external systems.
- Documentation:
http://localhost:8000/docs(Interactive Swagger UI) - Authentication:
X-API-Keyheader. - Workflow: Submit a JSON payload with data and template path; receive a
job_idto poll for status and download the result. - Asset Support: Optional
assets_base64field to provide a ZIP of images for dynamic replacement.
LogicPaper uses the pipe character (|) to apply formatting filters to variables.
For a complete list of filters, refer to the "How to Use" section in the application (Documentation in Github Pages).
{{ client_name | format_string('upper') }} -> "ACME CORP"
{{ client_id | format_string('prefix', 'ID: ') }} -> "ID: 12345"{{ contract_value | format_number('currency', 'USD') }} -> "$ 1,500.00"
{{ tax_rate | format_number('percent') }} -> "12.50%"
{{ total | format_number('spell_out', 'en') }} -> "one thousand five hundred"{{ start_date | format_date('long', 'en') }} -> "January 12, 2024"
{{ start_date | format_date('add_days', '30') }} -> "2024-02-11"Map status codes or values directly in the document:
{{ status_code | format_logic(
'10=Approved',
'20=Pending',
'default', 'Unknown'
) }}{{ email | format_mask('email') }} -> "j***@domain.com"{{ photo_filename | format_image('3', '4') }} -> (Resizes image to 3x4cm)LogicPaper is an open-source project and we love community contributions!
Whether you want to implement a new feature from our Roadmap, fix a bug, or improve documentation, please check our Contributing Guidelines before getting started.
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
- Share: Copy and redistribute the material in any medium or format.
- Adapt: Remix, transform, and build upon the material.
- Attribution: You must give appropriate credit to Rubens Braz, provide a link to the license, and indicate if changes were made.
- NonCommercial: You may NOT use the material for commercial purposes (selling the software, using it for paid services, or integrating it into commercial products).
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/
"Automation is not about laziness; it's about precision."


