image imagewidth (px) 480 480 |
|---|
GarbinAI
A modern AI platform for discovering, managing, and collaborating on Hugging Face models and Spaces. GarbinAI provides a comprehensive marketplace experience with advanced features for model management, community collaboration, and contribution tracking.
๐ ๏ธ Tech Stack
Frontend
- Next.js 15.5 - React framework with App Router and Turbopack
- React 19 - UI library for building interactive interfaces
- TypeScript 5 - Type-safe development
- TailwindCSS 4 - Utility-first CSS framework for styling
Backend
- Next.js API Routes - Serverless API endpoints
- NextAuth 5 - Authentication with OAuth integration
- PostgreSQL - Relational database for data persistence
- node-postgres (pg) - PostgreSQL client for Node.js
Integrations
- Hugging Face Hub - AI model and space management
- MetaMask - Web3 wallet integration for Ethereum
- Hugging Face OAuth - Seamless user authentication
Development Tools
- Turbopack - Next-generation bundler for faster builds
- PostCSS - CSS transformations and processing
๐ Features
Core Functionality
- Model Marketplace: Browse and discover AI models with advanced filtering and search
- Spaces Management: Create and manage Hugging Face Spaces with interactive demos
- File Management: Upload, organize, and track files with accurate commit history
- Pull Request System: Create, review, and merge contributions through a built-in PR system
- Discussion Forums: Engage with the community through model discussions and Q&A
- Contributor Tracking: Track contributions, metrics, and community engagement
- Commit History: View detailed commit history with accurate timestamps and file associations
Authentication & Integration
- Hugging Face OAuth: Seamless authentication using Hugging Face accounts
- MetaMask Integration: Connect Ethereum wallets for Web3 features
- Permission Management: Granular permission system for repository access
Blockchain & Web3 (Current)
- MetaMask Wallet Integration: Connect and manage Ethereum wallets directly in the platform
- Ethereum Mainnet Support: Full support for Ethereum mainnet transactions
- Wallet State Management: Real-time wallet connection status and account tracking
- Chain Switching: Programmatic network switching capabilities
- Auto-Reconnect: Automatic wallet reconnection on page reload
Performance & Caching
- Intelligent Caching: PostgreSQL-based caching for files, commits, and metadata
- 90-100% Accuracy: Advanced commit matching algorithms for accurate file timestamps
- Fast Performance: Optimized queries with indexed database tables
๐ Prerequisites
- Node.js 18+ and npm/yarn/pnpm
- PostgreSQL database (12+)
- Hugging Face Account with OAuth app credentials
- MetaMask (optional, for wallet features)
๐ ๏ธ Installation
1. Clone the Repository
git clone <repository-url>
cd garbin-ai
2. Install Dependencies
npm install
# or
yarn install
# or
pnpm install
3. Set Up Environment Variables
Create a .env.local file in the root directory:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/garbin_ai
# Hugging Face OAuth
HUGGINGFACE_CLIENT_ID=your_client_id
HUGGINGFACE_CLIENT_SECRET=your_client_secret
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_secret_key
# Optional: MetaMask
NEXT_PUBLIC_CHAIN_ID=1
4. Set Up Database
Run the database schema migration:
psql $DATABASE_URL -f database_tables.sql
This creates all necessary tables including:
- User authentication and sessions
- Model and space metadata
- File and commit caching
- Pull requests and discussions
- Contributor metrics
5. Run Development Server
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 in your browser.
๐ Project Structure
garbin-ai/
โโโ src/
โ โโโ app/ # Next.js App Router pages
โ โ โโโ api/ # API routes
โ โ โ โโโ auth/ # Authentication endpoints
โ โ โ โโโ models/ # Model management APIs
โ โ โ โโโ spaces/ # Space management APIs
โ โ โ โโโ upload/ # File upload endpoints
โ โ โโโ models/ # Model pages
โ โ โโโ spaces/ # Space pages
โ โ โโโ upload/ # Upload pages
โ โโโ components/ # React components
โ โโโ lib/ # Utility libraries
โ โ โโโ db.ts # Database utilities
โ โ โโโ huggingface.ts # Hugging Face API client
โ โ โโโ metamask.ts # MetaMask integration
โ โ โโโ spaces.ts # Space utilities
โ โโโ types/ # TypeScript type definitions
โโโ database_tables.sql # Database schema
โโโ scripts/ # Utility scripts
โโโ public/ # Static assets
๐ง Configuration
Hugging Face OAuth Setup
- Go to Hugging Face Settings
- Create a new OAuth application
- Set redirect URI to:
http://localhost:3000/api/auth/callback/huggingface - Copy Client ID and Secret to your
.env.local
Database Configuration
The application uses PostgreSQL with the following key tables:
- users: User accounts and authentication
- platform_models: Registered models metadata
- platform_spaces: Registered spaces metadata
- model_files: Cached file metadata
- model_commits: Cached commit history
- model_pull_requests: PR tracking
- contributor_metrics: Contribution statistics
See database_tables.sql for the complete schema.
๐ฏ Usage
Creating a Model
- Sign in with your Hugging Face account
- Navigate to "Create Model" or visit
/upload - Fill in model details (name, description, type, license)
- Upload files or connect to existing Hugging Face repository
- Your model will be registered and appear in the marketplace
Importing from Hugging Face
- Go to "Import Models" or visit
/models/import - Enter the Hugging Face model ID (e.g.,
username/model-name) - The model will be synced and added to your dashboard
Contributing to Models
- Navigate to a model page
- Click "Contribute" โ "Create Pull Request"
- Upload your changes
- Create a PR with description
- Model owners can review and merge contributions
Managing Spaces
- Create a new Space at
/spaces/create - Configure SDK (Gradio, Streamlit, etc.)
- Upload files and deploy
- Share your interactive demo with the community
๐ API Endpoints
Models
GET /api/models- List all modelsGET /api/models/[id]- Get model detailsPOST /api/models/register- Register a new modelGET /api/models/[id]/files- Get model filesGET /api/models/[id]/commits- Get commit historyGET /api/models/[id]/prs- List pull requestsPOST /api/models/[id]/sync- Sync model data
Spaces
GET /api/spaces- List all spacesGET /api/spaces/[id]- Get space detailsPOST /api/spaces/create- Create a new spacePOST /api/spaces/[id]/upload- Upload files to spaceGET /api/spaces/[id]/prs- List pull requests
Authentication
GET /api/auth/signin- Sign in pageGET /api/auth/callback/huggingface- OAuth callback
๐งช Development
Running Tests
npm run test
Building for Production
npm run build
npm start
Database Migrations
When updating the schema:
psql $DATABASE_URL -f database_tables.sql
๐ Troubleshooting
Database Connection Issues
Ensure your PostgreSQL database is running and DATABASE_URL is correctly set:
psql $DATABASE_URL -c "SELECT 1"
OAuth Authentication Fails
- Verify
HUGGINGFACE_CLIENT_IDandHUGGINGFACE_CLIENT_SECRETare correct - Check redirect URI matches your OAuth app settings
- Ensure
NEXTAUTH_URLmatches your deployment URL
File Upload Issues
- Check file size limits (configured in API routes)
- Verify Hugging Face API token has write permissions
- Review browser console for error messages
Cache Not Updating
Force refresh the cache:
curl -X POST http://localhost:3000/api/models/{modelId}/sync
๐ฎ Roadmap & Future Features
Blockchain & Fair-Pay System (Coming Soon)
GarbinAI is building a comprehensive blockchain-enabled fair-pay system for the AI supply chain. This will revolutionize how contributors are rewarded for their work.
Smart Contract Infrastructure
- Asset Registry: Tokenize datasets and models as NFTs/ERC-1155 tokens with off-chain storage pointers (IPFS/Filecoin/Arweave)
- Provenance Graph: On-chain weighted graph tracking contribution percentages and asset lineage
- Royalty Split Contracts: Automatic revenue distribution to all contributors via smart contracts
- License Enforcement: Smart contract-based licensing with usage gates before compute access
- Escrow & Arbitration: Dispute resolution system with escrow contracts for fair settlements
Fair-Pay Features
- Pay-on-Use Model: Automatic revenue splits triggered by real usage (training/inference)
- Usage Metering: AI Factory gateway signs usage receipts for transparent billing
- Multi-Stakeholder Payouts: Reward data owners, annotators, curators, model designers, trainers, and GPU providers
- Stablecoin Payments: Automatic distribution in stablecoins for global accessibility
- Immutable Receipts: Blockchain-verified usage records and payment history
Contributor Features
- Wallet-Linked Profiles: Connect contributor identities to blockchain wallets
- Reputation System: On-chain reputation tracking based on contribution quality
- Task Receipts: Mint lightweight NFTs/records for each labeled batch or contribution
- Transparent Payouts: Real-time visibility into earnings and payment history
- KYC Integration: Optional KYC at withdrawal thresholds for compliance
Cross-Chain Support
- Multi-Chain Architecture: Support for BSC, Polygon, Arbitrum, and Ethereum
- Chain-Agnostic Design: Flexible architecture allowing easy addition of new chains
- Low-Cost Transactions: Optimized for micro-payouts with low gas fees
Enterprise & Compliance
- License Templates: OpenRAIL-style and custom licensing with commercial terms
- Usage Analytics: Privacy-preserving metrics with optional ZK attestations
- Regulatory Compliance: Built-in support for KYC/AML at withdrawal points
- Audit Trails: Complete on-chain audit trail for all transactions and payouts
Additional Planned Features
- Streaming Payouts: Real-time payments during long training runs
- DAO Governance: Reputation-weighted curation DAO for dataset/model approvals
- Privacy-Preserving Metrics: TEEs or ZK attestations for usage tracking
- Enterprise SSO: Single Sign-On integration for enterprise customers
- Custom Invoicing: Enterprise billing and invoice generation
Note: These features are in active development. See the Proposal & Feasibility Report for detailed technical specifications.
๐ Documentation
- Quick Start Guide - Get started quickly
- Database Schema - Complete database structure
- Proposal & Feasibility Report - Blockchain fair-pay system design
- Hugging Face API Docs - External API reference
๐ก๏ธ Security
- OAuth tokens are securely stored in the database
- Access tokens are encrypted and never exposed to the client
- User permissions are validated on every API request
- SQL injection protection via parameterized queries
- CORS and CSRF protection via NextAuth
๐ค Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is private and proprietary.
๐ Blockchain Integration
Using MetaMask
The platform includes built-in MetaMask integration for Web3 features:
import { createMetaMaskManager } from '@/lib/metamask';
const wallet = createMetaMaskManager({
enforceChainId: 1, // Ethereum mainnet
autoReconnect: true,
});
// Connect wallet
await wallet.connect();
// Get current state
const state = wallet.getState();
console.log(state.accounts, state.chainId);
// Switch networks
await wallet.switchChain(137); // Polygon
// Disconnect
wallet.disconnect();
Wallet Status
The platform displays wallet connection status on the dashboard, showing:
- Connection state (connected/idle/unavailable)
- Connected account address
- Current network/chain ID
- Auto-reconnection status
๐ Acknowledgments
- Built with Next.js
- Integrated with Hugging Face
- Authentication via NextAuth.js
- Database powered by PostgreSQL
- Blockchain integration via MetaMask
๐ Support
For issues and questions:
- Open an issue on GitHub
- Check existing documentation
- Review the Quick Start Guide
Made with โค๏ธ for the AI community
- Downloads last month
- 396