A Python pipeline that processes construction company month-end financial data through six sequential AI-assisted steps, producing a Word document pack and an Excel review checklist for human sign-off.
Built as a proof-of-concept for the Stringline Phase 0 brief. Runs against synthetic Business Central data that mirrors real OData response shapes.
BC Data (OData / JSON)
│
▼
┌─────────────────┐
│ Step 1 │ Ingestion — read and normalise BC data
│ Confidence: det.│ Deterministic confidence based on data completeness
└────────┬────────┘
│
▼
┌─────────────────┐
│ Step 2 │ Classification — tag each transaction by cost type
│ Confidence: hyb.│ Deterministic (account codes) + Claude (ambiguous)
└────────┬────────┘
│
▼
┌─────────────────┐
│ Step 3 │ Reconciliation — transaction-level bank vs ledger
│ Confidence: det.│ Deterministic match scoring + Claude commentary
└────────┬────────┘
│
▼
┌─────────────────┐
│ Step 4 │ Anomaly Flagging — unusual amounts, CIS, margins
│ Confidence: AI │ Claude self-assessed against prior month comparatives
└────────┬────────┘
│
▼
┌─────────────────┐
│ Step 5 │ Commentary — plain-English MD narrative
│ Confidence: AI │ Claude self-assessed, structured 4-section output
└────────┬────────┘
│
▼
┌─────────────────┐
│ Step 6 │ Sector Intelligence — web search, subsector filtered
│ Confidence: AI │ Claude web search tool, relevance-scored output
└────────┬────────┘
│
▼
┌──────────────────────────────┐
│ output/month_end_pack.docx │ Word document for SharePoint
│ output/review_checklist.xlsx │ Excel checklist for human reviewer
└──────────────────────────────┘
Each step returns a confidence score (0–100):
| Step | Scoring Method | Rationale |
|---|---|---|
| 1 — Ingestion | Deterministic — presence and population of expected data sets | We can measure completeness directly |
| 2 — Classification | Hybrid — deterministic for account codes (95%), Claude self-assessed for ambiguous (0–100) | Account codes are reliable; descriptions need LLM judgement |
| 3 — Reconciliation | Deterministic — weighted: exact match=100, partial=70, unmatched=0 | Match quality is measurable |
| 4 — Anomaly | Claude self-assessed — per anomaly, averaged for step score | We can't measure what we don't know; Claude estimates its own certainty |
| 5 — Commentary | Claude self-assessed — extracted from end of response | Narrative quality requires self-evaluation |
| 6 — Sector Intel | Relevance score — Claude-assessed per item, averaged | Source quality varies; relevance is LLM judgement |
Items below LOW_CONFIDENCE_THRESHOLD (60%) are flagged for mandatory human review.
Items below MEDIUM_CONFIDENCE_THRESHOLD (80%) are flagged as advisory.
# Install dependencies
pip install -r requirements.txt
# Set your Anthropic API key
export ANTHROPIC_API_KEY=your_key_here
# Run full pipeline against synthetic data
python pipeline.py
# Run only through Step 3 (ingestion, classification, reconciliation)
python pipeline.py --step 3
# Run against a custom data file
python pipeline.py --data path/to/your_bc_data.json
# Run individual steps for testing
python steps/step1_ingestion.py
python steps/step2_classification.py
python steps/step3_reconciliation.py
python steps/step4_5_anomaly_commentary.py
python steps/step6_sector_intelligence.pystringline-pipeline/
├── pipeline.py # Main orchestrator
├── config.py # All configuration (client, thresholds, paths)
├── document_generator.py # Word document (.docx) generation
├── review_checklist.py # Excel review checklist generation
├── requirements.txt
├── steps/
│ ├── step1_ingestion.py # BC data ingestion and normalisation
│ ├── step2_classification.py # Transaction classification (hybrid)
│ ├── step3_reconciliation.py # Bank vs ledger reconciliation
│ ├── step4_5_anomaly_commentary.py # Anomaly flagging + management commentary
│ └── step6_sector_intelligence.py # Sector intelligence (web search)
├── data/
│ └── synthetic_bc_data.json # Realistic synthetic BC data (Phase 0)
├── output/ # Generated documents (gitignored)
└── logs/ # Step-by-step output logs (gitignored)
All client-specific configuration is in config.py:
CLIENT_NAME = "Stringline Testbed Construction Ltd"
REPORTING_MONTH = "May 2025"
SUBSECTOR = "modular/offsite manufacturer" # Change per client in Phase 1
LOW_CONFIDENCE_THRESHOLD = 60 # Below this = mandatory review
MEDIUM_CONFIDENCE_THRESHOLD = 80 # Below this = advisory reviewFor Phase 1 multi-client support, each client gets its own config file. No pipeline code changes required — only config changes.
- Pipeline architecture: 6 independent, chainable steps with consistent interface
- Hybrid confidence scoring: deterministic where measurable, Claude self-assessed where not
- Transaction-level reconciliation: not balance-level — surfaces individual unmatched items
- Structured outputs: every step returns
{"result": ..., "confidence": 0-100, "flags": [...]} - Failure logging: every step output persisted to
logs/for Phase 0 learning - Document generation: complete Word pack and Excel reviewer checklist
- Independently runnable steps: each step can be tested in isolation
Not built and not intended:
- ❌ Web application or API
- ❌ Database or persistent data store
- ❌ Email or notification sending
- ❌ SharePoint integration (checklist is generated as .xlsx for manual upload)
- ❌ Automated scheduling
- ❌ Write operations to Business Central
- ❌ Multi-tenant architecture
These are Phase 1 decisions, made with data from Phase 0 failure logs.
data/synthetic_bc_data.json contains realistic construction finance data:
- 13 bank feed transactions (May 2025)
- 12 ledger entries with BC account codes
- 4 active projects with WIP and retention data
- Aged debtors and creditors
- Prior month comparatives (April 2025)
- Deliberate anomalies for pipeline testing:
- 2 bank transactions cleared but not in ledger (BF012, BF013)
- 1 ledger entry posted but not cleared in bank (GL012)
- Missing CIS deduction on one subcontractor payment
- Retention held but bank receipt outstanding
Phase 0 — June 2026 | Built by Virendra Vyas / Yug Solutions Ltd