JEBI
System Architecture

A runnable tech stack

FastAPI gateway + DeepSeek integration + unified JBP metering + Solidity on-chain attestation.

Layers

System layers

1Access layer · API Gateway
Auth · Rate limiting · Billing entry (JBP) · FastAPI + CORS
2Service layer · Business microservices
recommendation · supply-chain · quality-inspection · ledger
3Model layer · Jebi Brain (DeepSeek)
api.deepseek.com/v1 · deepseek-chat · prompt library · JSON output · demo mode
4Metering layer · Unified pricing
real-usage cost · role pricing · subscription 0 · ceil rounding
5Data & on-chain · Ledger + attestation
SQLite/PostgreSQL · ai_usage_logs · jbp_ledger · Solidity · consortium/public chain
API

API routes (the running demo is calling them)

Method & pathFunctionBilling
POST /api/v1/recommend/personalizedAI personalized recommendation (Jebi Brain)Charged JBP by role
POST /api/v1/billing/quotePrice quote (no charge)
GET /api/v1/users/{id}/balanceBalance query
POST /api/v1/users/{id}/topupJBP top-up (caps)
POST /api/v1/users/{id}/subscribeActivate subscription (demo helper)
POST /api/v1/users/{id}/refund7-day cooling-off refund
GET /api/v1/admin/usage/summaryUsage audit (cost vs charged)
Contracts

On-chain contracts & deployment

ContractStandardRoleKey fixes
JebiPointERC-20JBP points ledger (consortium chain)Whitelisted minters, reason-carrying mint/burn
CoffeeWarehouseReceiptERC-1155Coffee receipt (registration no.)uri() fallback · minter whitelist
RoastPackageTokenERC-721Roast-pack certificate (escrow)CEI · nonReentrant · existence checks

🔧 Deployment order

cd chain && npm install
npx hardhat test
npx hardhat run scripts/deploy.js --network localhost
Data Flow

Data flow of one cup of coffee

OrderUser scans to order, chooses payment
Order & pointsOrder Service creates the order; JBP granted on payment (1 CNY = 1 JBP)
AI profileJebi Brain updates the taste profile (meter first, price second)
InventoryReal-time deduction; below threshold triggers AI restock suggestion
On-chain attestationKey hashes anchored on chain after closing
Franchisee reportOwner app: profit, JBP consumption, AI suggestions, audit details
Stack

Tech stack at a glance

🐍 Backend

  • FastAPI + Uvicorn
  • SQLite (demo) / PostgreSQL (prod)
  • openai SDK (DeepSeek-compatible)

⛓️ On-chain

  • Solidity 0.8.24 + OZ v5
  • Hardhat (compile / test / deploy)
  • EVM cancun (OZ mcopy)

🌐 Frontend

  • Vanilla HTML/CSS/JS
  • Same-origin static mount via FastAPI
  • Jebi API client with graceful degradation