Skip to main content

Swarm Intelligence System for Documentation-Driven Code Generation

Project description

AppAI - Swarm Intelligence System

Documentation-driven code generation powered by decentralized agent swarms.

Python Version License

What is AppAI?

AppAI is a swarm intelligence system that generates production-ready code using decentralized autonomous agents. Agents compete for tasks through async bidding, collaborate on complex projects, and learn from framework documentation patterns.

Key Innovation: Cross-App Intelligence

AppAI agents understand relationships between models in different Django apps - automatically creating ForeignKey relationships with proper imports:

# agents/models.py
class Author(models.Model):
    name = models.CharField(max_length=200)

# blog/models.py - DIFFERENT APP!
from authors.models import Author  # โœ… Auto-generated import

class Post(models.Model):
    author = models.ForeignKey(Author, on_delete=CASCADE, related_name='posts')

Quick Start

# Install
pip install appai

# Run example
python examples/example_blog_with_relations.py

Features

๐Ÿค– Decentralized Swarm Architecture

  • Async Task Bidding - Agents compete for tasks based on expertise
  • No Central Coordinator - Self-organizing agent network
  • Real-time Communication - Agents share knowledge and progress

๐Ÿ“š Documentation-Driven Development

  • ChromaDB Vector Store - Pattern matching from framework docs
  • Framework-Aware Prompts - Django, FastAPI, Flask support
  • Shared Knowledge System - Agents track models across apps

๐ŸŽฏ Smart Code Generation

  • Multi-Agent Roles - ModelArchitect, APIBuilder, QualityGuard
  • Type-Safe Models - Pydantic2 validation
  • Test Generation - Automatic test suite creation

Installation

# From PyPI
pip install appai

# From source
git clone https://github.com/yourusername/appai.git
cd appai2
poetry install

Usage

Basic Example

from appai.orchestration import SwarmHub
from appai.documentation import DocumentationEngine

# Initialize
docs = DocumentationEngine(framework="django")
hub = SwarmHub(docs_engine=docs)

# Run swarm
await hub.run_swarm(
    goal="Create blog system with Author, Post, Comment models",
    config={"output_dir": "generated/blog"}
)

Cross-App Model Relationships

# AppAI automatically:
# 1. Creates Author in authors/models.py
# 2. Creates Post in blog/models.py with ForeignKey to Author
# 3. Generates proper imports: from authors.models import Author
# 4. Adds related_name for reverse lookups

goal = """
Create Django apps:
- authors app with Author model
- blog app with Post model (ForeignKey to Author)
- comments app with Comment model (ForeignKey to Post)
"""

await hub.run_swarm(goal=goal)

Development

DevOps CLI

# Version management & packaging
npm run cli

# Show version info
npm run version

# Build package
npm run build

See DEVOPS.md for details.

Run Examples

# Blog with cross-app relationships
poetry run python examples/example_blog_with_relations.py

# Decentralized task bidding
poetry run python examples/example_decentralized.py

# Auto catalog generation
poetry run python examples/example_auto_catalog.py

Run Tests

poetry run pytest

Architecture

appai/
โ”œโ”€โ”€ src/appai/
โ”‚   โ”œโ”€โ”€ agents/              # Agent implementations
โ”‚   โ”‚   โ”œโ”€โ”€ agent_pool.py   # Agent coordination
โ”‚   โ”‚   โ””โ”€โ”€ profiles/       # Agent role definitions
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ orchestration/       # Swarm coordination
โ”‚   โ”‚   โ””โ”€โ”€ swarm_hub.py    # Decentralized task bidding
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ prompts/             # Framework-aware prompts
โ”‚   โ”‚   โ”œโ”€โ”€ registry.py     # Prompt builder registry
โ”‚   โ”‚   โ””โ”€โ”€ django.py       # Django-specific prompts
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ documentation/       # ChromaDB pattern matching
โ”‚   โ””โ”€โ”€ tools/               # MCP file operations
โ”‚
โ”œโ”€โ”€ devops/                  # Package management CLI
โ”‚   โ”œโ”€โ”€ cli/                # Interactive CLI
โ”‚   โ”œโ”€โ”€ managers/           # Version & package managers
โ”‚   โ””โ”€โ”€ models/             # Pydantic models
โ”‚
โ”œโ”€โ”€ examples/               # Usage examples
โ””โ”€โ”€ @progress/              # Development docs

How It Works

1. Task Decomposition

User Goal โ†’ Planning Agent โ†’ Subtasks (model, api, tests)

2. Async Bidding

Subtasks โ†’ Broadcast โ†’ Agents bid โ†’ Winner selected โ†’ Task executed

3. Shared Knowledge

Agent completes task โ†’ Updates shared_knowledge โ†’ Other agents see new models

4. Framework-Aware Prompts

Agent receives task โ†’ Registry selects prompts โ†’ Agent gets Django-specific guidelines

Documentation

Key Innovations

1. Shared Knowledge System

Agents automatically track created models across different apps:

shared_knowledge = {
    "created_models": [
        {"name": "Author", "app": "authors", "file": "authors/models.py"},
        {"name": "Post", "app": "blog", "file": "blog/models.py"}
    ]
}

2. Framework-Aware Prompts

Agent prompts adapt based on framework and task:

@PromptBuilderRegistry.register('django')
class DjangoPromptBuilder:
    def get_cross_app_imports_guide():
        """Django-specific cross-app import instructions"""

3. Decentralized Task Bidding

No central coordinator - agents self-organize:

# Agent calculates bid based on:
# - Task category match (model, api, tests)
# - Previous experience
# - Current workload

Requirements

  • Python 3.12+
  • OpenAI API key
  • ChromaDB (for documentation patterns)

License

MIT

Contributing

Contributions welcome! See issues for current development priorities.

Credits

Built with:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

appai-1.0.1.tar.gz (60.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

appai-1.0.1-py3-none-any.whl (72.7 kB view details)

Uploaded Python 3

File details

Details for the file appai-1.0.1.tar.gz.

File metadata

  • Download URL: appai-1.0.1.tar.gz
  • Upload date:
  • Size: 60.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for appai-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a58a52568d266042fde356feddce851b08e4599a1f3c3a02119b6cddd4267c19
MD5 19e180f618a1629dfa87b4298bd63af6
BLAKE2b-256 9b5486bbe8914542854559e715a5dc40ffc3bc8267af6134a095c5cad0425df4

See more details on using hashes here.

File details

Details for the file appai-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: appai-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 72.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for appai-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3ce0c088d75b575695b273ed988f363e681d46dc3c13c35f134830e6b6fdb4a
MD5 575061dec7c0edb725edcd4b72cfcbc1
BLAKE2b-256 b23ee8bd560832ca781e0c4bde9b437e593914940b3ad493996c51a3cf9747dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page