Skip to content

Nezha-Amine/NoBell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”” NoBell β€” Decentralized Equity Marketplace

Bitcoin-native private equity trading with AI risk intelligence, Lightning Network submarine swaps, and Taproot Asset tokenization.

MIT Bitcoin Hackathon 2026 License Python React MongoDB


πŸ“‹ Table of Contents


πŸ”” What is NoBell?

NoBell is a marketplace where startups can raise funding by tokenizing equity, employees can sell vested shares, and investors can buy private equity β€” all settled in under one second via Bitcoin's Lightning Network.

Every listing is automatically analyzed by an AI-powered risk inspector before going live. Ownership is proven by Merkle inclusion proofs. Settlement is atomic via HTLC submarine swaps. No brokers, no clearinghouses, no waiting.

One-liner: Robinhood for private equity, powered by Bitcoin and AI.


🚨 The Problem

Problem Today's Reality NoBell's Fix
Locked equity Startup employees sit on options they can't sell. Legal fees: $5K-$15K per transfer. One-click sell with AI validation
Slow settlement T+1 to T+2 (1-2 business days). Counterparty risk during the gap. Under 1 second via Lightning
No ownership A central depository holds your shares. They can freeze your account. Your wallet, your keys (Taproot Assets)
No risk intelligence Zero analyst coverage for private markets. You're flying blind. AI Inspector scores every listing (12 metrics)
Cross-border friction Currency conversion (2-4%), wire transfers (3-5 days), legal hurdles. Bitcoin settles globally, instantly

πŸ’‘ Our Solution

Three-Layer Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND (React)                  β”‚
β”‚   Marketplace β”‚ BuyFlow β”‚ Portfolio β”‚ Rewards β”‚ Adminβ”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              AI INSPECTOR (Port 8000)                β”‚
β”‚  Risk Scoring β”‚ Lightning Pipeline β”‚ Taproot Engine  β”‚
β”‚  Merkle Proofs β”‚ Security (8 layers) β”‚ Gemini AI     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              BACKEND API (Port 8001)                 β”‚
β”‚  Auth (SIWE) β”‚ Wallet β”‚ Loyalty β”‚ MongoDB Atlas      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚              BITCOIN + ETHEREUM                      β”‚
β”‚  Lightning Network β”‚ Taproot Assets β”‚ Sepolia (EVM)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Lightning Network β€” Sub-second settlement via HTLC submarine swaps
  2. Taproot Assets β€” Bitcoin-native tokenized equity with Sparse-Merkle Tree ownership
  3. AI Inspector β€” 12-feature risk scoring + Gemini AI explanations + Merkle proof verification
Screenshot 2026-04-12 at 5 38 21β€―AM

⚑ Lightning Pipeline Deep Dive

Submarine Swap β€” How It Works

A submarine swap atomically exchanges Bitcoin (Lightning, off-chain) for Taproot Asset tokens (on-chain). Neither side can cheat because both are locked by the same HTLC hash.

                    SAME HASH LOCKS BOTH SIDES
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  SHA256(preimage)   β”‚
                    β”‚  = payment_hash     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                             β”‚
    Lightning Side                  Taproot Side
    (Buyer's BTC)                  (Seller's Tokens)
              β”‚                             β”‚
    Payment HELD                   Tokens LOCKED
    by HTLC                       by same HTLC
              β”‚                             β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                    PREIMAGE REVEALED
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ Both sides settle  β”‚
                    β”‚ simultaneously     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

10-Stage Pipeline

Stage Name Duration What Happens
0 Inspector Validation <1ms Risk score check, approve/reject
1 Security Checks <1ms 6 layers verified
2 HTLC Creation <1ms Single hash/preimage locks both sides
3 Lightning Invoice <1ms Bolt11 invoice locked to HTLC hash
4 Edge Node RFQ <1ms Price quote with 0.1-0.5% spread
5 Payment Routing 200-1000ms 2-hop Lightning payment, HELD by HTLC
6 Lightning Loop 100-300ms Off-chain β†’ on-chain bridge
7 Submarine Swap 50-150ms Preimage reveal = atomic settlement
8 HTLC Verification <1ms SHA256(preimage) == payment_hash
9 Certificate <1ms Full HTLC chain + atomic proof

Total: ~500-1500ms per transaction. Average across 4 items: 908ms.

Verifying a Certificate

Anyone can verify a submarine swap certificate:

  1. HTLC Check: SHA256(payment_preimage) must equal payment_hash
  2. Atomicity Check: Both Lightning and Taproot sides reference the same payment_hash
  3. Taproot Check: taproot_tx_hash can be verified on the Bitcoin blockchain
  4. Atomic Proof Check: SHA256(preimage:taproot_tx:amount_sats) must match atomic_proof
Screenshot 2026-04-12 at 5 41 56β€―AM

πŸ€– Inspector Deep Dive

Company Risk Scoring (12 Features)

Each feature is normalized to 0-1 and weighted:

Feature Weight Scoring Logic
Runway Months 18% β‰₯18mo = 1.0, 12-18 = 0.7, 6-12 = 0.4, <6 = 0.1
Revenue Growth YoY 15% β‰₯100% = 1.0, 50-100 = 0.8, 0-50 = 0.5, negative = 0.2
Churn Rate 12% ≀2% = 1.0, 2-5% = 0.8, 5-10% = 0.5, >10% = 0.2
Gross Margin 10% β‰₯70% = 1.0, 50-70% = 0.7, 30-50% = 0.4, <30% = 0.2
Burn Efficiency 10% Cash/burn ratio scaled
Lead Investor 8% Sequoia/a16z = 1.0, known VC = 0.7, angel = 0.4
Funding Efficiency 7% Valuation per dollar raised
Team Strength 5% Team size and track record
Customer Concentration 5% Revenue spread across customers
NPS Score 5% Net Promoter Score
Market Risk 3% External market conditions
Regulatory Risk 2% Legal and compliance risk

Final score = weighted sum Γ— 100. Tiers: Low Risk (75+), Medium (60-74), Medium-High (45-59), High (<45).

P2P Borrower Scoring (9 Features)

Feature Weight
Credit Score 22%
Default Probability 20%
Debt-to-Income Ratio 15%
Employment Stability 12%
Income Level 10%
Collateral 8%
Payment History 5%
Identity Verification 4%
Income Verification 4%

Grades: A+ (80+), A (70-79), B (60-69), C (50-59), D (40-49), F (<40).

Inspector Pipeline

Listing submitted
    β”‚
    β”œβ”€ 1. Ownership verification (Merkle proof + certificate check)
    β”œβ”€ 2. Risk scoring (12 or 9 weighted features)
    β”œβ”€ 3. Price validation (risk-adjusted ceiling)
    β”œβ”€ 4. Decision: approved / manual_review / rejected
    └─ 5. Gemini AI generates natural language explanation

Screenshot 2026-04-12 at 3 57 36β€―AM

πŸ“‘ API Reference

AI Inspector β€” Port 8000

Marketplace Data

Method Endpoint Description
GET /data/startups Browse 50 startups with AI risk scores
GET /data/startups/{id} Detailed startup analysis
GET /data/peers Browse 50 P2P borrowers with AI scores
GET /data/peers/{id} Detailed borrower analysis
GET /data/stats Platform-wide risk statistics

Checkout & Transactions

Method Endpoint Description
POST /checkout Multi-item cart checkout via submarine swap
POST /transaction/buy Single item purchase
POST /transaction/quote Get a price quote without executing

Risk Inspection

Method Endpoint Description
POST /inspect/company Full company risk analysis
POST /inspect/peer P2P borrower risk analysis
POST /inspect/price Quick price validation

Taproot Assets

Method Endpoint Description
POST /taproot/mint Mint new Taproot Asset tokens
POST /taproot/transfer Transfer tokens between wallets
GET /taproot/proof/{asset_id}/{address} Ownership proof with Merkle path
GET /taproot/verify/{asset_id}/{address}/{quantity} Verify ownership
GET /taproot/assets List all Taproot assets

Merkle Anchoring

Method Endpoint Description
POST /merkle/anchor-batch Build tree, return root for Ethereum
POST /merkle/verify Verify a certificate proof
GET /merkle/batches List all anchored batches

Security

Method Endpoint Description
GET /security/status Security configuration
GET /security/audit Request audit log
POST /security/generate-key Generate new API key
Screenshot 2026-04-12 at 5 38 56β€―AM

Backend API β€” Port 8001

Authentication

Method Endpoint Description
POST /auth/nonce Generate SIWE nonce
POST /auth/login SIWE login, returns JWT
POST /auth/demo-login Demo mode (investor/startup/inspector)

Wallet

Method Endpoint Description
POST /wallet/deposit Deposit USD
POST /wallet/purchase Atomic buy (debit buyer, credit seller)
GET /wallet/{address} Wallet balance
GET /wallet/{address}/history Transaction history

Loyalty

Method Endpoint Description
POST /loyalty/login?wallet=xxx Daily login + streak
GET /loyalty/{wallet} Full loyalty profile
GET /loyalty/board/top Leaderboard

πŸ— Architecture

Services

Service Port Location Stack
AI Inspector 8000 backend/ai_inspector/ Python 3.9, FastAPI
Backend API 8001 backend/ Python 3.12, FastAPI, MongoDB
Frontend 5173 src/ React 18, Vite

Data Flow

User clicks "Buy" on marketplace
        β”‚
        β–Ό
Frontend sends POST /checkout to AI Inspector (port 8000)
        β”‚
        β–Ό
β”Œβ”€ Stage 0: Inspector validates listing (risk score check)
β”œβ”€ Stage 1: Security checks (6 layers)
β”œβ”€ Stage 2: HTLC created (atomic lock β€” binds both sides)
β”œβ”€ Stage 3: Lightning invoice (bolt11, locked to HTLC hash)
β”œβ”€ Stage 4: Edge node RFQ (spread: 0.1-0.5%)
β”œβ”€ Stage 5: Lightning payment routed (HELD by HTLC)
β”œβ”€ Stage 6: Lightning Loop bridges off-chain β†’ on-chain
β”œβ”€ Stage 7: Submarine swap β€” preimage revealed, both sides settle
β”œβ”€ Stage 8: HTLC verification (SHA256 proof)
└─ Stage 9: Certificate generated with full HTLC chain
        β”‚
        β–Ό
Frontend updates Portfolio (holdings, transactions, wallet balance)
Backend (port 8001) persists to MongoDB Atlas

πŸ›  Tech Stack

Layer Technology Purpose
Backend FastAPI (Python) Async REST APIs with auto-docs
Database MongoDB Atlas Document store, cloud-hosted
Frontend React + Vite Component-based SPA with HMR
Payments Lightning Network Sub-second Bitcoin settlement
Tokens Taproot Assets Bitcoin-native tokenization
Smart Contracts Solidity (Sepolia) Merkle root anchoring
AI Google Gemini 2.0 Flash Natural language risk explanations
Risk Engine Custom Python 12-feature weighted scoring
Cryptography SHA-256, HMAC-SHA256 Merkle trees, HTLC, request signing
Auth MetaMask + SIWE + JWT Ethereum wallet login
Wallet Alby (WebLN) Lightning wallet connection

✨ Features

For Investors

  • Browse 100+ listings (50 startups + 50 P2P) with AI risk scores
  • Buy shares via Lightning β€” settlement in under 1 second
  • Portfolio with real-time holdings, transaction history, wallet balance
  • Submarine swap certificates with cryptographic proof of ownership
  • Loyalty rewards: 5 tiers, streak multipliers, achievements

For Startups

  • Tokenize equity as Taproot Assets on Bitcoin
  • List shares for primary fundraising
  • AI Inspector validates every listing before it goes live
  • Merkle proof of ownership anchored to Ethereum

For Inspectors

  • Admin panel with pending listing queue
  • Approve/reject listings based on AI risk analysis
  • Anchor Merkle batches to Ethereum Sepolia
  • Full audit trail of every decision

πŸš€ Getting Started

Prerequisites

  • Python 3.9+ (AI Inspector)
  • Python 3.12 (Backend β€” via Homebrew: brew install [email protected])
  • Node.js 18+ (Frontend β€” brew install node)
  • MongoDB Atlas account (free M0 tier)
  • Gemini API key (free at ai.google.dev)

1. Clone the Repository

git clone https://github.com/Nezha-Amine/NoBell.git
cd NoBell

2. Set Up AI Inspector (Port 8000)

cd backend/ai_inspector

# Install dependencies
pip install fastapi uvicorn pandas httpx python-dotenv

# Create .env file
cat > .env << EOF
LLM_PROVIDER=gemini
GEMINI_API_KEY=your_gemini_api_key_here
BTC_PRICE_USD=65000
MAX_TRANSACTION_USD=100000
EOF

# Start the service
python3 main.py

The AI Inspector runs at http://localhost:8000. Swagger docs at http://localhost:8000/docs.

3. Set Up Backend (Port 8001)

⚠️ Important: Campus WiFi may block MongoDB Atlas TLS connections. Use phone hotspot if you get connection errors.

cd backend

# Create virtual environment with Python 3.12
python3.12 -m venv venv312
source venv312/bin/activate

# Install dependencies
pip install fastapi uvicorn motor beanie python-dotenv pyjwt certifi httpx

# Create .env file
cat > .env << EOF
MONGODB_URL=mongodb+srv://Nobell:[email protected]/NoBell
MONGODB_DB=NoBell
JWT_SECRET=nobell_jwt_secret_2026
DEMO_MODE=true
EOF

# Seed the database (with AI Inspector running on port 8000)
python seed_data.py
python seed_merkle.py
python seed_wallets.py
python seed_transactions.py

# Start the service
uvicorn main:app --host 0.0.0.0 --port 8001 --reload

4. Set Up Frontend

cd ..  # back to project root
npm install
npm run dev

Frontend runs at http://localhost:5173.

5. Open the App

  1. Open http://localhost:5173 in your browser
  2. Click "Demo as Investor" to explore as an investor
  3. Click "Demo as Inspector" to access the admin panel
  4. Or connect MetaMask for real wallet authentication

Example: Checkout API Call

curl -X POST http://localhost:8000/checkout \
  -H "Content-Type: application/json" \
  -d '{
    "buyer_wallet": "bc1q_kunal_investor",
    "cart": [
      {"asset_id": "STP-001", "quantity": 10},
      {"asset_id": "STP-002", "quantity": 5},
      {"asset_id": "P2P-004", "quantity": 1}
    ]
  }'

Response includes: 10-stage pipeline per item, submarine swap certificates, HTLC proofs, Taproot tx hashes, Lightning fees, settlement time, portfolio update.


πŸ—„ Database Schema

MongoDB Atlas Collections

Collection Documents Description
startups 50 Company financial data (revenue, runway, churn, margins)
peers 50 P2P borrower data (credit score, income, debt ratios)
taproot_assets 70 Minted Taproot Asset tokens
ownership_certificates 70 Certificates with valid Merkle proofs
merkle_batches 1 Anchored Merkle tree (root for Ethereum)
transfers 15 Token transfer records
users 7 User accounts (demo + MetaMask)
loyalty 5 Loyalty points, tiers, streaks
wallets 6 USD wallet balances
wallet_transactions 16+ Deposit, purchase, sale records
orders 5+ Checkout order records
transactions Varies Individual submarine swap transactions
certificates Varies Full submarine swap certificates


πŸ”’ Security

8 Security Layers

# Layer Protection
1 API Key Auth X-API-Key header required
2 HMAC-SHA256 Signing Request body signature prevents tampering
3 Data Encryption Sensitive fields encrypted (preimages, proofs)
4 Rate Limiting 100/min per IP, 30/min per wallet
5 Audit Logging Every request logged (IP, timestamp, action)
6 Response Integrity SHA-256 hash on every response
7 Input Sanitization SQL injection, XSS, script tag protection
8 Security Headers HSTS, X-Frame-Options, no-cache

Transaction Security

Check What It Prevents
Wallet validation Malformed or blocked addresses
Rate limiting Transaction flooding / DDoS
Amount limits Abnormally large transactions
Self-trade detection Wash trading (buying from yourself)
Double-spend protection Same transaction processed twice
Risk-adjusted limits High-risk listings get lower transaction caps
HTLC verification Fake or tampered preimages

🎬 Demo Walkthrough

As an Investor

  1. Open http://localhost:5173
  2. Click "Demo as Investor"
  3. Marketplace: See 100 listings with AI risk scores, recommendations, growth metrics
  4. Buy: Click NovaMed AI β†’ set quantity β†’ "Pay with Lightning ⚑"
  5. Watch: 10-stage submarine swap pipeline animates in real-time
  6. Certificate: See HTLC ID, payment hash, Taproot TX, atomic proof
  7. Portfolio: Wallet balance deducted, holdings updated, transaction logged
  8. Sell: Go to Sell Shares β†’ select NovaMed AI β†’ set price β†’ AI Inspector validates
  9. Rewards: See loyalty points, tier progress, streak multiplier

As an Inspector

  1. Click "Demo as Inspector"
  2. Admin Panel: See pending listings waiting for review
  3. Approve/Reject: Each listing shows price deviation and risk data
  4. Anchor Batch: Click to build Merkle tree and get root for Ethereum

In Postman

GET  http://localhost:8000/data/startups          β€” All 50 startups with AI scores
GET  http://localhost:8000/data/stats             β€” Platform risk statistics
POST http://localhost:8000/checkout               β€” Full submarine swap checkout
GET  http://localhost:8000/taproot/assets          β€” All Taproot assets
POST http://localhost:8000/merkle/verify           β€” Verify a certificate proof
GET  http://localhost:8000/security/status          β€” Security configuration
GET  http://localhost:8000/security/audit           β€” Request audit log
GET  http://localhost:8001/wallet/bc1q_kunal_investor/history β€” Transaction history
GET  http://localhost:8001/loyalty/bc1q_kunal_investor       β€” Loyalty profile


πŸ™ Acknowledgments

  • Lightning Labs β€” synthlock and justjason (Discord) for guiding the submarine swap architecture
  • MIT Bitcoin Hackathon β€” for the platform and mentorship
  • Google Gemini β€” AI-powered risk explanations
  • OpenZeppelin β€” MerkleProof.sol reference implementation
  • Taproot Assets Protocol β€” Lightning Labs' token standard on Bitcoin

πŸ“„ License

MIT License β€” see LICENSE for details.


Built with Bitcoin. Secured by Lightning. Powered by AI.
MIT Bitcoin Hackathon 2026 β€” Team NoBell

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors