Live interactive demo: https://alexklet777.github.io/DebtLoop/
B2B FinTech infrastructure for circular-debt detection and multilateral netting.
DebtLoop identifies closed chains of obligations between companies and calculates how much debt can be offset without requiring each participant to move the full gross amount of cash.
SMEs can be simultaneously creditors and debtors. When payment chains become circular, liquidity can remain trapped even though part of the obligations could be offset. DebtLoop models obligations as a directed graph, detects cycles, and proposes a mathematically consistent multilateral netting amount.
The current PoC includes:
- debt creation and bilateral confirmation in a Telegram prototype;
- persistent debt records;
- circular-debt detection;
- automatic calculation of the maximum equal offset around a detected cycle;
- before/after obligation calculation;
- a built-in B2B demo command;
- automated unit tests for the core netting engine.
Important: the current PoC calculates and proposes netting. It does not yet execute legal settlement, move funds, or replace accounting/ERP systems.
Input obligations:
- Company A → Company B: $100,000
- Company B → Company C: $80,000
- Company C → Company A: $70,000
DebtLoop detects the cycle and calculates:
- maximum netting per link: $70,000
- gross obligations before: $250,000
- residual obligations after: $40,000
- gross debt eliminated from the cycle: $210,000
Residual obligations:
- Company A → Company B: $30,000
- Company B → Company C: $10,000
- Company C → Company A: $0
/owe @username amount— create a debt record;/confirm ID— confirm a debt;/reject ID— reject a debt;/paid ID— mark a confirmed debt as paid;/debts— show debts you owe;/credits— show debts owed to you;/netting— detect a circular debt and calculate a netting proposal;/demo— show the built-in B2B PoC scenario.
main.py— Telegram prototype;netting.py— standalone circular-debt detection and netting engine;test_netting.py— unit tests;demo_netting.py— command-line demo;.github/workflows/netting-tests.yml— automated test workflow;QATAR_START_APPLICATION.md— working draft for the Startup Qatar / QDB application;MVP_TEST_PLAN.md— validation checklist for the PoC.
python demo_netting.pypython -m unittest -v test_netting.pyInstall dependencies:
pip install -r requirements.txtSet the Telegram bot token as environment variable TOKEN, then:
python main.pyThe intended product is a B2B platform, not merely a Telegram bot. The Telegram interface is currently used as a lightweight PoC. Planned product development includes:
- B2B web application with company accounts and role-based access;
- invoice / obligation import;
- multi-cycle optimization across larger graphs;
- proposal approval by all affected parties;
- audit trail and settlement documentation;
- ERP/accounting integrations and APIs;
- jurisdiction-specific legal and compliance workflows;
- analytics showing liquidity unlocked and obligations reduced.
DebtLoop is being prepared for the Startup Qatar Investment Program (START track). Current work focuses on the areas QDB explicitly expects at START stage: a validated concept, clear technology roadmap, market research, business model and monetization strategy, an execution plan, and a committed leadership team.
See:
QATAR_START_APPLICATION.md— application draft;QATAR_VALIDATION_PACKAGE.md— evidence and validation plan;MVP_TEST_PLAN.md— technical PoC validation.
DebtLoop is being prepared as a B2B FinTech / working-capital infrastructure project for a potential Qatar launch and later GCC expansion. Before commercial deployment, the legal enforceability of multilateral netting, accounting treatment, data requirements, and any regulated activities must be validated with qualified local advisers and partners.
Created by Alexander Kletsov.
GitHub: AlexKlet777
Telegram: @alexanderkletsov
Original project authorship was recorded in this repository on 2025-04-23.