# crewaiinc/crewai-tools architecture

> Architecture diagram of the GitHub repository crewaiinc/crewai-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crewaiinc/crewai-tools
- Repository: https://github.com/crewaiinc/crewai-tools

## Overview

##### Main Components
- Core Library (crewai_tools):
- This is the container package for the entire suite of tools.
- It contains subpackages including “adapters”, “aws”, and “tools”.
- Adapters:
- Under “crewai_tools/adapters”, these modules (e.g., embedchain_adapter, lancedb_adapter, and pdf_embedchain_adapter) provide integration layers to interface with external systems or services.
- AWS Integration:
- The “crewai_tools/aws” directory holds submodules for AWS integrations. This includes support for AWS Bedrock (with agents and a knowledge base), and AWS S3 (with reader and writer tools).
- Tools Collection:
- The “crewai_tools/tools” directory is the largest portion and contains many self-contained tool submodules (each in its own folder with README and source files).
- They include functionalities such as web scraping (e.g., SeleniumScrapingTool, ScrapflyScrapeWebsiteTool, etc.), file reading/writing, database integrations (e.g., PGSearchTool, MySQLSearchTool), AI-powered tools (DallETool, VisionTool), and more.
- Testing Infrastructure:
- The “tests” directory, along with integration tests in tests/it, provides the framework for validating tool functionality.
- Configuration & Infrastructure:
- Files such as .gitignore, pyproject.toml, and pre-commit configuration show support for code quality and dependency management.

##### Relationships and Interactions
- The “crewai_tools” package serves as the backbone.
- The “tools” subpackage may either (a) subclass a common BaseTool class or (b) be created using a decorator methodology, as highlighted in the README.
- The “adapters” and “aws” directories indicate that some tools have a dependency on third-party services (like AWS services) or serve as bridges to other platforms.
- Interdependencies:
- For example, tool implementations (in tools/) might rely on shared functionality or common patterns defined in the core package.
- AWS integrations (bedrock, s3) may communicate with external AWS services.

##### Architectural Patterns and Design Principles
- Modularity: Each tool is encapsulated in its own module/folder, making it easy to add or remove functionality.
- Extensibility: The project supports two patterns for custom tools (subclassing BaseTool and a decorator-based approach), so the design should emphasize extension points.
- Integration: There is a clear separation between core functionalities (tools) and integration layers (adapters, AWS-specific components).
- Testing: The presence of separate test directories shows adherence to testing best practices.

##### Relevant Technologies and Frameworks
- Python is the core language.
- AWS integrations suggest use of AWS SDKs or libraries.
- The README mentions “uv sync” and “pyright” for development tasks, and Docker is present for code interpreter tool support.
- Pre-commit tools (via .pre-commit-config.yaml) for static analysis and code quality.

##### Elements
- All major components should have clear, descriptive labels.
- CrewAI Agents/Consumers → Core Tools library.
- Tools interacting with external services (e.g., AWS, third-party APIs).
- Core packages versus integration/adapters versus individual tool modules.
- Optionally incorporate annotations on how developers can create custom tools through subclassing or decorators as described in the README.

##### Final Advice to the Principal Software Engineer
- Detailing each module’s role in the overall ecosystem.
- Clearly separate core functionality (shared by all tools) from specialized implementations.
- Avoid over-simplification; the goal is to capture as many key components as possible with clear interactions and extension points.

## Diagram (Mermaid)

```mermaid
graph TD
    External["External CrewAI Agents"]:::external
    coreLib["CrewAI Tools Library"]:::core

    External -->|"calls"| coreLib

    %% Core Library Subcomponents
    coreLib --> adapters["Adapters"]:::integration
    coreLib --> awsIntegration["AWS Integration"]:::integration
    coreLib --> toolsCollection["Tools Collection"]:::tools

    %% AWS Integration Details
    awsIntegration --> awsb["AWS Bedrock"]:::integration
    awsIntegration --> awss["AWS S3"]:::integration

    %% AWS Bedrock Details
    awsb --> bedrockAgent["Bedrock Agents"]:::integration
    awsb --> bedrockKB["Knowledge Base"]:::integration

    %% AWS S3 Details
    awss --> s3Reader["S3 Reader"]:::integration
    awss --> s3Writer["S3 Writer"]:::integration

    %% Ancillary Components
    coreLib --> testInfra["Testing Infrastructure"]:::test
    coreLib --> configGroup["Configuration Files"]:::config

    %% Configuration Files Breakdown
    configGroup --> gitignore[".gitignore"]:::config
    configGroup --> pyproject["pyproject.toml"]:::config
    configGroup --> precommit[".pre-commit-config.yaml"]:::config

    %% Click Events
    click coreLib "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/"
    click adapters "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/adapters/"
    click awsIntegration "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/aws/"
    click awsb "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/aws/bedrock/"
    click bedrockAgent "https://github.com/crewaiinc/crewai-tools/blob/main/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py"
    click bedrockKB "https://github.com/crewaiinc/crewai-tools/blob/main/crewai_tools/aws/bedrock/knowledge_base/retriever_tool.py"
    click awss "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/aws/s3/"
    click s3Reader "https://github.com/crewaiinc/crewai-tools/blob/main/crewai_tools/aws/s3/reader_tool.py"
    click s3Writer "https://github.com/crewaiinc/crewai-tools/blob/main/crewai_tools/aws/s3/writer_tool.py"
    click toolsCollection "https://github.com/crewaiinc/crewai-tools/tree/main/crewai_tools/tools/"
    click testInfra "https://github.com/crewaiinc/crewai-tools/tree/main/tests/"
    click gitignore "https://github.com/crewaiinc/crewai-tools/blob/main/.gitignore"
    click pyproject "https://github.com/crewaiinc/crewai-tools/blob/main/pyproject.toml"
    click precommit "https://github.com/crewaiinc/crewai-tools/blob/main/.pre-commit-config.yaml"

    %% Styles
    classDef external fill:#E1BEE7,stroke:#333,stroke-width:2px;
    classDef core fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef integration fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef tools fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef test fill:#F8BBD0,stroke:#333,stroke-width:2px;
    classDef config fill:#D7CCC8,stroke:#333,stroke-width:2px;
```
