# sourangshupal/trip-planner-using-crewai architecture

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

- Interactive diagram: https://gitdiagram.com/sourangshupal/trip-planner-using-crewai
- Repository: https://github.com/sourangshupal/trip-planner-using-crewai

## Overview

##### Main Components
- User Interaction Interfaces:
- CLI (cli_app.py) for command-line usage.
- FASTAPI Server (api_app.py) which exposes REST endpoints.
- Streamlit Interface (streamlit_app.py) for a user-friendly web experience.
- Core Logic & Orchestration:
- Trip Agents (trip_agents.py) which manage AI role-playing agents.
- Trip Tasks (trip_tasks.py) that hold task prompts or planning instructions.
- Tools and Utilities Layer:
- Tools directory (tools/) including browser_tools.py, calculator_tools.py, and search_tools.py that provide supporting functionalities required by the agents.
- External Integrations:
- LLM models integration (e.g., GEMINI, Ollama, Serper, OpenAI) shown in the README examples.
- External API integrations such as Browseless. These should be noted as connections to third-party services.

##### Relationships & Interactions
- User input flows: The user inputs trip details through either CLI, the Streamlit UI, or via REST API calls. Each entry point routes input to the CrewAI framework.
- Agent Orchestration: The input is processed by trip_agents.py together with task details from trip_tasks.py. The agents then invoke specific functionalities from the tools layer.
- Data Flow: After processing, the results (trip itineraries) are returned through the respective interface back to the user.
- Configuration: Include configuration files like .env.example and Streamlit’s config.toml that denote environmental dependencies and secret management.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Different entry points (CLI, API, UI) are clearly separated in the system.
- Modular Design: The standalone modules (trip_agents, trip_tasks, and the tools submodules) indicate modular components that can be independently tested and maintained.
- Extensibility: The design emphasizes easy switching between LLM models or integration of additional tools, as demonstrated in the README snippet for integrating Ollama.
- Layered Architecture: Clearly delineate user interface layers, business logic/agent orchestration, and external service integrations.

##### Final Recommendations
- Gradually decompose each block to show internal components and their interactions.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction Interfaces
    subgraph "User Interaction Interfaces"
        CLI["CLI Interface (cli_app.py)"]:::ui
        API["REST API Server (api_app.py)"]:::ui
        Streamlit["Streamlit UI (streamlit_app.py)"]:::ui
        StreamlitConfig["Streamlit Config (.streamlit/config.toml)"]:::config
    end

    %% Core Engine Components
    subgraph "Core Engine"
        CrewAI["CrewAI Agent Orchestration (trip_agents.py)"]:::engine
        Tasks["Trip Task Definitions (trip_tasks.py)"]:::engine
    end

    %% Tools and Utilities Layer
    subgraph "Tools and Utilities"
        Tools["Tools and Utilities (tools/)"]:::tools
        Browser["Browser Tools (tools/browser_tools.py)"]:::tools
        Calculator["Calculator Tools (tools/calculator_tools.py)"]:::tools
        Search["Search Tools (tools/search_tools.py)"]:::tools
    end

    %% External Integrations & Configuration
    subgraph "External & Configuration"
        External["LLM Models & Third-Party APIs (GEMINI, Ollama, Browseless)"]:::ext
        Env["Configuration (.env.example)"]:::config
        Documentation["External Integrations Documentation (README.md)"]:::ext
    end

    %% Data Flow: User Interfaces to Core Engine
    CLI -->|"sends-input"| CrewAI
    API -->|"sends-input"| CrewAI
    Streamlit -->|"sends-input"| CrewAI

    %% Core Engine interactions
    CrewAI -->|"uses"| Tasks
    CrewAI -->|"invokes"| Tools
    CrewAI -->|"calls"| External
    Env -->|"configures"| CrewAI
    Documentation -->|"guides"| External

    %% Tools internal breakdown
    Tools -->|"provides"| Browser
    Tools -->|"provides"| Calculator
    Tools -->|"provides"| Search

    %% External feedback to Core Engine
    External -->|"returns-data"| CrewAI

    %% Core Engine returns output to User Interfaces
    CrewAI -->|"returns-itinerary"| CLI
    CrewAI -->|"returns-itinerary"| API
    CrewAI -->|"returns-itinerary"| Streamlit

    %% Click Events
    click CLI "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/cli_app.py"
    click API "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/api_app.py"
    click Streamlit "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/streamlit_app.py"
    click StreamlitConfig "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/.streamlit/config.toml"
    click CrewAI "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/trip_agents.py"
    click Tasks "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/trip_tasks.py"
    click Tools "https://github.com/sourangshupal/trip-planner-using-crewai/tree/main/tools/"
    click Browser "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/tools/browser_tools.py"
    click Calculator "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/tools/calculator_tools.py"
    click Search "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/tools/search_tools.py"
    click Env "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/.env.example"
    click Documentation "https://github.com/sourangshupal/trip-planner-using-crewai/blob/main/README.md"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef engine fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef tools fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef config fill:#E6E6FA,stroke:#333,stroke-width:2px;
```
