Skip to content

BackBone AI is an innovative AI-driven code generation project designed to rapidly bootstrap robust and scalable backends using FastAPI and SQLAlchemy. It transforms natural language or structured schema definitions into production-ready Python code, focusing specifically on data persistence and API logic.

Notifications You must be signed in to change notification settings

vidinsight-labs/BackBone-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– BackBone-AI

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.

🎯 Problem Statement

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

πŸ’‘ Solution

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

πŸ—οΈ Architecture

User JSON Schema
       ↓
Orchestrator Agent
       ↓
β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
↓             ↓          ↓          ↓
Schema      Architect  Code Gen  Validator
Validator   Agent      Agent     Agent

Agents

  1. Schema Validator Agent: Validates JSON structure, ForeignKeys, and relationships
  2. Architect Agent: Creates dependency order and architectural plan
  3. Code Generator Agent: Generates SQLAlchemy models using templates
  4. Validator Agent: Validates generated code for syntax and best practices

πŸš€ Quick Start

Installation

# 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 keys

Configuration

Edit .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-here

Usage

Create 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

πŸ“¦ Features

Core Functionality

  • βœ… 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

Production Features

  • βœ… 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)

πŸš€ Production Ready (95%)

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.

πŸ› οΈ Technology Stack

  • 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

πŸ“– Documentation

Core Documentation

Production Documentation

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines.

πŸ“„ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

πŸ“ž Support


Status: 🚧 Alpha - Active Development

Current Phase: Building core agent system and code generation pipeline.

About

BackBone AI is an innovative AI-driven code generation project designed to rapidly bootstrap robust and scalable backends using FastAPI and SQLAlchemy. It transforms natural language or structured schema definitions into production-ready Python code, focusing specifically on data persistence and API logic.

Topics

Resources

Security policy

Stars

Watchers

Forks

Languages