An open-source financial automation engine orchestrating ingestion, extraction, fraud check, signatures, payments, and ledger synchronization.
Why Ledgerdemain · Quickstart · Core Workflows · Architecture · Configuration Reference · License
Note
This documentation targets system integrators, finance operations engineers, and developers who automate financial data pipelines.
Manual financial operations scale poorly. Finance teams spend hours downloading invoices from emails, extracting data into spreadsheets, running compliance checks, chasing signatures, and manually reconciling payments in Xero or QuickBooks. Ledgerdemain automates this entire pipeline. The system catches the email, extracts the data, runs the compliance checks, routes exceptions to a human, and syncs the final entry to your ledger.
The name Ledgerdemain combines the accounting term ledger with demain, the French word for tomorrow. It also plays on the noun legerdemain, which means sleight of hand or street magic. The system automates multi-stage financial transactions behind the scenes so smoothly that the operation resembles magic.
To launch Ledgerdemain, run the CLI tool in your terminal:
npx ledgerdemainThe command automatically executes the following actions:
- Boots a local n8n instance on port 5678.
- Guides you through an interactive setup wizard to select integrations.
- Creates n8n credential skeletons for your chosen providers.
- Synchronizes all 7 workflow files from the
workflows/directory into n8n.
If you want to modify the workflows locally, run the development command:
npx ledgerdemain devThe dev command monitors the workflows/ directory for edits. Pressing R in the terminal re-syncs the JSON files to n8n, while Q terminates the server.
Ledgerdemain structures financial processing into 7 distinct stages managed by a master orchestrator.
| Stage | Core Purpose | Supported Integrations |
|---|---|---|
| Stage 1: Ingestion | Polls sources and downloads incoming financial documents | Gmail, Outlook, Mailgun |
| Stage 2: Extraction | Extracts structured metadata from raw documents | OpenAI, Anthropic, AWS Textract |
| Stage 3: Fraud and Compliance | Verifies business registration and calculates sales tax | Middesk, ComplyAdvantage, TaxJar |
| Stage 4: Human-in-the-Loop | Routes low-confidence extractions to human operators | Slack, Microsoft Teams, Telegram |
| Stage 5: E-Signatures | Sends finalized agreements for digital signatures | DocuSign, PandaDoc, Dropbox Sign |
| Stage 6: Payments | Initiates card payments or bank transfers for invoices | Stripe, Wise, PayPal |
| Stage 7: Ledger Sync | Reconciles transactions in the system of record | Xero, QuickBooks Online, NetSuite |
The Master Orchestrator (ledgerdemain_app.json) routes transactions through the entire multi-stage financial pipeline. It evaluates conditional switches and routes data based on the features you enable in the global configuration.
The Ingestion workflow (stage_1_ingestion.json) polls external sources and downloads incoming financial documents.
Example: A vendor emails an invoice to your billing address. Ledgerdemain detects the email, downloads the PDF attachment, and passes it to the extraction stage.
The Extraction workflow (stage_2_extraction.json) extracts structured metadata from raw documents.
Example: The system reads the vendor PDF and extracts the total amount, due date, line items, and vendor name into a structured JSON payload.
The Fraud and Compliance workflow (stage_3_fraud_compliance.json) runs business verification checks and calculates sales tax on extracted invoices.
Example: Before paying a new vendor, the system queries Middesk to verify their business registration and checks TaxJar for correct tax calculations.
The Human-in-the-Loop workflow (stage_4_hitl.json) routes extractions with low confidence scores to human operators for validation.
Example: If the AI is unsure about an invoice total, the system sends a Slack message with interactive buttons. A manager clicks "Approve" or "Reject" to unblock the pipeline.
The Electronic Signatures workflow (stage_5_esignatures.json) sends finalized agreements to vendors or clients for digital signing.
Example: For contractor invoices over $10,000, the system automatically generates a DocuSign envelope and pauses the workflow until the vendor signs the compliance document.
The Payments workflow (stage_6_payments.json) initiates electronic bank transfers or card payments for validated invoices.
Example: Once approved and signed, the system calls the Stripe API to securely wire the funds to the vendor's bank account.
The Ledger Synchronization workflow (stage_7_ledger_sync.json) creates journal entries in the system of record.
Example: After the payment clears, the system logs a journal entry in Xero and marks the original bill as paid, keeping your books perfectly balanced.
Ledgerdemain relies on a modular architecture where the CLI communicates with a local n8n instance via the REST API.
%%{init: {
"theme": "base",
"themeVariables": {
"primaryColor": "#10b981",
"primaryTextColor": "#ffffff",
"primaryBorderColor": "#047857",
"lineColor": "#6b7280",
"secondaryColor": "#3b82f6",
"tertiaryColor": "#f3f4f6"
}
}}%%
graph TD
CLI[npx ledgerdemain] -->|1. Launches| N8N[Local n8n Server]
CLI -->|2. Runs| Wizard[CLI Setup Wizard]
Wizard -->|3. Synchronizes| DB[(n8n Database)]
DB -->|4. Runs| Orchestrator[Master Orchestrator]
Orchestrator -->|5. Triggers| S1[Stage 1: Ingestion]
Orchestrator -->|5. Triggers| S2[Stage 2: Extraction]
Orchestrator -->|5. Triggers| S3[Stage 3: Fraud]
Orchestrator -->|5. Triggers| S4[Stage 4: HITL]
Orchestrator -->|5. Triggers| S5[Stage 5: E-Sign]
Orchestrator -->|5. Triggers| S6[Stage 6: Payments]
Orchestrator -->|5. Triggers| S7[Stage 7: Ledger Sync]
View Global Configuration Variables
Configure the orchestrator by adjusting properties in the Global Config node:
config.enable_fraud_check(boolean): Enables Stage 3 business compliance checks.config.enable_hitl(boolean): Enables Stage 4 manual reviews.config.enable_esignature(boolean): Enables Stage 5 contract signing steps.config.enable_payments(boolean): Enables Stage 6 transaction settlement.config.providers.ingestion(array): List of active ingestion tools (e.g.,["gmail"]).config.providers.extraction(array): List of active document parsers (e.g.,["openai"]).config.providers.fraud(array): List of compliance checks (e.g.,["middesk"]).config.providers.hitl(array): List of review notification destinations (e.g.,["slack"]).config.providers.esignature(array): List of active signature systems (e.g.,["docusign"]).config.providers.payments(array): List of transactional backends (e.g.,["stripe"]).config.providers.ledger(array): List of accounting integrations (e.g.,["xero"]).
This project is licensed under the MIT License. See LICENSE for details.
