-
Notifications
You must be signed in to change notification settings - Fork 0
Accounting Demo
This guide walks you through the RoboSystems Accounting Demo, showcasing how graph databases transform traditional accounting workflows into powerful, queryable knowledge graphs.
The Accounting Demo demonstrates RoboSystems' capabilities for accounting and financial data management by creating a complete double-entry bookkeeping system in a graph database. This approach offers:
- Full Transaction Lineage: Trace every dollar through the complete accounting cycle
- Real-time Financial Reports: Generate trial balances, income statements, and cash flow reports instantly
- Flexible Analysis: Run ad-hoc queries without predefined reports
- Audit Trail: Complete transaction history with relationship tracking
- Graph-native Accounting: Leverage graph relationships for multi-dimensional analysis
What gets created:
- 1 Entity: Acme Consulting LLC (fictional consulting company)
- 20 Accounts: Complete chart of accounts (Assets, Liabilities, Equity, Revenue, Expenses)
- ~180 Transactions: 6 months of realistic business activity
- ~360 Line Items: Double-entry journal entries with debits and credits
- Graph Relationships: Transaction lineage and account mappings
Before starting, ensure you have:
- Docker running locally
- RoboSystems development environment set up
- Services started with
just start
The fastest way to run the complete demo:
# Ensure RoboSystems is running
just start
# Run complete workflow
just demo-accountingWhat this does:
- Creates user account and API key
- Creates a new graph database
- Generates 6 months of accounting data
- Uploads and ingests data into the graph
- Runs verification queries with beautiful table output
First run: Takes ~2-3 minutes to complete all steps.
Subsequent runs: Reuses credentials and graph (~30 seconds).
Command syntax: just demo-accounting [flags] [base_url]
- Flags are comma-separated:
new-user,new-graph,regenerate-data,skip-queries - Base URL defaults to
http://localhost:8000
# Start fresh with new user and graph
just demo-accounting new-user,new-graph
# Create new graph (keep existing user)
just demo-accounting new-graph
# Regenerate data files
just demo-accounting regenerate-data
# Skip verification queries
just demo-accounting skip-queries
# Combine multiple flags
just demo-accounting new-user,new-graph,regenerate-dataThe just demo-accounting command runs all 5 steps automatically. This section explains what happens during each step. To run individual steps manually, use the Python scripts directly (see examples below).
What happens automatically:
- Creates new user in PostgreSQL database
- Generates API key for authentication
- Stores credentials locally in
examples/accounting_demo/credentials/config.json
Control via flags:
just demo-accounting new-user # Force new credentialsManual execution (if needed):
uv run examples/accounting_demo/01_setup_credentials.py
uv run examples/accounting_demo/01_setup_credentials.py --force # Force newWhat happens automatically:
- Creates new Kuzu graph database
- Registers graph with user account
- Stores graph_id in
credentials/config.jsonfor subsequent operations
Control via flags:
just demo-accounting new-graph # Force new graphManual execution (if needed):
uv run examples/accounting_demo/02_create_graph.py
uv run examples/accounting_demo/02_create_graph.py --reuse # Reuse existingWhat happens automatically:
- Generates 6 months of transaction data (default)
- Creates Parquet files in
examples/accounting_demo/data/directory - Includes: Entity, Element, Transaction, LineItem, and relationship files
- Validates double-entry bookkeeping (debits = credits)
Generated data includes:
- Monthly Revenue (consulting and training with realistic variation)
- Monthly Expenses (rent, salaries, utilities, office supplies, marketing)
- Balance Sheet Accounts (cash, accounts receivable/payable, equipment)
- Equity Accounts (common stock, retained earnings)
- Double-Entry Validation (every transaction balances)
Control via flags:
just demo-accounting regenerate-data # Force regenerateManual execution (if needed):
uv run examples/accounting_demo/03_generate_data.py
uv run examples/accounting_demo/03_generate_data.py --months 12 # More dataWhat happens automatically:
- Upload: Files uploaded to S3 (LocalStack in development)
- Stage: Data loaded into DuckDB staging tables
- Validate: Automatic data quality checks
- Ingest: DuckDB → Kuzu graph database via extension
- Verify: Counts verified, relationships checked
Manual execution (if needed):
uv run examples/accounting_demo/04_upload_ingest.pyWhat happens automatically:
- Executes all 15 preset financial queries
- Displays results in formatted Rich tables
- Shows trial balance, income statement, profitability, and more
Control via flags:
just demo-accounting skip-queries # Skip this stepManual execution (if needed):
# Run all presets
uv run examples/accounting_demo/05_query_graph.py --all
# Run specific preset
uv run examples/accounting_demo/05_query_graph.py --preset trial_balance
# Interactive mode
uv run examples/accounting_demo/05_query_graph.pyAfter the demo completes, see the Available Financial Reports section below for more query examples.
All queries display with professional Rich table formatting showing financial data clearly aligned and formatted.
View the complete chart of accounts with account types and normal balances:
uv run examples/accounting_demo/05_query_graph.py --preset chart_of_accountsOutput:
View chart of accounts
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ account ┃ type ┃ normal_balance ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ Cash │ asset │ debit │
│ AccountsReceivable │ asset │ debit │
│ ConsultingRevenue │ revenue │ credit │
│ Salaries │ expense │ debit │
└─────────────────────┴───────────┴────────────────┘
Calculate account balances using double-entry bookkeeping:
uv run examples/accounting_demo/05_query_graph.py --preset trial_balanceOutput:
Calculate trial balance
┏━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ account ┃ type ┃ total_debits┃ total_credits┃ net_balance┃
┡━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Cash │ asset │ 124,901.57 │ 85,450.17 │ 39,451.40 │
│ Revenue │ rev │ 0.00 │ 124,901.57 │ -124,901.57│
│ Salaries │ exp │ 62,962.89 │ 0.00 │ 62,962.89 │
└────────────┴───────┴─────────────┴──────────────┴────────────┘
Cypher Query:
MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WITH
e.name AS account,
e.classification AS type,
sum(li.debit_amount) AS total_debits,
sum(li.credit_amount) AS total_credits
RETURN
account,
type,
total_debits,
total_credits,
total_debits - total_credits AS net_balance
ORDER BY accountView revenue and expenses to determine profitability:
uv run examples/accounting_demo/05_query_graph.py --preset income_statementCypher Query:
MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WHERE e.classification IN ['revenue', 'expense']
WITH
e.classification AS category,
e.name AS account,
sum(li.credit_amount) - sum(li.debit_amount) AS amount
RETURN category, account, amount
ORDER BY category, accountTrack all transactions affecting the Cash account:
uv run examples/accounting_demo/05_query_graph.py --preset cash_flowCypher Query:
MATCH (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->(li:LineItem)
-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WHERE e.name = 'Cash'
RETURN
t.date AS date,
t.description AS description,
li.debit_amount AS cash_in,
li.credit_amount AS cash_out
ORDER BY t.date DESC
LIMIT 20Analyze revenue by month:
uv run examples/accounting_demo/05_query_graph.py --preset revenue_by_monthCypher Query:
MATCH (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->(li:LineItem)
-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WHERE e.classification = 'revenue'
RETURN
substring(t.date, 1, 7) AS month,
sum(li.credit_amount) AS total_revenue
ORDER BY monthMonthly profit/loss calculation:
uv run examples/accounting_demo/05_query_graph.py --preset profitabilityOutput:
Profitability by month (Revenue - Expenses)
┏━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ month ┃ revenue ┃ expenses ┃ profit ┃
┡━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━┩
│ 2025-05 │ 20,726.01 │ 13,115.65 │ 7,610.36 │
│ 2025-06 │ 21,422.14 │ 12,570.74 │ 8,851.40 │
│ 2025-07 │ 22,156.29 │ 14,750.07 │ 7,406.22 │
└─────────┴───────────┴───────────┴───────────┘
The demo includes 15 preset queries:
- counts - Count all nodes by type
- chart_of_accounts - View chart of accounts
- trial_balance - Calculate trial balance
- income_statement - Revenue & Expenses
- cash_flow - Cash flow transactions
- revenue_by_month - Revenue trends
- expense_by_month - Expense trends
- profitability - Monthly profit/loss
- top_expenses - Top expense categories
- recent_transactions - Most recent transactions
- monthly_reports - List financial reports
- report_summary - Report facts summary
- account_facts - Aggregated facts by account
- report_lineage - Data lineage from transactions to reports
- full_reporting_structure - Complete reporting hierarchy
The accounting demo uses a graph-native approach to double-entry bookkeeping.
Entity
- Represents the business entity (Acme Consulting LLC)
- Properties:
identifier,name,industry,jurisdiction
Element
- Individual accounts in the chart of accounts
- Properties:
identifier,name,classification,balance,period_type - Classifications:
asset,liability,equity,revenue,expense
Transaction
- Business transactions (invoices, payments, expenses)
- Properties:
identifier,date,description,type
LineItem
- Journal entry lines (debits and credits)
- Properties:
identifier,debit_amount,credit_amount,description
Report (optional)
- Financial reports linking to XBRL facts
- Properties:
identifier,name,form,report_date,fiscal_year,fiscal_period
Fact (optional)
- XBRL-style financial metrics
- Properties:
identifier,value,numeric_value,decimals
Period (optional)
- Time contexts for facts
- Properties:
identifier,instant_date,start_date,end_date
TRANSACTION_HAS_LINE_ITEM
- Links transactions to their journal entry lines
- Represents the composition of a transaction
LINE_ITEM_RELATES_TO_ELEMENT
- Links journal entries to chart of accounts
- Maps debits/credits to specific accounts
ENTITY_HAS_REPORT (optional)
- Links business entity to financial reports
REPORT_HAS_FACT (optional)
- Links reports to individual financial metrics
FACT_HAS_ELEMENT (optional)
- Links facts to account definitions
FACT_HAS_PERIOD (optional)
- Links facts to time periods
Transaction (Invoice #1234, 2025-05-15)
-[:TRANSACTION_HAS_LINE_ITEM]-> LineItem (Debit: $5,000)
-[:LINE_ITEM_RELATES_TO_ELEMENT]-> Element (Accounts Receivable)
-[:TRANSACTION_HAS_LINE_ITEM]-> LineItem (Credit: $5,000)
-[:LINE_ITEM_RELATES_TO_ELEMENT]-> Element (Consulting Revenue)
This represents: Invoiced $5,000 for consulting services, increasing Accounts Receivable (debit) and Consulting Revenue (credit).
You can also query the accounting graph using the just graph-query command:
# Count all nodes
just graph-query <graph_id> "MATCH (n) RETURN count(n)"
# View chart of accounts
just graph-query <graph_id> "MATCH (e:Element) RETURN e.name, e.classification ORDER BY e.name"
# Calculate trial balance
just graph-query <graph_id> "MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element) WITH e.name AS account, sum(li.debit_amount) AS debits, sum(li.credit_amount) AS credits RETURN account, debits, credits, debits - credits AS balance ORDER BY account"Note: Get your graph_id from credentials/config.json after running step 2.
The demo generates 6 months by default. To generate more data, you can run the individual Python scripts directly:
# Generate 12 months of data
uv run examples/accounting_demo/03_generate_data.py --months 12 --regenerate
# Upload and ingest
uv run examples/accounting_demo/04_upload_ingest.pyReset and recreate everything:
# Delete local credentials and data files
rm -rf examples/accounting_demo/credentials/
rm -rf examples/accounting_demo/data/
# Run with new user and graph
just demo-accounting new-user,new-graphRegenerate data and reload into existing graph:
just demo-accounting regenerate-dataAfter running the demo, use the just graph-query command for ad-hoc analysis. Get your graph_id from examples/accounting_demo/credentials/config.json:
# Find all expenses over $1,000
just graph-query <graph_id> "MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element) WHERE e.classification = 'expense' AND li.debit_amount > 1000 RETURN e.name, li.debit_amount ORDER BY li.debit_amount DESC"
# Calculate total revenue
just graph-query <graph_id> "MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element) WHERE e.classification = 'revenue' RETURN sum(li.credit_amount) AS total_revenue"
# Find transactions by description
just graph-query <graph_id> "MATCH (t:Transaction) WHERE t.description CONTAINS 'Consulting' RETURN t.date, t.description ORDER BY t.date DESC"G.V() is a powerful graph visualization tool and our recommended partner for exploring graph databases interactively. After running the accounting demo, you can visualize the complete accounting structure including entities, accounts, transactions, and their relationships.

Example: Accounting demo graph visualized in G.V() showing the entity (yellow center), chart of accounts (blue/purple Element nodes), transactions (pink), financial reports (orange), periods (magenta), and units (cyan) with all their relationships in the double-entry bookkeeping system
- Visit https://gdotv.com/ or download the desktop application
- Connect to your accounting graph database:
-
Database Path:
./data/kuzu-dbs/<graph_id>.kuzu(get graph_id fromcredentials/config.json)
-
Database Path:
- Enable "Fetch all edges between vertices" in settings for richer visualizations
- Run visualization queries to explore your accounting data
-- Visualize the complete accounting structure (limit for clarity)
MATCH (e:Entity)-[:ENTITY_HAS_REPORT]->(r:Report)-[:REPORT_HAS_FACT]->(f:Fact)
MATCH (f)-[:FACT_HAS_ELEMENT]->(el:Element)
MATCH (f)-[:FACT_HAS_PERIOD]->(p:Period)
RETURN e, r, f, el, p
LIMIT 20
-- View transaction flow through accounts
MATCH (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->(li:LineItem)
-[:LINE_ITEM_RELATES_TO_ELEMENT]->(el:Element)
WHERE t.date >= '2025-09-01'
RETURN t, li, el
LIMIT 15
-- Explore chart of accounts relationships
MATCH (el:Element)
WHERE el.classification IS NOT NULL
OPTIONAL MATCH (el)<-[:LINE_ITEM_RELATES_TO_ELEMENT]-(li:LineItem)
RETURN el, li
LIMIT 25
-- Focus on revenue accounts
MATCH (el:Element {classification: 'revenue'})
<-[:LINE_ITEM_RELATES_TO_ELEMENT]-(li:LineItem)
<-[:TRANSACTION_HAS_LINE_ITEM]-(t:Transaction)
RETURN el, li, t
LIMIT 20-
Start small: Use
LIMIT 10-20to avoid cluttering the visualization -
Filter by date: Use
WHERE t.date >= '2025-09-01'to focus on specific periods -
Focus on account types: Filter by classification (
revenue,expense,asset, etc.) - Click nodes: Explore properties and relationships interactively
- Use layouts: Try different layout algorithms to organize the graph
- Export images: Save visualizations for presentations and documentation
Traditional accounting systems store transactions in flat tables. Graph databases capture the relationships between transactions, accounts, and entities:
-- Trace a dollar through the entire accounting cycle
MATCH path = (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->
(li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WHERE t.description CONTAINS 'Invoice'
RETURN pathNo need for pre-computed views or batch processing. Financial reports are generated instantly from the current graph state:
-- Real-time balance sheet
MATCH (li:LineItem)-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
WHERE e.classification IN ['asset', 'liability', 'equity']
RETURN e.classification, e.name, sum(li.debit_amount - li.credit_amount) AS balanceComplete transaction history with full lineage tracking:
-- Full audit trail for an account
MATCH (e:Element {name: 'Cash'})<-[:LINE_ITEM_RELATES_TO_ELEMENT]-
(li:LineItem)<-[:TRANSACTION_HAS_LINE_ITEM]-(t:Transaction)
RETURN t.date, t.description, li.debit_amount, li.credit_amount
ORDER BY t.dateGraph queries enable analysis across multiple dimensions without complex SQL joins:
-- Profitability by account and month
MATCH (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->(li:LineItem)
-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
RETURN
substring(t.date, 1, 7) AS month,
e.name AS account,
sum(li.credit_amount - li.debit_amount) AS net_amount
ORDER BY month, accountGraph databases adapt easily to new accounting requirements:
- Add new node types (departments, projects, cost centers)
- Add new relationships (allocations, transfers, adjustments)
- Extend existing nodes with properties
- No schema migrations required
The demo showcases patterns used in real RoboSystems integrations:
The demo includes optional XBRL-style reporting structures (Reports, Facts, Periods) showing how traditional accounting transactions map to regulatory filings:
-- Link transactions to XBRL reports
MATCH (t:Transaction)-[:TRANSACTION_HAS_LINE_ITEM]->(li:LineItem)
-[:LINE_ITEM_RELATES_TO_ELEMENT]->(e:Element)
MATCH (r:Report)-[:REPORT_HAS_FACT]->(f:Fact)-[:FACT_HAS_ELEMENT]->(e)
RETURN t.description, e.name, f.value, r.nameSimilar patterns power the QuickBooks integration (/robosystems/processors/qb_transactions.py):
- Transactions → QuickBooks Invoices/Bills
- LineItems → Journal Entry Lines
- Elements → Chart of Accounts
- Real-time sync with graph queries
Any double-entry accounting system can follow this pattern:
- Extract transactions and journal entries
- Map to Element (chart of accounts)
- Create Transaction and LineItem nodes
- Link with relationships
- Query with Cypher for analysis
Solution: Let the demo create credentials automatically, or force new credentials:
just demo-accounting new-userSolution: Let the demo create a graph automatically, or force new graph:
just demo-accounting new-graphSolution: Regenerate data:
just demo-accounting regenerate-dataSolution: Ensure RoboSystems services are running:
just start
docker ps # Verify containers are runningSolution: Install dev dependencies:
just installSolution: Re-run the demo to reload data:
just demo-accounting regenerate-data-
Query Your Data: Use
just graph-query <graph_id> "..."for ad-hoc Cypher queries - Visualize Your Graph: See the Visualizing with G.V() section to explore your accounting graph interactively
- Learn Cypher: Explore graph query patterns with Cypher Manual
- Generate More Data: Modify scripts to generate 12+ months for more historical analysis
- Build Custom Reports: Create your own financial analysis queries
- Integrate Your Data: Adapt the pattern for your accounting system
-
Demo Code:
/examples/accounting_demo/in the repository - QUICKSTART.md: Detailed quickstart in the demo directory
- G.V() Graph IDE: https://gdotv.com/ - Visualize your accounting graph
- Cypher Docs: Cypher Manual
- RoboSystems API: http://localhost:8000/docs (when running locally)
-
Integration Docs:
/robosystems/processors/for QuickBooks and XBRL processors
- GitHub Issues: robosystems/issues
- Main README: robosystems/README.md
- Development Guide: CLAUDE.md
MIT © 2025 RFS LLC