# ridabayi/ai-trip-planner architecture

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

- Interactive diagram: https://gitdiagram.com/ridabayi/ai-trip-planner
- Repository: https://github.com/ridabayi/ai-trip-planner

## Overview

##### Project type and purpose
- AI Trip Planner is a Python-based full-stack application combining a Streamlit frontend with an LLM-powered itinerary generator.
- It includes deployment automation (Docker + Kubernetes) and an ELK-stack for logging/monitoring.

##### File structure
- Top-level artifacts:
- app.py – entrypoint for the Streamlit UI
- Dockerfile + k8s-deployment.yml – build & deploy
- elasticsearch.yml, logstash.yml, kibana.yml, filebeat.yml – ELK config
- requirements.txt – dependencies
- src/ directory subdivided into:
- Config (config loader)
- Chains (Itinerary_chain orchestration)
- Core (planner logic)
- Utils (logging, exception handling)

##### README for additional insights
- It shows key deployment targets and highlights how the app is containerized and monitored.

##### Capturing essential details without excess
- Src/ sub-modules to show code organization.
- How config.py injects API keys into Chains.
- Error handling via Utils.custom_exception.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        User["User"]:::ui
        Streamlit["Streamlit UI"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Config["Config Loader<br/>(config.py)"]:::core
        Planner["Core Planner Module<br/>(planner.py)"]:::core
        Chain["Itinerary Chain<br/>(Itinerary_chain.py)"]:::core
        Logger["Logging Utility<br/>(logger.py)"]:::core
        Exception["Exception Handler<br/>(custom_exception.py)"]:::core
    end

    %% External Services
    subgraph "External Services"
        direction TB
        LLM["LLM API"]:::ext
        Secrets["Kubernetes Secrets"]:::ext
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Docker["Docker Container<br/>(Dockerfile)"]:::infra
        K8s["Kubernetes Cluster<br/>(k8s-deployment.yml)"]:::infra
    end

    %% Observability Pipeline
    subgraph "Observability Pipeline"
        direction TB
        Filebeat["Filebeat<br/>(filebeat.yml)"]:::obs
        Logstash["Logstash<br/>(logstash.yml)"]:::obs
        Elasticsearch["Elasticsearch<br/>(elasticsearch.yml)"]:::obs
        Kibana["Kibana<br/>(kibana.yml)"]:::obs
    end

    %% Dependencies
    Requirements["Dependencies<br/>(requirements.txt)"]:::infra
    Docs["README.md"]:::infra

    %% Connections with sequence labels
    User -->|1. submit city & preferences| Streamlit
    Streamlit -->|2. load config| Config
    Config -->|uses secrets| Secrets
    Streamlit -->|3. call planner| Planner
    Planner -->|4. orchestrate chain| Chain
    Chain -->|5. POST /generate| LLM
    LLM -->|6. return response| Chain
    Chain -->|7. return itinerary| Planner
    Streamlit -->|8. render results| User

    %% Logging flow
    Streamlit -->|log event| Logger
    Planner -->|log event| Logger
    Chain -->|log event| Logger
    Exception -->|on error| Logger
    Logger -->|ship logs| Filebeat
    Filebeat -->|forward logs| Logstash
    Logstash -->|index logs| Elasticsearch
    Elasticsearch -->|visualize metrics| Kibana

    %% Infrastructure flow
    Docker -->|package app| K8s
    K8s -->|deploy container| Streamlit
    K8s -->|inject| Secrets
    K8s -->|mount config| Config

    %% Dependency docs
    Streamlit -.->|refers| Requirements
    Streamlit -.->|see| Docs

    %% Click Events
    click Streamlit "https://github.com/ridabayi/ai-trip-planner/blob/main/app.py"
    click Config "https://github.com/ridabayi/ai-trip-planner/blob/main/src/Config/config.py"
    click Planner "https://github.com/ridabayi/ai-trip-planner/blob/main/src/Core/planner.py"
    click Chain "https://github.com/ridabayi/ai-trip-planner/blob/main/src/Chains/Itinerary_chain.py"
    click Logger "https://github.com/ridabayi/ai-trip-planner/blob/main/src/Utils/logger.py"
    click Exception "https://github.com/ridabayi/ai-trip-planner/blob/main/src/Utils/custom_exception.py"
    click Docker "https://github.com/ridabayi/ai-trip-planner/tree/main/Dockerfile"
    click K8s "https://github.com/ridabayi/ai-trip-planner/blob/main/k8s-deployment.yml"
    click Filebeat "https://github.com/ridabayi/ai-trip-planner/blob/main/filebeat.yml"
    click Logstash "https://github.com/ridabayi/ai-trip-planner/blob/main/logstash.yml"
    click Elasticsearch "https://github.com/ridabayi/ai-trip-planner/blob/main/elasticsearch.yml"
    click Kibana "https://github.com/ridabayi/ai-trip-planner/blob/main/kibana.yml"
    click Requirements "https://github.com/ridabayi/ai-trip-planner/blob/main/requirements.txt"
    click Docs "https://github.com/ridabayi/ai-trip-planner/blob/main/README.md"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef core fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef ext fill:#FAD7A0,stroke:#D68910,color:#7E5109
    classDef infra fill:#E5E7E9,stroke:#7B7D7D,color:#424949
    classDef obs fill:#E8DAEF,stroke:#8E44AD,color:#4A235A
```
