Code Organization¶
This document describes the organization and structure of the Bedrock Swarm codebase.
Project Structure¶
bedrock-swarm/
├── bedrock_swarm/ # Main package directory
│ ├── __init__.py # Package initialization
│ ├── agency/ # Agency components
│ │ ├── __init__.py
│ │ ├── agency.py # Core agency implementation
│ │ ├── thread.py # Thread management
│ │ └── events.py # Event system
│ ├── agents/ # Agent implementations
│ │ ├── __init__.py
│ │ └── base.py # Base agent class
│ ├── models/ # Model implementations
│ │ ├── __init__.py
│ │ ├── base.py # Base model class
│ │ ├── claude.py # Claude model
│ │ ├── titan.py # Titan model
│ │ └── factory.py # Model factory
│ └── tools/ # Tool implementations
│ ├── __init__.py
│ ├── base.py # Base tool class
│ ├── calculator.py # Calculator tool
│ ├── time.py # Time tool
│ └── validation.py # Validation tool
├── docs/ # Documentation
├── tests/ # Test suite
├── examples/ # Example code
└── scripts/ # Development scripts
Component Organization¶
Agency Components¶
The agency/ directory contains core orchestration components:
agency.py: Main agency implementationthread.py: Thread management systemevents.py: Event handling system
Agent Components¶
The agents/ directory contains agent implementations:
base.py: Base agent class- Custom agent implementations
Model Components¶
The models/ directory contains model implementations:
base.py: Base model interfaceclaude.py: Claude model implementationtitan.py: Titan model implementationfactory.py: Model factory system
Tool Components¶
The tools/ directory contains tool implementations:
base.py: Base tool interfacecalculator.py: Calculator tooltime.py: Time toolvalidation.py: Validation tool
Code Style¶
We follow these organization principles:
- Module Organization:
- One class per file
- Clear module names
-
Logical grouping
-
Import Organization:
- Standard library first
- Third-party imports second
-
Local imports last
-
Code Structure:
- Clear class hierarchy
- Consistent naming
- Proper encapsulation
Best Practices¶
- File Naming:
- Use lowercase
- Use underscores
-
Be descriptive
-
Module Structure:
- Module docstring
- Imports
- Constants
- Classes
-
Functions
-
Documentation:
- Clear docstrings
- Type hints
- Usage examples