AmeerUlAman commited on
Commit
6c7f0ad
·
verified ·
1 Parent(s): c58c574

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -413
README.md CHANGED
@@ -1,413 +1,12 @@
1
- # GarbinAI
2
-
3
- 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.
4
-
5
- ## 🛠️ Tech Stack
6
-
7
- ### Frontend
8
- - **Next.js 15.5** - React framework with App Router and Turbopack
9
- - **React 19** - UI library for building interactive interfaces
10
- - **TypeScript 5** - Type-safe development
11
- - **TailwindCSS 4** - Utility-first CSS framework for styling
12
-
13
- ### Backend
14
- - **Next.js API Routes** - Serverless API endpoints
15
- - **NextAuth 5** - Authentication with OAuth integration
16
- - **PostgreSQL** - Relational database for data persistence
17
- - **node-postgres (pg)** - PostgreSQL client for Node.js
18
-
19
- ### Integrations
20
- - **Hugging Face Hub** - AI model and space management
21
- - **MetaMask** - Web3 wallet integration for Ethereum
22
- - **Hugging Face OAuth** - Seamless user authentication
23
-
24
- ### Development Tools
25
- - **Turbopack** - Next-generation bundler for faster builds
26
- - **PostCSS** - CSS transformations and processing
27
-
28
- ## 🚀 Features
29
-
30
- ### Core Functionality
31
- - **Model Marketplace**: Browse and discover AI models with advanced filtering and search
32
- - **Spaces Management**: Create and manage Hugging Face Spaces with interactive demos
33
- - **File Management**: Upload, organize, and track files with accurate commit history
34
- - **Pull Request System**: Create, review, and merge contributions through a built-in PR system
35
- - **Discussion Forums**: Engage with the community through model discussions and Q&A
36
- - **Contributor Tracking**: Track contributions, metrics, and community engagement
37
- - **Commit History**: View detailed commit history with accurate timestamps and file associations
38
-
39
- ### Authentication & Integration
40
- - **Hugging Face OAuth**: Seamless authentication using Hugging Face accounts
41
- - **MetaMask Integration**: Connect Ethereum wallets for Web3 features
42
- - **Permission Management**: Granular permission system for repository access
43
-
44
- ### Blockchain & Web3 (Current)
45
- - **MetaMask Wallet Integration**: Connect and manage Ethereum wallets directly in the platform
46
- - **Ethereum Mainnet Support**: Full support for Ethereum mainnet transactions
47
- - **Wallet State Management**: Real-time wallet connection status and account tracking
48
- - **Chain Switching**: Programmatic network switching capabilities
49
- - **Auto-Reconnect**: Automatic wallet reconnection on page reload
50
-
51
- ### Performance & Caching
52
- - **Intelligent Caching**: PostgreSQL-based caching for files, commits, and metadata
53
- - **90-100% Accuracy**: Advanced commit matching algorithms for accurate file timestamps
54
- - **Fast Performance**: Optimized queries with indexed database tables
55
-
56
- ## 📋 Prerequisites
57
-
58
- - **Node.js** 18+ and npm/yarn/pnpm
59
- - **PostgreSQL** database (12+)
60
- - **Hugging Face Account** with OAuth app credentials
61
- - **MetaMask** (optional, for wallet features)
62
-
63
- ## 🛠️ Installation
64
-
65
- ### 1. Clone the Repository
66
-
67
- ```bash
68
- git clone <repository-url>
69
- cd garbin-ai
70
- ```
71
-
72
- ### 2. Install Dependencies
73
-
74
- ```bash
75
- npm install
76
- # or
77
- yarn install
78
- # or
79
- pnpm install
80
- ```
81
-
82
- ### 3. Set Up Environment Variables
83
-
84
- Create a `.env.local` file in the root directory:
85
-
86
- ```env
87
- # Database
88
- DATABASE_URL=postgresql://user:password@localhost:5432/garbin_ai
89
-
90
- # Hugging Face OAuth
91
- HUGGINGFACE_CLIENT_ID=your_client_id
92
- HUGGINGFACE_CLIENT_SECRET=your_client_secret
93
-
94
- # NextAuth
95
- NEXTAUTH_URL=http://localhost:3000
96
- NEXTAUTH_SECRET=your_secret_key
97
-
98
- # Optional: MetaMask
99
- NEXT_PUBLIC_CHAIN_ID=1
100
- ```
101
-
102
- ### 4. Set Up Database
103
-
104
- Run the database schema migration:
105
-
106
- ```bash
107
- psql $DATABASE_URL -f database_tables.sql
108
- ```
109
-
110
- This creates all necessary tables including:
111
- - User authentication and sessions
112
- - Model and space metadata
113
- - File and commit caching
114
- - Pull requests and discussions
115
- - Contributor metrics
116
-
117
- ### 5. Run Development Server
118
-
119
- ```bash
120
- npm run dev
121
- # or
122
- yarn dev
123
- # or
124
- pnpm dev
125
- ```
126
-
127
- Open [http://localhost:3000](http://localhost:3000) in your browser.
128
-
129
- ## 📁 Project Structure
130
-
131
- ```
132
- garbin-ai/
133
- ├── src/
134
- │ ├── app/ # Next.js App Router pages
135
- │ │ ├── api/ # API routes
136
- │ │ │ ├── auth/ # Authentication endpoints
137
- │ │ │ ├── models/ # Model management APIs
138
- │ │ │ ├── spaces/ # Space management APIs
139
- │ │ │ └── upload/ # File upload endpoints
140
- │ │ ├── models/ # Model pages
141
- │ │ ├── spaces/ # Space pages
142
- │ │ └── upload/ # Upload pages
143
- │ ├── components/ # React components
144
- │ ├── lib/ # Utility libraries
145
- │ │ ├── db.ts # Database utilities
146
- │ │ ├── huggingface.ts # Hugging Face API client
147
- │ │ ├── metamask.ts # MetaMask integration
148
- │ │ └── spaces.ts # Space utilities
149
- │ └── types/ # TypeScript type definitions
150
- ├── database_tables.sql # Database schema
151
- ├── scripts/ # Utility scripts
152
- └── public/ # Static assets
153
- ```
154
-
155
- ## 🔧 Configuration
156
-
157
- ### Hugging Face OAuth Setup
158
-
159
- 1. Go to [Hugging Face Settings](https://huggingface.co/settings/oauth-applications)
160
- 2. Create a new OAuth application
161
- 3. Set redirect URI to: `http://localhost:3000/api/auth/callback/huggingface`
162
- 4. Copy Client ID and Secret to your `.env.local`
163
-
164
- ### Database Configuration
165
-
166
- The application uses PostgreSQL with the following key tables:
167
-
168
- - **users**: User accounts and authentication
169
- - **platform_models**: Registered models metadata
170
- - **platform_spaces**: Registered spaces metadata
171
- - **model_files**: Cached file metadata
172
- - **model_commits**: Cached commit history
173
- - **model_pull_requests**: PR tracking
174
- - **contributor_metrics**: Contribution statistics
175
-
176
- See `database_tables.sql` for the complete schema.
177
-
178
- ## 🎯 Usage
179
-
180
- ### Creating a Model
181
-
182
- 1. Sign in with your Hugging Face account
183
- 2. Navigate to "Create Model" or visit `/upload`
184
- 3. Fill in model details (name, description, type, license)
185
- 4. Upload files or connect to existing Hugging Face repository
186
- 5. Your model will be registered and appear in the marketplace
187
-
188
- ### Importing from Hugging Face
189
-
190
- 1. Go to "Import Models" or visit `/models/import`
191
- 2. Enter the Hugging Face model ID (e.g., `username/model-name`)
192
- 3. The model will be synced and added to your dashboard
193
-
194
- ### Contributing to Models
195
-
196
- 1. Navigate to a model page
197
- 2. Click "Contribute" → "Create Pull Request"
198
- 3. Upload your changes
199
- 4. Create a PR with description
200
- 5. Model owners can review and merge contributions
201
-
202
- ### Managing Spaces
203
-
204
- 1. Create a new Space at `/spaces/create`
205
- 2. Configure SDK (Gradio, Streamlit, etc.)
206
- 3. Upload files and deploy
207
- 4. Share your interactive demo with the community
208
-
209
- ## 🔍 API Endpoints
210
-
211
- ### Models
212
- - `GET /api/models` - List all models
213
- - `GET /api/models/[id]` - Get model details
214
- - `POST /api/models/register` - Register a new model
215
- - `GET /api/models/[id]/files` - Get model files
216
- - `GET /api/models/[id]/commits` - Get commit history
217
- - `GET /api/models/[id]/prs` - List pull requests
218
- - `POST /api/models/[id]/sync` - Sync model data
219
-
220
- ### Spaces
221
- - `GET /api/spaces` - List all spaces
222
- - `GET /api/spaces/[id]` - Get space details
223
- - `POST /api/spaces/create` - Create a new space
224
- - `POST /api/spaces/[id]/upload` - Upload files to space
225
- - `GET /api/spaces/[id]/prs` - List pull requests
226
-
227
- ### Authentication
228
- - `GET /api/auth/signin` - Sign in page
229
- - `GET /api/auth/callback/huggingface` - OAuth callback
230
-
231
- ## 🧪 Development
232
-
233
- ### Running Tests
234
-
235
- ```bash
236
- npm run test
237
- ```
238
-
239
- ### Building for Production
240
-
241
- ```bash
242
- npm run build
243
- npm start
244
- ```
245
-
246
- ### Database Migrations
247
-
248
- When updating the schema:
249
-
250
- ```bash
251
- psql $DATABASE_URL -f database_tables.sql
252
- ```
253
-
254
- ## 🐛 Troubleshooting
255
-
256
- ### Database Connection Issues
257
-
258
- Ensure your PostgreSQL database is running and `DATABASE_URL` is correctly set:
259
-
260
- ```bash
261
- psql $DATABASE_URL -c "SELECT 1"
262
- ```
263
-
264
- ### OAuth Authentication Fails
265
-
266
- 1. Verify `HUGGINGFACE_CLIENT_ID` and `HUGGINGFACE_CLIENT_SECRET` are correct
267
- 2. Check redirect URI matches your OAuth app settings
268
- 3. Ensure `NEXTAUTH_URL` matches your deployment URL
269
-
270
- ### File Upload Issues
271
-
272
- - Check file size limits (configured in API routes)
273
- - Verify Hugging Face API token has write permissions
274
- - Review browser console for error messages
275
-
276
- ### Cache Not Updating
277
-
278
- Force refresh the cache:
279
-
280
- ```bash
281
- curl -X POST http://localhost:3000/api/models/{modelId}/sync
282
- ```
283
-
284
- ## 🔮 Roadmap & Future Features
285
-
286
- ### Blockchain & Fair-Pay System (Coming Soon)
287
-
288
- 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.
289
-
290
- #### Smart Contract Infrastructure
291
- - **Asset Registry**: Tokenize datasets and models as NFTs/ERC-1155 tokens with off-chain storage pointers (IPFS/Filecoin/Arweave)
292
- - **Provenance Graph**: On-chain weighted graph tracking contribution percentages and asset lineage
293
- - **Royalty Split Contracts**: Automatic revenue distribution to all contributors via smart contracts
294
- - **License Enforcement**: Smart contract-based licensing with usage gates before compute access
295
- - **Escrow & Arbitration**: Dispute resolution system with escrow contracts for fair settlements
296
-
297
- #### Fair-Pay Features
298
- - **Pay-on-Use Model**: Automatic revenue splits triggered by real usage (training/inference)
299
- - **Usage Metering**: AI Factory gateway signs usage receipts for transparent billing
300
- - **Multi-Stakeholder Payouts**: Reward data owners, annotators, curators, model designers, trainers, and GPU providers
301
- - **Stablecoin Payments**: Automatic distribution in stablecoins for global accessibility
302
- - **Immutable Receipts**: Blockchain-verified usage records and payment history
303
-
304
- #### Contributor Features
305
- - **Wallet-Linked Profiles**: Connect contributor identities to blockchain wallets
306
- - **Reputation System**: On-chain reputation tracking based on contribution quality
307
- - **Task Receipts**: Mint lightweight NFTs/records for each labeled batch or contribution
308
- - **Transparent Payouts**: Real-time visibility into earnings and payment history
309
- - **KYC Integration**: Optional KYC at withdrawal thresholds for compliance
310
-
311
- #### Cross-Chain Support
312
- - **Multi-Chain Architecture**: Support for BSC, Polygon, Arbitrum, and Ethereum
313
- - **Chain-Agnostic Design**: Flexible architecture allowing easy addition of new chains
314
- - **Low-Cost Transactions**: Optimized for micro-payouts with low gas fees
315
-
316
- #### Enterprise & Compliance
317
- - **License Templates**: OpenRAIL-style and custom licensing with commercial terms
318
- - **Usage Analytics**: Privacy-preserving metrics with optional ZK attestations
319
- - **Regulatory Compliance**: Built-in support for KYC/AML at withdrawal points
320
- - **Audit Trails**: Complete on-chain audit trail for all transactions and payouts
321
-
322
- ### Additional Planned Features
323
- - **Streaming Payouts**: Real-time payments during long training runs
324
- - **DAO Governance**: Reputation-weighted curation DAO for dataset/model approvals
325
- - **Privacy-Preserving Metrics**: TEEs or ZK attestations for usage tracking
326
- - **Enterprise SSO**: Single Sign-On integration for enterprise customers
327
- - **Custom Invoicing**: Enterprise billing and invoice generation
328
-
329
- *Note: These features are in active development. See the [Proposal & Feasibility Report](./src/app/forai/Proposal%20%26%20Feasibility%20Report.txt) for detailed technical specifications.*
330
-
331
- ## 📚 Documentation
332
-
333
- - [Quick Start Guide](./QUICK_START.md) - Get started quickly
334
- - [Database Schema](./database_tables.sql) - Complete database structure
335
- - [Proposal & Feasibility Report](./src/app/forai/Proposal%20%26%20Feasibility%20Report.txt) - Blockchain fair-pay system design
336
- - [Hugging Face API Docs](https://huggingface.co/docs/api-inference/index) - External API reference
337
-
338
- ## 🛡️ Security
339
-
340
- - OAuth tokens are securely stored in the database
341
- - Access tokens are encrypted and never exposed to the client
342
- - User permissions are validated on every API request
343
- - SQL injection protection via parameterized queries
344
- - CORS and CSRF protection via NextAuth
345
-
346
- ## 🤝 Contributing
347
-
348
- Contributions are welcome! Please follow these steps:
349
-
350
- 1. Fork the repository
351
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
352
- 3. Commit your changes (`git commit -m 'Add amazing feature'`)
353
- 4. Push to the branch (`git push origin feature/amazing-feature`)
354
- 5. Open a Pull Request
355
-
356
- ## 📝 License
357
-
358
- This project is private and proprietary.
359
-
360
- ## 🔗 Blockchain Integration
361
-
362
- ### Using MetaMask
363
-
364
- The platform includes built-in MetaMask integration for Web3 features:
365
-
366
- ```typescript
367
- import { createMetaMaskManager } from '@/lib/metamask';
368
-
369
- const wallet = createMetaMaskManager({
370
- enforceChainId: 1, // Ethereum mainnet
371
- autoReconnect: true,
372
- });
373
-
374
- // Connect wallet
375
- await wallet.connect();
376
-
377
- // Get current state
378
- const state = wallet.getState();
379
- console.log(state.accounts, state.chainId);
380
-
381
- // Switch networks
382
- await wallet.switchChain(137); // Polygon
383
-
384
- // Disconnect
385
- wallet.disconnect();
386
- ```
387
-
388
- ### Wallet Status
389
-
390
- The platform displays wallet connection status on the dashboard, showing:
391
- - Connection state (connected/idle/unavailable)
392
- - Connected account address
393
- - Current network/chain ID
394
- - Auto-reconnection status
395
-
396
- ## 🙏 Acknowledgments
397
-
398
- - Built with [Next.js](https://nextjs.org/)
399
- - Integrated with [Hugging Face](https://huggingface.co/)
400
- - Authentication via [NextAuth.js](https://next-auth.js.org/)
401
- - Database powered by [PostgreSQL](https://www.postgresql.org/)
402
- - Blockchain integration via [MetaMask](https://metamask.io/)
403
-
404
- ## 📞 Support
405
-
406
- For issues and questions:
407
- - Open an issue on GitHub
408
- - Check existing documentation
409
- - Review the [Quick Start Guide](./QUICK_START.md)
410
-
411
- ---
412
-
413
- **Made with ❤️ for the AI community**
 
1
+ ---
2
+ title: Spacial
3
+ emoji: 📚
4
+ colorFrom: yellow
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 6.6.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference