| # π START HERE - Instructions for AI Developer | |
| ## β οΈ CRITICAL: THIS IS AN UPDATE REQUEST, NOT A NEW PROJECT | |
| **IMPORTANT:** This is a **SPACE UPDATE REQUEST** for an existing HuggingFace Space. You are NOT creating a new space from scratch. You are **UPDATING and ENHANCING** an existing deployment to add comprehensive API capabilities. | |
| --- | |
| ## π STEP-BY-STEP READING ORDER | |
| Follow this **EXACT ORDER** when reading the documentation: | |
| ### **STEP 1: Read the Summary (5 minutes)** | |
| π **File:** `HF_DEPLOYMENT_SUMMARY.md` | |
| **Purpose:** Get a quick overview of what needs to be done | |
| **What to understand:** | |
| - This is an UPDATE to existing HuggingFace Space | |
| - We need to add 30+ API endpoints | |
| - Goal is to centralize ALL data requests through HF Space | |
| - Current problem: 60+ files making scattered API calls | |
| **Key takeaway:** Understand the "why" before diving into "how" | |
| --- | |
| ### **STEP 2: Read the Official Request Letter (10 minutes)** | |
| π **File:** `SEND_TO_HF_TEAM.md` | |
| **Purpose:** Understand the scope and priorities | |
| **What to understand:** | |
| - Request type: UPDATE (not new deployment) | |
| - Priority: HIGH | |
| - Success criteria | |
| - Key requirements overview | |
| - Tech stack overview | |
| **Key takeaway:** Understand project priorities and success metrics | |
| --- | |
| ### **STEP 3: Read Architecture Analysis (30 minutes)** | |
| π **File:** `DATA_ARCHITECTURE_ANALYSIS_REPORT.md` | |
| **Purpose:** Understand current state and why changes are needed | |
| **What to understand:** | |
| - Current architecture weaknesses | |
| - Files that need modification (63 files listed) | |
| - Data sources currently used | |
| - Proposed new architecture (Data Highway) | |
| - Implementation roadmap | |
| **Key takeaway:** Understand the "before" state to implement the "after" state correctly | |
| --- | |
| ### **STEP 4: Read Complete API Specifications (2-3 hours)** | |
| π **File:** `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` | |
| **Purpose:** This is your MAIN REFERENCE for implementation | |
| **What to understand:** | |
| - **ALL 30+ API endpoint specifications** | |
| - Request/Response formats for each endpoint | |
| - Query parameters | |
| - Path parameters | |
| - Error handling formats | |
| - WebSocket implementation | |
| - Caching strategy | |
| - Rate limiting | |
| - Data source integration | |
| - AI/ML models integration | |
| - Deployment configuration | |
| - Testing procedures | |
| **Key takeaway:** This file contains EVERYTHING you need to implement. Read it thoroughly. | |
| **β οΈ CRITICAL SECTIONS (Must Read Carefully):** | |
| 1. **API Specifications (Lines 1-800)** β All endpoint definitions | |
| 2. **Technical Requirements (Lines 801-1000)** β Backend code | |
| 3. **Data Sources Integration (Lines 1001-1200)** β API integrations | |
| 4. **Caching Strategy (Lines 1201-1300)** β Performance | |
| 5. **AI/ML Models (Lines 1301-1500)** β AI features | |
| 6. **WebSocket Implementation (Lines 1501-1700)** β Real-time | |
| 7. **Deployment Config (Lines 1701-1900)** β Dockerfile, requirements.txt | |
| 8. **Testing & Verification (Lines 1901-end)** β Quality assurance | |
| --- | |
| ### **STEP 5: Read Engineering Standards (Optional, 1 hour)** | |
| π **File:** `ENGINEERING_GUIDE.md` | |
| **Purpose:** Understand coding standards and best practices | |
| **What to understand:** | |
| - Code style guidelines | |
| - Component architecture | |
| - Error handling patterns | |
| - Testing requirements | |
| - Documentation standards | |
| **Key takeaway:** Write code that matches project standards | |
| --- | |
| ## π― IMPLEMENTATION CHECKLIST | |
| After reading all documentation, follow this implementation order: | |
| ### **Phase 1: Environment Setup** | |
| ```bash | |
| - [ ] Clone/access existing HuggingFace Space | |
| - [ ] Set up Python 3.9+ environment | |
| - [ ] Install Redis locally for testing | |
| - [ ] Create virtual environment | |
| - [ ] Install all dependencies from requirements.txt | |
| ``` | |
| ### **Phase 2: Core API Framework** | |
| ```bash | |
| - [ ] Set up FastAPI application structure | |
| - [ ] Configure CORS middleware | |
| - [ ] Set up Redis connection | |
| - [ ] Create health check endpoint (/health) | |
| - [ ] Test basic server startup | |
| ``` | |
| ### **Phase 3: Data Sources Integration** | |
| ```bash | |
| - [ ] Implement CoinGecko API client | |
| - [ ] Implement Binance API client | |
| - [ ] Implement NewsAPI client | |
| - [ ] Implement CryptoPanic client | |
| - [ ] Implement Alternative.me client | |
| - [ ] Create fallback mechanism | |
| - [ ] Test each data source individually | |
| ``` | |
| ### **Phase 4: Market Data Endpoints** | |
| ```bash | |
| - [ ] Implement GET /api/market | |
| - [ ] Implement GET /api/price/{symbol} | |
| - [ ] Implement GET /api/ohlcv | |
| - [ ] Implement GET /api/ticker/{symbol} | |
| - [ ] Add caching for each endpoint | |
| - [ ] Test all market endpoints | |
| ``` | |
| ### **Phase 5: News & Sentiment Endpoints** | |
| ```bash | |
| - [ ] Implement GET /api/news/latest | |
| - [ ] Implement GET /api/sentiment/global | |
| - [ ] Implement GET /api/sentiment/symbol/{symbol} | |
| - [ ] Integrate Fear & Greed Index | |
| - [ ] Test all news endpoints | |
| ``` | |
| ### **Phase 6: Trading Endpoints** | |
| ```bash | |
| - [ ] Implement GET /api/exchange-info | |
| - [ ] Implement GET /api/orderbook/{symbol} | |
| - [ ] Implement GET /api/trades/{symbol} | |
| - [ ] Test all trading endpoints | |
| ``` | |
| ### **Phase 7: AI/ML Integration** | |
| ```bash | |
| - [ ] Load BERT sentiment model (ElKulako/cryptobert) | |
| - [ ] Implement sentiment analysis function | |
| - [ ] Implement price prediction model | |
| - [ ] Implement GET /api/ai/signals | |
| - [ ] Implement POST /api/ai/predict | |
| - [ ] Implement GET /api/ai/analysis/{symbol} | |
| - [ ] Test all AI endpoints | |
| ``` | |
| ### **Phase 8: Blockchain Endpoints** | |
| ```bash | |
| - [ ] Implement GET /api/blockchain/transactions/{address} | |
| - [ ] Implement GET /api/blockchain/whale-alerts | |
| - [ ] Test blockchain endpoints | |
| ``` | |
| ### **Phase 9: Statistics Endpoints** | |
| ```bash | |
| - [ ] Implement GET /api/stats | |
| - [ ] Implement GET /api/stats/dominance | |
| - [ ] Implement GET /api/history/price/{symbol} | |
| - [ ] Test statistics endpoints | |
| ``` | |
| ### **Phase 10: WebSocket Implementation** | |
| ```bash | |
| - [ ] Create WebSocket connection manager | |
| - [ ] Implement WS /ws/ticker | |
| - [ ] Implement WS /ws/trades | |
| - [ ] Create broadcast mechanism | |
| - [ ] Test WebSocket connections | |
| - [ ] Test subscribe/unsubscribe | |
| ``` | |
| ### **Phase 11: Performance & Optimization** | |
| ```bash | |
| - [ ] Implement caching layer (Redis) | |
| - [ ] Implement rate limiting | |
| - [ ] Add request deduplication | |
| - [ ] Optimize database queries (if any) | |
| - [ ] Test performance under load | |
| ``` | |
| ### **Phase 12: Error Handling & Logging** | |
| ```bash | |
| - [ ] Implement consistent error format | |
| - [ ] Add logging for all endpoints | |
| - [ ] Add error tracking | |
| - [ ] Test error scenarios | |
| ``` | |
| ### **Phase 13: Testing** | |
| ```bash | |
| - [ ] Test all 30+ endpoints individually | |
| - [ ] Test error handling | |
| - [ ] Test fallback mechanisms | |
| - [ ] Test caching | |
| - [ ] Test rate limiting | |
| - [ ] Test WebSocket stability | |
| - [ ] Load test with 100+ concurrent users | |
| ``` | |
| ### **Phase 14: Documentation** | |
| ```bash | |
| - [ ] Verify /docs endpoint works (FastAPI auto-docs) | |
| - [ ] Add API examples to README | |
| - [ ] Document authentication (if added) | |
| - [ ] Document rate limits | |
| ``` | |
| ### **Phase 15: Deployment** | |
| ```bash | |
| - [ ] Create Dockerfile | |
| - [ ] Test Docker build locally | |
| - [ ] Configure environment variables in HF Space | |
| - [ ] Push to HuggingFace Space | |
| - [ ] Verify deployment | |
| - [ ] Test all endpoints in production | |
| - [ ] Monitor for 24 hours | |
| ``` | |
| --- | |
| ## π CRITICAL REMINDERS | |
| ### β οΈ THIS IS AN UPDATE | |
| ``` | |
| YOU ARE NOT CREATING A NEW SPACE! | |
| YOU ARE UPDATING AN EXISTING SPACE! | |
| This means: | |
| β Use existing space repository | |
| β Keep existing functionality (if any) | |
| β ADD new endpoints | |
| β ENHANCE existing features | |
| β Don't break existing integrations | |
| ``` | |
| ### β οΈ PRIORITY ORDER | |
| ``` | |
| 1. MUST HAVE (implement first): | |
| - GET /api/market | |
| - GET /api/ohlcv | |
| - GET /api/news/latest | |
| - GET /api/sentiment/global | |
| - GET /api/ai/signals | |
| 2. SHOULD HAVE (implement second): | |
| - All other REST endpoints | |
| - WebSocket /ws/ticker | |
| 3. NICE TO HAVE (implement if time): | |
| - Advanced AI features | |
| - WebSocket /ws/trades | |
| - Blockchain endpoints | |
| ``` | |
| ### β οΈ QUALITY STANDARDS | |
| ``` | |
| β ALL endpoints must return valid JSON | |
| β ALL errors must follow the standard format | |
| β ALL endpoints must have caching | |
| β ALL responses must include timestamp | |
| β ALL endpoints must handle timeouts gracefully | |
| β ALL data sources must have fallbacks | |
| ``` | |
| ### β οΈ PERFORMANCE REQUIREMENTS | |
| ``` | |
| Response Times: | |
| - Price endpoints: < 100ms | |
| - Market data: < 500ms | |
| - News/Sentiment: < 1s | |
| - AI predictions: < 2s | |
| Caching TTL: | |
| - Prices: 5 seconds | |
| - OHLCV: 60 seconds | |
| - News: 5 minutes | |
| - AI signals: 2 minutes | |
| Rate Limits: | |
| - Per IP: 100 requests/minute | |
| - Per endpoint: Varies (see specs) | |
| ``` | |
| --- | |
| ## π QUICK REFERENCE GUIDE | |
| ### When you need to find... | |
| **Endpoint specifications** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "DETAILED API SPECIFICATIONS") | |
| **Request/Response formats** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Each endpoint section) | |
| **Backend code examples** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "TECHNICAL REQUIREMENTS") | |
| **Data source integration** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "Data Sources Integration") | |
| **Caching implementation** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "Caching Strategy") | |
| **AI model code** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "AI/ML Models Integration") | |
| **WebSocket code** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "WebSocket Implementation") | |
| **Deployment files** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "DEPLOYMENT CONFIGURATION") | |
| **Testing procedures** β `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (Section: "VERIFICATION CHECKLIST") | |
| **Current architecture** β `DATA_ARCHITECTURE_ANALYSIS_REPORT.md` | |
| **Project overview** β `HF_DEPLOYMENT_SUMMARY.md` | |
| --- | |
| ## π¨ COMMON MISTAKES TO AVOID | |
| ### β DON'T: | |
| ``` | |
| β Create a new HuggingFace Space (it already exists!) | |
| β Remove existing functionality | |
| β Hard-code API keys in the code | |
| β Skip error handling | |
| β Ignore caching requirements | |
| β Skip testing | |
| β Deploy without local testing | |
| β Use synchronous code (use async/await) | |
| β Return inconsistent response formats | |
| β Ignore rate limiting | |
| ``` | |
| ### β DO: | |
| ``` | |
| β Update the existing Space | |
| β Use environment variables for secrets | |
| β Implement proper error handling | |
| β Add caching to every endpoint | |
| β Test locally before deploying | |
| β Use async/await throughout | |
| β Follow the standard response format | |
| β Implement rate limiting | |
| β Add fallback mechanisms | |
| β Log all errors | |
| ``` | |
| --- | |
| ## π QUESTIONS & CLARIFICATIONS | |
| If you're unsure about something: | |
| 1. **Check the main spec file first** - `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` has 120+ pages of details | |
| 2. **Look at code examples** - The spec file includes complete Python code | |
| 3. **Review architecture report** - `DATA_ARCHITECTURE_ANALYSIS_REPORT.md` explains the "why" | |
| 4. **Check the summary** - `HF_DEPLOYMENT_SUMMARY.md` might answer quick questions | |
| --- | |
| ## π― SUCCESS CRITERIA | |
| You'll know you're done when: | |
| β All 30+ endpoints return valid responses | |
| β WebSocket connections are stable | |
| β Caching improves response times | |
| β Fallback mechanisms work | |
| β AI models generate predictions | |
| β `/docs` endpoint shows interactive API documentation | |
| β Health check endpoint works | |
| β All endpoints tested in production | |
| β No errors in logs for 24 hours | |
| β Response times meet requirements | |
| --- | |
| ## π READY TO START? | |
| ### Your first 3 actions should be: | |
| 1. **Read** `HF_DEPLOYMENT_SUMMARY.md` (5 min) | |
| 2. **Read** `SEND_TO_HF_TEAM.md` (10 min) | |
| 3. **Read** `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` (2-3 hours) | |
| ### Then: | |
| 4. Set up local environment | |
| 5. Start with Phase 1 of implementation | |
| 6. Follow the checklist above | |
| 7. Test everything | |
| 8. Deploy | |
| --- | |
| ## π FILE STRUCTURE OVERVIEW | |
| ``` | |
| π Project Documentation/ | |
| β | |
| βββ π START_HERE_INSTRUCTIONS.md β YOU ARE HERE | |
| β βββ Read this first for navigation | |
| β | |
| βββ π HF_DEPLOYMENT_SUMMARY.md β Step 1: Quick overview (5 min) | |
| β βββ What we're building and why | |
| β | |
| βββ π SEND_TO_HF_TEAM.md β Step 2: Official request (10 min) | |
| β βββ Scope, priorities, success criteria | |
| β | |
| βββ π DATA_ARCHITECTURE_ANALYSIS_REPORT.md β Step 3: Architecture (30 min) | |
| β βββ Current state, problems, solution | |
| β | |
| βββ π HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md β Step 4: MAIN SPEC (2-3 hours) | |
| β βββ Complete API specifications + code | |
| β | |
| βββ π ENGINEERING_GUIDE.md β Step 5: Standards (optional, 1 hour) | |
| βββ Coding standards and best practices | |
| ``` | |
| --- | |
| ## β±οΈ TIME ESTIMATE | |
| **Reading:** 3-4 hours | |
| **Setup:** 1-2 hours | |
| **Implementation:** 3-5 days (full-time) | |
| **Testing:** 1-2 days | |
| **Deployment:** 1 day | |
| **Total:** 5-8 days for complete implementation | |
| --- | |
| ## π LEARNING PATH | |
| If you're new to any of these technologies: | |
| **FastAPI:** Read official docs at https://fastapi.tiangolo.com/ | |
| **Redis:** Read caching guide at https://redis.io/docs/ | |
| **WebSockets:** Read FastAPI WebSocket guide | |
| **HuggingFace Spaces:** Read deployment guide | |
| **CCXT:** Read crypto exchange library docs | |
| --- | |
| ## π FINAL REMINDER | |
| ### THIS IS AN UPDATE REQUEST! π | |
| ``` | |
| NOT creating new space β | |
| UPDATING existing space β | |
| NOT a new project β | |
| ENHANCING existing project β | |
| NOT starting from zero β | |
| BUILDING on existing foundation β | |
| ``` | |
| --- | |
| ## β PRE-FLIGHT CHECKLIST | |
| Before you start coding, confirm: | |
| - [ ] I have read `HF_DEPLOYMENT_SUMMARY.md` | |
| - [ ] I have read `SEND_TO_HF_TEAM.md` | |
| - [ ] I have read `DATA_ARCHITECTURE_ANALYSIS_REPORT.md` | |
| - [ ] I have read `HUGGINGFACE_SPACE_DEPLOYMENT_REQUEST.md` completely | |
| - [ ] I understand this is an UPDATE, not a new project | |
| - [ ] I understand the priority order (MUST/SHOULD/NICE TO HAVE) | |
| - [ ] I have access to the existing HuggingFace Space | |
| - [ ] I have Python 3.9+ installed | |
| - [ ] I have Redis installed (or know how to use cloud Redis) | |
| - [ ] I have API keys for: CoinGecko, Binance, NewsAPI, etc. | |
| - [ ] I understand the success criteria | |
| - [ ] I am ready to start Phase 1 | |
| --- | |
| ## π GO! | |
| **Start with:** `HF_DEPLOYMENT_SUMMARY.md` | |
| **Then proceed** through the reading order above. | |
| **Good luck!** π― | |
| --- | |
| **Version:** 1.0 | |
| **Last Updated:** December 5, 2025 | |
| **Project:** Dreammaker Crypto Trading Platform - HF Space Update | |
| **Status:** π’ Ready for Implementation | |