mirror of
https://github.com/blackboxprogramming/blackroad.io.git
synced 2026-03-18 03:33:59 -05:00
- Created FastAPI backend with all endpoints (auth, agents, chat, blockchain, payments) - Added unified BlackRoad API client (blackroad-api.js) for all frontend apps - Updated index.html to use new unified API - Backend includes health checks, JWT auth, and mock AI responses - Ready for Railway deployment with Procfile and railway.json - All frontend apps can now share authentication and API calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2.3 KiB
2.3 KiB
BlackRoad OS Backend API
Complete FastAPI backend for BlackRoad Operating System.
Features
- Authentication: JWT-based auth with register/login
- AI Chat: Conversation management with AI responses
- Agents: Spawn, list, and manage 30,000+ AI agents
- Blockchain: RoadChain transactions and blocks
- Payments: Stripe checkout integration
- Files: Cloud file management
- Social: Social network feed
Local Development
# Install dependencies
pip install -r requirements.txt
# Run server
uvicorn main:app --reload --port 8000
# Test
curl http://localhost:8000/health
Railway Deployment
# From this directory
railway login
railway link
railway up
Environment Variables
SECRET_KEY: JWT secret (auto-generated if not set)STRIPE_SECRET_KEY: Your Stripe secret keyPORT: Port to run on (default: 8000)
API Endpoints
Health
GET /health- Health checkGET /ready- Readiness check
Auth
POST /api/auth/register- Register new userPOST /api/auth/login- LoginGET /api/auth/me- Get current user
AI Chat
POST /api/ai-chat/chat- Send messageGET /api/ai-chat/conversations- List conversations
Agents
POST /api/agents/spawn- Spawn new agentGET /api/agents/list- List agentsGET /api/agents/{id}- Get agent detailsDELETE /api/agents/{id}- Terminate agent
Blockchain
GET /api/blockchain/blocks- Get blocksPOST /api/blockchain/transaction- Create transactionGET /api/blockchain/transactions- Get transactions
Payments
POST /api/payments/create-checkout-session- Create Stripe checkoutPOST /api/payments/verify-payment- Verify payment
Files
GET /api/files/list- List files
Social
GET /api/social/feed- Get social feed
System
GET /api/system/stats- System statistics
Architecture
- FastAPI with async/await
- JWT authentication
- In-memory storage (replace with PostgreSQL/Redis in production)
- CORS enabled for all origins
- Mock AI responses (integrate with real LLM)
Production Considerations
- Replace in-memory storage with PostgreSQL
- Add Redis for sessions
- Integrate real LLM (OpenAI/Anthropic)
- Add rate limiting
- Enable HTTPS only
- Set strong SECRET_KEY
- Configure CORS for specific origins