CupTrace solves the critical "trust gap" in African agricultural supply chains. By leveraging Cardano's eUTxO model and metadata capabilities, we provide an immutable history of every coffee batch—from the moment cherries are picked to the final export certificate.
Rwanda produces some of the world's best coffee, but:
- Farmers often face delayed payments and lack credit history.
- Buyers cannot verify if the "Single Origin" label is authentic.
- Data is fragmented across paper receipts and siloed databases.
A Hybrid Traceability System that combines the speed of Web2 with the trust of Web3:
- Immutable History: Harvests, processing, and QC results are recorded on-chain.
- Fair Payments: Smart contracts facilitate transparent payment records.
- Digital Identity: Each batch gets a unique NFT (Non-Fungible Token) acting as its digital passport.
One of CupTrace's key innovations is our "Lazy Minting" workflow, designed to minimize blockchain congestion and cost while maximizing UX:
- Stage 1: Offline/Local: Farmers and Station Agents collect data offline. It syncs to our PostgreSQL database immediately.
- Stage 2: Virtual Batch: As processing happens (Washing -> Drying -> Grading), "Virtual" transactions are recorded internally.
- Stage 3: QC Approval: When Quality Control approves a batch, a "Shadow UTxO" is created on-chain.
- Stage 4: Final Minting: Only upon Final Export/Completion is the comprehensive Batch NFT minted. This NFT contains the entire provenance history (IPFS hash of metadata + previous transaction hashes) in its metadata.
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 14, Tailwind, Shadcn UI | Consumer App & Dashboards |
| Backend | Node.js, Express, Prisma | API, Business Logic, Caching |
| Database | PostgreSQL (Supabase) | Relational Data & User Mgmt |
| Blockchain | Cardano (Preprod) | Immutable Record Layer |
| Contracts | Aiken | Smart Contract Validators |
| Storage | IPFS (Pinata) | Decentralized Document Storage |
Our core logic resides in contracts/, utilizing the Aiken language for safety and expressiveness.
| Contract | Path | Function |
|---|---|---|
| Batch NFT | policies/batch_nft.aiken |
Policies ensuring only authorized Factory wallets can mint a Batch NFT. Enforces uniqueness of Lot IDs. |
| Traceability | validators/batch_traceability.aiken |
Holds the state of a batch on-chain. Ensures metadata updates (e.g., changing stage from Drying to Milling) preserve history. |
| Stage Guard | validators/stage_transition.aiken |
Enforces the strict supply chain DAG (Farmers -> Station -> Factory -> Export). Prevents illegal jumps. |
Follow these steps to deploy CupTrace locally for testing or adjudication.
- Node.js 18+ & npm/yarn
- Aiken (for contract compilation)
- A Supabase Project (or local PostgreSQL)
- Blockfrost Project ID (Cardano Preprod)
git clone https://github.com/aime-stack/cuptrace.git
cd cuptracecd backend
npm install
# Environment Configuration
cp .env.example .envRequired .env Variables:
PORT=4000
DATABASE_URL="postgresql://postgres:[PASSWORD]@db.supabase.co:5432/postgres"
JWT_SECRET="super-secret-key-change-me"
# Blockchain Configuration
CARDANO_NETWORK="preprod"
BLOCKFROST_API_KEY="preprod..."
WALLET_PRIVATE_KEY="ed25519_sk..." # Creating agent wallet keyRun Database Migrations & Start:
npx prisma generate
npx prisma migrate dev
npm run devcd ../frontend
npm install
npm run devAccess the app at http://localhost:3000.
To verify the simplified flow designed for the hackathon:
- Log in as Station Agent (email:
agent@cuptrace.com, pw:password123- if seeded). - Go to "Register Harvest".
- Select a Farmer (e.g., "Jean Bosco") and enter harvest details (Weight: 50kg, Quality: Grade A).
- Observation: This saves to DB instantly. Status:
Pending Processing.
- Navigate a batch through the pipeline:
Washing->Fermenting->Drying. - Each step timestamps the batch.
- Log in as QC Agent (
qc@cuptrace.com). - Select a
Driedbatch and click "Approve Quality". - Enter Cupping Score (e.g., 86.5).
- Action: System generates an IPFS Metadata file and creates a QC Approval UTxO on Cardano Preprod.
- Log in as Factory Manager.
- Mark batch as
Export Ready. - Check Output: The system triggers
mintBatchNFT():- Mints a CIP-68 compliant NFT.
- Mints a QR Code pointing to
cuptrace.com/verify/[batch-id].
- Go to
http://localhost:3000/verify. - Scan the generated QR code (or enter the Lot ID).
- Validation: You will see a "Verified on Cardano" badge with a link to the Transaction Hash on CardanoScan (Preprod).
Built with ❤️ by the CupTrace Team for the Cardano Community.
- Aime P. Mwizerwa - Lead Developer & Architect
- Etienne TUYIHAMYE - Smart Contract Engineer (Aiken)
- Iragena D. - Backend Specialist
- Didier I. - UI/UX Designer
- Ireme Promesse - Project Supervisor
This project is open-source and available under the MIT License.