Skip to content

FlowNet is a decentralized delivery network where autonomous agents connect customers, local shops, and delivery partners. Users order through an AI assistant, shops receive and manage requests, and delivery agents negotiate prices and complete deliveries automatically.

License

Notifications You must be signed in to change notification settings

tejus-fetch/FlowNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowNet

FlowNet is a decentralized delivery network where autonomous agents connect customers, local shops, and delivery partners. Users order through an AI assistant, shops receive and manage requests, and delivery agents negotiate prices and complete deliveries automatically.


📋 Table of Contents


🎯 Project Overview

FlowNet is a multi-layered decentralized delivery platform built on blockchain technology (CosmWasm) with autonomous agent negotiation. The system consists of:

  • Smart Contract Layer: Handles escrow management and secure payment settlement between businesses and delivery partners
  • Protocol Layer: Implements autonomous agent logic for negotiation, routing, and contract interactions
  • Client Applications: Web interfaces for businesses and delivery partners to manage orders and operations

FlowNet Pitch & Demo (78 MB)


🏗️ Architecture

The FlowNet architecture follows a layered approach:

┌─────────────────────────────────────────────────────┐
│         Client Applications (Next.js)               │
│  ┌──────────────────────┬──────────────────────┐   │
│  │   Business App       │   Delivery App       │   │
│  │  (Order Management)  │ (Delivery Tracking)  │   │
│  └──────────────────────┴──────────────────────┘   │
└─────────────────────────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────┐
│      Protocol Layer (Python Agents)                 │
│  ┌──────────────────────────────────────────────┐  │
│  │  • Autonomous Agent Negotiation              │  │
│  │  • Payment Processing & Settlement           │  │
│  │  • Contract Orchestration                    │  │
│  │  • Business & Delivery Agent Logic           │  │
│  └──────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────┐
│    Smart Contract Layer (CosmWasm/Rust)            │
│  ┌──────────────────────────────────────────────┐  │
│  │  Escrow Contract                              │  │
│  │  • Secure Payment Escrow                     │  │
│  │  • Contract State Management                 │  │
│  │  • Trust & Settlement Logic                  │  │
│  └──────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────┘

📁 Directory Structure

FlowNet/
├── contract/                      # Smart Contract (CosmWasm)
│   ├── contracts/
│   │   └── flownet_escrow/       # Escrow smart contract
│   │       ├── src/
│   │       │   ├── lib.rs        # Contract library entry point
│   │       │   ├── contract.rs   # Core contract logic
│   │       │   ├── msg.rs        # Message types
│   │       │   ├── state.rs      # Contract state management
│   │       │   └── error.rs      # Error definitions
│   │       ├── artifacts/        # Compiled contract artifacts
│   │       ├── schema/           # JSON schemas for contract messages
│   │       └── Cargo.toml        # Rust dependencies
│   ├── jenesis.toml              # Deployment configuration
│   └── pyproject.toml            # Python dependencies for deployment tools
│
├── protocol/                      # Protocol & Agent Layer (Python)
│   ├── business_agent.py         # Autonomous business agent logic
│   ├── delivery_agent.py         # Autonomous delivery agent logic
│   ├── contract.py               # Contract interaction utilities
│   ├── models.py                 # Data models (Pydantic/uAgents)
│   ├── utils.py                  # Utility functions
│   ├── pyproject.toml            # Python dependencies
│   └── .env                      # Environment variables (not in repo)
│
├── business-app/                 # Business Web Application (Next.js)
│   ├── app/
│   │   ├── layout.tsx            # Root layout
│   │   ├── page.tsx              # Business dashboard
│   │   └── globals.css           # Global styles
│   ├── public/                   # Static assets
│   ├── package.json              # Node dependencies
│   ├── tsconfig.json             # TypeScript configuration
│   ├── next.config.ts            # Next.js configuration
│   └── tailwindcss.config.js     # TailwindCSS configuration
│
├── delivery-app/                 # Delivery Partner Web Application (Next.js)
│   ├── app/
│   │   ├── layout.tsx            # Root layout
│   │   ├── page.tsx              # Delivery dashboard
│   │   └── globals.css           # Global styles
│   ├── public/                   # Static assets
│   ├── package.json              # Node dependencies
│   ├── tsconfig.json             # TypeScript configuration
│   ├── next.config.ts            # Next.js configuration
│   └── tailwindcss.config.js     # TailwindCSS configuration
│
├── LICENSE                       # Project license
└── README.md                     # This file

🚀 Getting Started

Prerequisites

  • Rust: For smart contract development (1.70+)
  • Python: 3.12+ (for protocol and agent layer)
  • Node.js: 18+ (for web applications)
  • CosmWasm CLI: For smart contract deployment

Quick Setup

1. Smart Contract Setup

cd contract
cargo build --release
cargo test

2. Protocol Layer Setup

cd protocol
pip install -e .
# Configure environment variables in .env
python business_agent.py  # Start business agent
python delivery_agent.py  # Start delivery agent

3. Business App Setup

cd business-app
npm install
npm run dev
# Access at http://localhost:3000

4. Delivery App Setup

cd delivery-app
npm install
npm run dev
# Access at http://localhost:3001 (or next available port)

🔧 Components

Contract Module (/contract)

Purpose: Smart contract for handling secure escrow and payment settlement on the blockchain.

Key Features:

  • Escrow Management: Secure holding of payment between businesses and delivery partners
  • Payment Settlement: Automated fund release based on contract completion
  • State Management: Tracks all active and completed escrows
  • Error Handling: Robust error types for various failure scenarios

Key Files:

  • contract.rs - Implements execute/query handlers for contract messages
  • msg.rs - Defines message types (InstantiateMsg, ExecuteMsg, QueryMsg)
  • state.rs - Manages contract state and escrow details
  • error.rs - Custom error types for contract operations
  • schema/ - JSON schemas documenting contract interface

Tech Stack: Rust, CosmWasm, Cargo


Protocol Module (/protocol)

Purpose: Autonomous agent layer that orchestrates business logic, agent negotiation, and contract interactions.

Key Components:

business_agent.py

  • Manages business-side operations
  • Receives delivery requests from customers
  • Initiates escrow contracts for orders
  • Handles payment confirmation and settlement

delivery_agent.py

  • Manages delivery partner operations
  • Negotiates delivery prices and timing
  • Proposes delivery terms to the business
  • Completes deliveries and triggers payment release

contract.py

  • Provides utilities for interacting with the smart contract
  • Handles contract deployment and initialization
  • Manages escrow creation and state queries
  • Facilitates payment settlement calls

models.py

  • DeliveryRequest: Request data (location, order info)
  • DriverResponse: Driver's proposal (pricing, ETA, distance)
  • ContractCreationResponse: Escrow contract details
  • Response: Standard response wrapper

utils.py

  • Helper functions for calculations, formatting, and common operations

Tech Stack: Python 3.12+, uAgents, LangChain, python-dotenv

Environment Variables Needed:

  • Blockchain RPC endpoint
  • Contract address
  • Agent wallet addresses
  • OpenAI API key (for LLM features)

Business App (/business-app)

Purpose: Web dashboard for shop owners and business managers to receive, manage, and track orders.

Features:

  • View incoming delivery requests
  • Review delivery proposals from agents
  • Accept/reject delivery terms
  • Track order status and delivery progress
  • Manage payment settlements

Tech Stack: Next.js 16, React 19, TypeScript, TailwindCSS

Development:

cd business-app
npm run dev          # Start dev server
npm run build        # Production build
npm run lint         # Run ESLint

Delivery App (/delivery-app)

Purpose: Web dashboard for delivery partners to view available orders and manage deliveries.

Features:

  • View available delivery requests
  • Submit delivery proposals with pricing and ETA
  • Track accepted deliveries
  • Manage delivery status and completion
  • View earnings and payment history

Tech Stack: Next.js 16, React 19, TypeScript, TailwindCSS

Development:

cd delivery-app
npm run dev          # Start dev server
npm run build        # Production build
npm run lint         # Run ESLint

🛠️ Development

Smart Contract Development

  1. Modify contract logic in contract/contracts/flownet_escrow/src/
  2. Update message types in msg.rs if needed
  3. Update state in state.rs if needed
  4. Add tests in contract module
  5. Build and test:
    cd contract
    cargo build --release
    cargo test
  6. Generate JSON schemas:
    cargo schema

Protocol Layer Development

  1. Update agent logic in business_agent.py or delivery_agent.py
  2. Modify data models in models.py
  3. Update contract interactions in contract.py
  4. Test with:
    cd protocol
    python -m pytest  # If tests are available

Frontend Development

  1. Update pages in app/page.tsx
  2. Create new components in app/components/
  3. Use TypeScript for type safety
  4. Style with TailwindCSS
  5. Test in dev environment:
    npm run dev

Deployment

  • Smart Contract: Deploy using CosmWasm CLI with jenesis.toml configuration
  • Protocol Agents: Run on servers with network access to blockchain and agents
  • Web Apps: Deploy on Vercel (Next.js native), AWS, or similar hosting

📝 License

See LICENSE for details.


🤝 Contributing

Contributions are welcome! Please follow the existing code structure and add tests for new features.


📧 Support

For issues or questions, please open an issue on the repository.


⚠️ Development Status

This project is currently in active development and is not yet production-ready. Features, APIs, and architecture may change significantly. Please use caution if deploying to production systems.

About

FlowNet is a decentralized delivery network where autonomous agents connect customers, local shops, and delivery partners. Users order through an AI assistant, shops receive and manage requests, and delivery agents negotiate prices and complete deliveries automatically.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •