Skip to content

Latest commit

Β 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FaturaFi

Paid before payday.

Turkish small businesses wait 60–120 days to get paid on their invoices. FaturaFi turns those invoices into real Solana NFTs, scores them with explainable AI, and connects them to global liquidity β€” so business owners get paid in seconds instead of months.

Built on Solana Anchor 0.30 Next.js 14 License: MIT

View the Solana program Β· Built for Colosseum Frontier 2026 β€” Superteam TΓΌrkiye


The problem

Every small business in TΓΌrkiye knows this story:

You ship goods or deliver a service. The buyer is reliable. The invoice gets accepted. And then you wait β€” 60 days, 90 days, sometimes 120 days β€” to actually get paid.

During that wait, you still have to pay your suppliers, your rent, and your employees. From a bank balance that's already shrinking.

The numbers behind this:

  • 3.5 million small businesses operate in TΓΌrkiye
  • They produce 56% of the country's GDP and employ 73% of the workforce
  • At any given moment, β‚Ί2.3 trillion is trapped in unpaid invoices
  • This cash-flow gap is the single biggest reason these businesses fail

Why existing solutions don't work for most of them:

Option The problem
Bank factoring Requires collateral and credit history. Takes 3–5 days. Effective rates of 20–35% per year.
Credit cards Limits are far too low for typical B2B invoice amounts.
Informal lenders Predatory rates, no structure, no legal protection.
Doing nothing The most common choice. Also the most common cause of failure.

What FaturaFi does

FaturaFi tokenizes unpaid invoices as Solana NFTs that anyone can fund with SOL.

Here's the flow, in five steps:

  1. A business lists an invoice. They open the dApp, connect Phantom, and enter the invoice details: buyer name, amount, payment term, business history.

  2. The AI scores it instantly. An XGBoost model trained on Turkish factoring market data returns a risk score (0–100), a letter grade (A through E), and a suggested discount rate. The whole thing takes under 2 seconds. The model also returns SHAP explanations β€” so the investor can see exactly which factors drove the score.

  3. A real NFT mints on Solana. Phantom signs the transaction; an SPL Token NFT (decimals=0, supply=1) is minted on Solana devnet representing this specific receivable. Every mint produces a real transaction signature visible on Solana Explorer.

  4. An investor funds the invoice. They browse the marketplace, filter by sector or risk grade, and fund it. The business owner gets discounted SOL in their wallet in about 400 milliseconds.

  5. The buyer pays at maturity. When the original buyer pays the face value, the full amount goes to whoever holds the NFT. The investor's profit is the spread.


Why this only works on Solana

This isn't a "we picked Solana because it's popular" thing. The product is economically impossible on most other chains. Here's why:

Requirement Why we need it Solana delivers
Per-transaction cost under 0.01% of invoice value A 0.5 SOL invoice can't afford $5 in gas ~$0.00025
Settlement in seconds, not minutes Business owners need cash now, not after 12 minutes of confirmations ~400ms finality
Throughput at SME scale 3.5M businesses Γ— 12 invoices/year = 42M transactions/year minimum 65,000 TPS
Native NFT primitives Each invoice needs to be a transferable, unique on-chain asset SPL Token with decimals=0

On Ethereum L1, gas fees would eat the entire investor spread. On most L2s, finality slows down during congestion β€” which is exactly when small businesses need their money the fastest. Solana is the only network where the numbers actually work.


How everything fits together

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Next.js frontend   β”‚ ◄─────► β”‚   FastAPI backend   β”‚
β”‚  + Phantom wallet   β”‚  HTTPS  β”‚   XGBoost + SHAP    β”‚
β”‚  hosted on Vercel   β”‚         β”‚  hosted on Railway  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚                                β”‚
           β”‚  Solana RPC                    β”‚  SQLite
           β–Ό                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Solana devnet     β”‚         β”‚   invoices table    β”‚
β”‚                     β”‚         β”‚   risk drivers      β”‚
β”‚   β€’ SPL Token mint  β”‚         β”‚   portfolios        β”‚
β”‚     (NFT per inv.)  β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚                     β”‚
β”‚   Anchor program    β”‚
β”‚   (deployed, for    β”‚
β”‚   full settlement   β”‚
β”‚   roadmap Q3 2026)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repository structure

faturafi/
β”œβ”€β”€ program/          Anchor program (Rust) β€” the on-chain protocol
β”‚   β”œβ”€β”€ programs/faturafi/src/lib.rs
β”‚   └── tests/faturafi.ts
β”œβ”€β”€ backend/          FastAPI service (Python) β€” risk scoring + DB
β”‚   β”œβ”€β”€ ml/           XGBoost training pipeline
β”‚   └── app/          API routes
β”œβ”€β”€ frontend/         Next.js 14 (TypeScript) β€” UI + Solana wallet
β”‚   β”œβ”€β”€ src/app/      Routes (marketplace, list, portfolio, invoice/[id])
β”‚   β”œβ”€β”€ src/components/  Header, InvoiceCard, FaturaFiLogo (custom SVG)
β”‚   └── src/lib/solana/  Real SPL Token NFT minting helper
β”œβ”€β”€ docs/             Notes, X posts, additional docs
└── scripts/          One-command setup script

The AI risk model

The heart of FaturaFi is a real, trained machine learning model β€” not a chatbot wrapper.

Property Value
Algorithm XGBoost (gradient-boosted trees)
Training data 10,000 synthetic invoices calibrated to real Turkish factoring patterns
Features used 22 (sector, buyer size, macroeconomic conditions, payment history, term length, amounts)
Test AUC 0.72
Brier score 0.17
Explainability SHAP values per prediction, hashed and committed on-chain

What drives a typical prediction

Based on actual feature importance from the trained model:

  1. Who the buyer is. An enterprise-level buyer (think Migros, LC Waikiki) is far safer than a micro-business buyer. This single factor matters more than anything else.
  2. What sector the business is in. Construction and agriculture carry higher historical default rates. Services and food businesses are safer.
  3. The macroeconomic environment. During currency shocks, default rates roughly double across the board.
  4. How long the payment term is. A 120-day invoice carries materially more risk than a 30-day one.
  5. The business's track record. A history of on-time payment significantly reduces risk, even for newer businesses.

Every invoice in the marketplace has a "Why this score?" button. Click it and you see the actual SHAP drivers behind that specific number β€” not a black box.


The on-chain program

The Anchor program is deployed and live on Solana devnet:

CoM9J1UygQFBNwTbhK1AwT8vymCKL7dPM7KW76drNF36

View it on Solana Explorer β†’

What the program does

Instruction Who calls it What it does
initialize Protocol authority (once) Sets up the treasury and fee config
list_invoice The business Creates an Invoice account + mints a unique NFT for it
fund_invoice The investor Transfers discounted USDC to the business, takes a small protocol fee, marks the NFT as funded
settle_invoice The buyer Transfers the face value to the current NFT holder
mark_defaulted Anyone (after a 7-day grace period) Marks an invoice as defaulted, unlocking the recovery flow

The program uses three PDAs (Program Derived Addresses):

  • ["config"] β€” global protocol config
  • ["invoice", invoice_id] β€” state for each individual invoice
  • ["invoice_nft", invoice_id] β€” the NFT mint for each invoice

Every state change emits an on-chain event, so indexers or webhooks can power real-time dashboards.

Why the dApp uses SPL Token directly for the demo

For the current hackathon MVP, the frontend mints invoice NFTs through SPL Token directly instead of through the Anchor program. This is a deliberate scoping decision:

  • The Anchor program is deployed and verifiable on-chain
  • Direct SPL minting lets users see a real on-chain NFT in their Phantom wallet within seconds, with no protocol initialization, no USDC mint setup, no devnet token faucet
  • Full Anchor integration (fund/settle/default through PDAs, escrow logic) is the Q3 2026 roadmap item once the pilot moves to mainnet

This gives the demo real on-chain proof today, while keeping the protocol's full lifecycle ready for the production phase.


Running it locally

Prerequisites

You'll need:

  • Node.js 20 or later
  • Python 3.11 or later
  • Rust + Solana CLI (install guide)
  • Anchor 0.30.1 (avm install 0.30.1 && avm use 0.30.1)
  • A Phantom wallet set to Devnet (Settings β†’ Developer Settings β†’ Testnet Mode β†’ ON)
  • A little devnet SOL β€” get some at faucet.solana.com

Quick start

git clone https://github.com/mertcano/Fatura_Fi
cd Fatura_Fi
./scripts/setup.sh

The setup script installs all dependencies, generates the synthetic training data, and trains the model. Takes about 5 minutes total.

Run all three services

You'll need three terminal windows:

# Terminal 1 β€” the backend
cd backend && source venv/bin/activate
uvicorn app.main:app --reload

# Terminal 2 β€” the frontend
cd frontend
npm run dev

# Terminal 3 β€” Anchor (only the first time)
cd program
anchor build --no-idl && anchor deploy --provider.cluster devnet

Then open http://localhost:3000, connect your Phantom wallet (make sure it's on Devnet), and on the marketplace page click Load demo invoices to seed some data.

For step-by-step deployment instructions, see DEPLOY.md.


What's working in this MVP

  • βœ… Live on-chain NFT minting β€” every listed invoice produces a real Solana NFT signed by the user's Phantom wallet
  • βœ… Live AI risk scoring with sub-second response times
  • βœ… SHAP-based explanations for every score
  • βœ… Next.js 14 frontend with Phantom and Solflare wallet support
  • βœ… Filterable marketplace (by sector, risk grade, amount)
  • βœ… SME invoice submission form with all 22 model inputs
  • βœ… Portfolio dashboard with two views: Investments and My listings (open / funded / settled)
  • βœ… FastAPI backend with database persistence
  • βœ… Anchor program covering the full invoice lifecycle, deployed on devnet
  • βœ… End-to-end TypeScript integration tests for the program
  • βœ… Production frontend on Vercel + backend on Railway
  • βœ… Earth + Mint design system with custom SVG logo and Geist typography

What comes next

Q3 2026 β€” A pilot with 5 Turkish SMEs (we have early conversations going with textile workshops in Bursa and electronics suppliers in Konya) and 2 family-office investors. The synthetic training data gets replaced with real anonymized invoice data. The frontend migrates from direct SPL minting to full Anchor program integration with USDC escrow.

Q4 2026 β€” A KVKK (Turkish GDPR) compliance audit. Pyth oracle integration for live TRY/USD pricing. A buyer verification flow using e-signature attestations recorded on-chain.

Q1 2027 β€” Tranching: pooling similar-risk invoices into senior and junior tranches so institutional capital can participate at the risk level they want.

Q2 2027 β€” Expanding the protocol to other emerging markets with similar SME cash-flow problems β€” Brazil, Indonesia, Egypt.


Tech stack

Layer Technology
On-chain Solana, Anchor 0.30.1, SPL Token (@solana/spl-token)
Risk model XGBoost, scikit-learn, SHAP via XGBoost's pred_contribs
Backend FastAPI, SQLAlchemy, Pydantic, SQLite
Frontend Next.js 14 (App Router), TypeScript, Tailwind CSS, Geist font
Wallets @solana/wallet-adapter (Phantom + Solflare)
Deployment Vercel (frontend), Railway (backend), Solana devnet (program)

License

MIT β€” see LICENSE. Use it, fork it, build on it.


Built for Colosseum Frontier 2026 Β· Superteam TΓΌrkiye Track

Paid before payday.

Live demo Β· Solana program

About

AI-powered invoice tokenization protocol for Turkish SMEs, built on Solana. Tokenize unpaid invoices as NFTs, get instant USDC liquidity. Risk-scored by an XGBoost model with on-chain SHAP explanations. Built for Colosseum Frontier 2026.

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages