This commit implements a complete blockchain-based plant tracking system that preserves lineage across clones, seeds, and all plant offspring while connecting growers through geographic proximity. Features implemented: - Custom blockchain with proof-of-work consensus - Plant registration and cloning with lineage tracking - Geographic discovery to find nearby plants and growers - Integration with plants.net API for plant identification - Comprehensive web UI for plant management - RESTful API endpoints for all operations - Network statistics and visualization Core Components: - lib/blockchain/: PlantBlock, PlantChain, and blockchain manager - lib/services/: plants.net API and geolocation services - pages/api/plants/: REST API endpoints for all operations - pages/: Frontend UI pages for registration, exploration, and lineage Technical Details: - TypeScript for type safety - Next.js for server-side rendering - Tailwind CSS for responsive design - JSON file-based blockchain storage - Haversine distance calculations for geolocation - OpenStreetMap integration for geocoding This system enables large-scale adoption by: - Making plant lineage tracking accessible to everyone - Connecting local communities through plant sharing - Providing immutable proof of plant provenance - Supporting unlimited generations of plant propagation - Scaling from individual growers to global networks Documentation includes comprehensive README with: - Quick start guide - API reference - Architecture details - Scaling recommendations - Use cases for various audiences - Roadmap for future enhancements
81 lines
1.7 KiB
TypeScript
81 lines
1.7 KiB
TypeScript
// Plant Blockchain Types
|
|
|
|
export interface PlantLocation {
|
|
latitude: number;
|
|
longitude: number;
|
|
address?: string;
|
|
city?: string;
|
|
country?: string;
|
|
}
|
|
|
|
export interface PlantOwner {
|
|
id: string;
|
|
name: string;
|
|
email: string;
|
|
walletAddress?: string;
|
|
}
|
|
|
|
export interface PlantData {
|
|
id: string;
|
|
commonName: string;
|
|
scientificName?: string;
|
|
species?: string;
|
|
genus?: string;
|
|
family?: string;
|
|
|
|
// Lineage tracking
|
|
parentPlantId?: string; // Original plant this came from
|
|
propagationType?: 'seed' | 'clone' | 'cutting' | 'division' | 'grafting' | 'original';
|
|
generation: number; // How many generations from the original
|
|
|
|
// Plant lifecycle
|
|
plantedDate: string;
|
|
harvestedDate?: string;
|
|
status: 'sprouted' | 'growing' | 'mature' | 'flowering' | 'fruiting' | 'dormant' | 'deceased';
|
|
|
|
// Location and ownership
|
|
location: PlantLocation;
|
|
owner: PlantOwner;
|
|
|
|
// Plant network
|
|
childPlants: string[]; // IDs of clones and seeds from this plant
|
|
|
|
// Additional metadata
|
|
notes?: string;
|
|
images?: string[];
|
|
plantsNetId?: string; // ID from plants.net API
|
|
|
|
// Timestamps
|
|
registeredAt: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
export interface BlockData {
|
|
index: number;
|
|
timestamp: string;
|
|
plant: PlantData;
|
|
previousHash: string;
|
|
hash: string;
|
|
nonce: number;
|
|
}
|
|
|
|
export interface PlantLineage {
|
|
plantId: string;
|
|
ancestors: PlantData[];
|
|
descendants: PlantData[];
|
|
siblings: PlantData[]; // Other plants from the same parent
|
|
generation: number;
|
|
}
|
|
|
|
export interface NearbyPlant {
|
|
plant: PlantData;
|
|
distance: number; // in kilometers
|
|
owner: PlantOwner;
|
|
}
|
|
|
|
export interface PlantNetwork {
|
|
totalPlants: number;
|
|
totalOwners: number;
|
|
species: { [key: string]: number };
|
|
globalDistribution: { [country: string]: number };
|
|
}
|