aibtcdev-backend is a sophisticated FastAPI-based backend service that powers AI-driven interactions with Bitcoin and Stacks blockchain technologies. The service provides:
- Real-time chat functionality with AI agents via WebSocket
- Automated DAO management and monitoring
- Social media integration (Twitter, Telegram, Discord)
- Blockchain interaction capabilities (Stacks, Bitcoin)
- Market data analysis and reporting
- Document processing and vector search capabilities
The system is designed to be modular, scalable, and easily configurable through environment variables.
aibtc.dev is not liable for any lost, locked, or mistakenly sent funds. This is alpha software—use at your own risk. Any STX sent to you is owned by you, the trader, and may be redeemed, including profits or losses, at the end of the aibtc.dev Champions Sprint (~5 days). By participating, you accept that aibtc.dev is not responsible for any product use, costs, taxes incurred from trading STX or any other digital asset, or any other liability.
- Python 3.13
- Bun (for TypeScript tools)
- Git
- Conda (recommended for development) or Docker
- Node.js and npm (for agent tools)
aibtcdev-backend/
├── api/ # FastAPI endpoint definitions
│ ├── chat.py # WebSocket chat endpoints
│ ├── tools.py # Tool endpoints
│ ├── webhooks.py # Webhook handlers
│ └── dependencies.py # API dependencies
├── services/ # Core business logic
│ ├── workflows/ # Workflow implementations
│ ├── runner/ # Background task runners
│ ├── webhooks/ # Webhook processors
│ ├── discord/ # Discord integration
│ ├── chat.py # Chat service
│ ├── daos.py # DAO operations
│ ├── schedule.py # Task scheduling
│ ├── startup.py # App lifecycle management
│ ├── twitter.py # Twitter integration
│ ├── bot.py # Telegram bot
│ └── websocket.py # WebSocket management
├── backend/ # Database and storage
├── tools/ # AI agent tools
├── lib/ # Shared utilities
├── tests/ # Test suite
├── docs/ # Documentation
├── examples/ # Usage examples
└── agent-tools-ts/ # TypeScript-based agent tools
- Real-time WebSocket-based chat
- AI agent integration with OpenAI
- Context-aware conversations
- Document-based knowledge integration
- Vector search capabilities
- Automated DAO deployment monitoring
- Proposal creation and tracking
- Vote processing
- Automated conclusion handling
- Tweet generation for DAO events
- Twitter automation and monitoring
- Telegram bot integration
- Discord notifications
- Automated content generation
- Social engagement tracking
- Stacks blockchain interaction
- Bitcoin network monitoring
- Multiple API integrations:
- Hiro
- Alex
- Velar
- Platform API
- LunarCrush integration
- CoinMarketCap data processing
- Market trend analysis
- Automated reporting
- Scheduled task management
- Event-driven processing
- Multi-threaded task execution
- Failure recovery and retry logic
git clone [repository-url]
cd aibtcdev-backend
git submodule init
git submodule update --remote
- Copy the example environment file:
cp .env.example .env
- Configure your environment variables by following the Configuration Guide
# Install Miniconda
brew install miniconda
# Initialize conda
conda init "$(basename "${SHELL}")"
# Restart your terminal
# Create and activate environment
conda create --name aibackend python=3.12
conda activate aibackend
# Install dependencies
pip install -r requirements.txt
# Set up TypeScript tools
cd agent-tools-ts/
bun install
cd ..
docker build -t aibtcdev-backend .
docker run -p 8000:8000 --env-file .env aibtcdev-backend
/chat/ws
: Real-time chat communication- Supports message history
- AI agent integration
- Context management
- Document processing
/tools/available
: Available tool listing/tools/execute
: Tool execution endpoint- Custom tool integration support
/webhooks/chainhook
: Blockchain event processing/webhooks/github
: GitHub integration/webhooks/discord
: Discord notifications
/bot/telegram
: Telegram bot integration- User verification and management
- Command processing
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The project uses ruff for code formatting and linting. Configuration is in ruff.toml
.
pytest tests/
API documentation is available at /docs
when running the server.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
Guidelines:
- Follow the Python code style guide
- Add tests for new features
- Update documentation as needed
- Keep pull requests focused and atomic
-
OpenAI Rate Limits
- Check limits at https://platform.openai.com/settings/organization/limits
- TPM (Tokens Per Minute) limits:
- Tier 1: 200,000 TPM
- Tier 2: 2,000,000 TPM
-
WebSocket Connection Issues
- Check network connectivity
- Verify authentication tokens
- Check server logs for details
-
Database Connection Issues
- Verify Supabase credentials
- Check network access to database
- Verify connection string format
For support:
- Check the documentation
- Search existing issues
- Create a new issue with:
- Clear description
- Steps to reproduce
- Expected vs actual behavior
- Environment details
[License Information]