AI-Driven Code Generation for FastAPI & SQLAlchemy
BackBone AI is an innovative multi-agent system powered by LangChain that transforms JSON schema definitions into production-ready Python backends. Say goodbye to repetitive boilerplate code and hello to rapid, high-quality backend development.
Building backend systems involves repetitive tasks:
- Creating database models with proper relationships
- Setting up Foreign Keys and constraints
- Configuring mixins (timestamps, soft deletes)
- Writing boilerplate SQLAlchemy code
- Managing dependencies between tables
Existing AI coding assistants struggle with:
- Context window limitations in large projects (20+ tables)
- Tracking complex relationships
- Maintaining consistency across multiple files
- Following project-specific patterns
BackBone-AI uses a specialized multi-agent architecture with LangChain to:
- Focus on specific, narrow tasks with high quality output
- Maintain context through structured workflows
- Validate relationships and dependencies
- Generate clean, tested, production-ready code
User JSON Schema
β
Orchestrator Agent
β
ββββββββ΄βββββββ¬βββββββββββ¬βββββββββββ
β β β β
Schema Architect Code Gen Validator
Validator Agent Agent Agent
- Schema Validator Agent: Validates JSON structure, ForeignKeys, and relationships
- Architect Agent: Creates dependency order and architectural plan
- Code Generator Agent: Generates SQLAlchemy models using templates
- Validator Agent: Validates generated code for syntax and best practices
# Clone the repository
git clone https://github.com/vidinsight-miniflow/BackBone-AI.git
cd BackBone-AI
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .env
# Edit .env and add your API keysEdit .env file and add your LLM API keys:
# Choose your preferred provider
DEFAULT_LLM_PROVIDER=openai
# Add your API key
OPENAI_API_KEY=sk-your-key-here
# or
ANTHROPIC_API_KEY=sk-ant-your-key-hereCreate a JSON schema file (see examples/simple_schema.json):
{
"project_name": "MyBackend",
"db_type": "postgresql",
"schema": [
{
"table_name": "users",
"class_name": "User",
"options": {
"use_timestamps": true,
"use_soft_delete": false
},
"columns": [...],
"relationships": [...]
}
]
}Run the generator:
# CLI mode
backbone-ai generate --schema examples/simple_schema.json --output ./my_project
# API mode
uvicorn app.api.main:app --reload
# Then POST your schema to http://localhost:8000/generate- β Multi-Agent System: Specialized agents for validation, planning, generation, and testing
- β LangChain Integration: Powered by LangGraph for robust workflow orchestration
- β
3 LLM Providers: Full support for OpenAI GPT, Anthropic Claude, Google Gemini
- Mix and match providers per agent
- Cost optimization (Gemini ~10x cheaper than GPT-4)
- 128K-2M token context windows
- β Smart Validation: Automatic ForeignKey and relationship validation
- β Dependency Resolution: Correct table creation order
- β Mixin Support: TimestampMixin, SoftDeleteMixin, and custom mixins
- β Code Quality: Auto-formatted with Black, linted with Ruff
- β Type Safety: Full type hints with mypy validation
- β Security: API key + JWT authentication, 4-tier rate limiting, input validation
- β Monitoring: Health checks, Prometheus metrics (26 metrics), LangSmith tracing
- β REST API: Full-featured API with OpenAPI documentation
- β Observability: Request tracking, error monitoring, cost tracking
- β Documentation: Comprehensive guides (Security, Monitoring, API, Architecture)
BackBone-AI is production-ready with enterprise-grade features:
- Security: Dual authentication (API key + JWT), rate limiting, input validation
- Monitoring: Health checks, 26 Prometheus metrics, distributed tracing
- Documentation: 3000+ lines covering security, monitoring, deployment
- Testing: Comprehensive test suite with 15+ test cases
- Dependencies: All packages updated to latest secure versions
See Production Readiness Report for details.
- AI Framework: LangChain, LangGraph
- LLM Providers: OpenAI GPT-4, Anthropic Claude, Google Gemini
- Backend: FastAPI, SQLAlchemy 2.0
- Database: PostgreSQL (+ others via SQLAlchemy)
- Code Quality: Black, Ruff, mypy
- Testing: pytest, pytest-asyncio
- Architecture Guide - System design and workflows
- API Reference - REST API endpoints and usage
- Schema Guide - JSON schema format and examples
- LLM Provider Guide - OpenAI, Claude, Gemini setup & optimization
- Project Guide - Development guide
- Production Readiness - 95% ready status report
- Security Guide - Authentication, rate limiting, best practices
- Monitoring Guide - Health checks, metrics, observability
Contributions are welcome! Please read our contributing guidelines.
MIT License - see LICENSE file for details
- Built on top of sqlalchemy-engine-kit
- Powered by LangChain
- Inspired by the need for better AI-assisted backend development
- GitHub Issues: Report bugs or request features
- Documentation: Full documentation
Status: π§ Alpha - Active Development
Current Phase: Building core agent system and code generation pipeline.