Swarm Intelligence System for Documentation-Driven Code Generation
Project description
AppAI - Swarm Intelligence System
Documentation-driven code generation powered by decentralized agent swarms.
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
- Session Summary:
@progress/SESSION_SUMMARY.md- Cross-app model relationships - Framework Prompts:
@progress/FRAMEWORK_PROMPT_SYSTEM.md- Agent-driven prompts - DevOps CLI:
@progress/DEVOPS_CLI_SUMMARY.md- Packaging system
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:
- agency-swarm - Agent framework
- Pydantic - Type safety
- ChromaDB - Vector storage
- Rich - Terminal UI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a58a52568d266042fde356feddce851b08e4599a1f3c3a02119b6cddd4267c19
|
|
| MD5 |
19e180f618a1629dfa87b4298bd63af6
|
|
| BLAKE2b-256 |
9b5486bbe8914542854559e715a5dc40ffc3bc8267af6134a095c5cad0425df4
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3ce0c088d75b575695b273ed988f363e681d46dc3c13c35f134830e6b6fdb4a
|
|
| MD5 |
575061dec7c0edb725edcd4b72cfcbc1
|
|
| BLAKE2b-256 |
b23ee8bd560832ca781e0c4bde9b437e593914940b3ad493996c51a3cf9747dc
|