# rohithcherukuri816/ai-based-travel-agent architecture

> Architecture diagram of the GitHub repository rohithcherukuri816/ai-based-travel-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohithcherukuri816/ai-based-travel-agent
- Repository: https://github.com/rohithcherukuri816/ai-based-travel-agent

## Overview

##### Project Type and Purpose
- This is a full-stack, AI-driven travel planning web application.
- Frontend: React/TypeScript PWA (“frontend/…”).
- Backend: FastAPI Python (“app.py”, “main.py”, “ai_chat.py”, etc.) orchestrating multiple AI agents.
- Data services: local SQLite/PostgreSQL (“database.py”, “travel_agent.db”), optional Redis cache, plus static JSON fixtures in “data/…”.
- Integrations: Google Maps, OpenWeather, Wikipedia, Eventbrite, Amadeus, Booking.com, Stripe, PayPal, etc.

##### File Structure
- Top-level scripts (app.py, main.py, ai_chat.py, analytics_dashboard.py, payment_system.py, real_apis.py) implement:
- API endpoints & gateway logic
- AI agent orchestration (LangGraph / LangChain workflows)
- Analytics reporting
- Payment creation & webhook handlers
- “config.py” holds environment configuration (DB URLs, API keys).
- “database.py” + “models.py” define ORM or raw SQL access.
- “data/” contains sample JSON for offline/demo use.
- “frontend/” is a CRA-style React app with:
- public/ – index.html, manifest, favicon
- src/ – App.tsx, components, tests, styles

##### Extract Architecture Notes from README
- Four logical layers:
1. Frontend Layer (PWA + Chat UI + Analytics Dashboard + Payment UI)
2. API Gateway (FastAPI, Auth, Rate Limiting, Security middleware)
3. AI Agent Orchestration (UserAgent, FlightAgent, HotelAgent, ActivityAgent, WeatherAgent, BudgetAgent, PlannerAgent, BookingAgent)
4. Data Layer (PostgreSQL/SQLite, Redis Cache, File Storage, External API integrations)

a. Presentation Layer
- React PWA (components: ChatWindow, AnalyticsDashboard, BookingConfirmationDisplay, etc.)
- Static assets (index.html, script.js, style.css)
b. API Gateway / Backend Layer
- FastAPI server (app.py, main.py) exposing REST and WebSocket endpoints (/api/plan, /api/chat/stream, /api/analytics/real-time, /api/payment/create-intent, /api/auth/*)
- Middleware: JWT Auth, Rate Limit, CORS
c. AI Agent Orchestration
- LangGraph StateGraph workflow defined in ai_chat.py or in the backend code
- Individual agents as logical subcomponents (FlightAgent, HotelAgent, ActivityAgent, WeatherAgent, BudgetAgent, PlannerAgent, BookingAgent)
d. Data Layer
- Relational DB (PostgreSQL or local SQLite “travel_agent.db”)
- Redis Cache (optional, for session or partial cache)
- File storage (uploads, logs)
- Static JSON fixtures (“data/…”)
e. External Services
- Google Maps Platform (Places & Directions API)
- OpenWeatherMap API
- Wikipedia API
- Eventbrite API
- Amadeus API (flights)
- Booking.com API (hotels)
- Stripe & PayPal (payment processing)

##### Relationships & Data Flow
- Frontend → HTTP/HTTPS calls → API Gateway
- API Gateway → orchestrator module (in-process or separate microservice)
- Orchestrator → reads/writes → Data Layer (DB, Redis, file)
- Orchestrator → external calls → third-party APIs
- API Gateway → returns structured JSON to Frontend
- Analytics Dashboard → polls or WebSocket → Backend Analytics endpoints

##### Architectural Patterns & Principles
- Layered architecture: clear separation of concerns
- Multi-agent orchestration pattern (LangGraph StateGraph)
- Progressive Web App for offline/low-latency interactions
- Caching layer for performance (Redis)
- Modular, single-repository monolith with logical service boundaries
- Secure API gateway with JWT, rate limiting, CORS

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        PWA["React PWA"]:::frontend
        ChatUI["ChatWindow Component"]:::frontend
        AnalyticsUI["AnalyticsDashboard Component"]:::frontend
        BookingUI["BookingConfirmationDisplay Component"]:::frontend
        PaymentUI["PaymentModal Component"]:::frontend
        Entry["React Entry Point (index.tsx)"]:::frontend
        StaticAssets["Static Assets\n(index.html, script.js, style.css)"]:::frontend
    end

    %% API Gateway / Backend Layer
    subgraph "API Gateway / Backend" 
        direction TB
        APIGateway["FastAPI Gateway\n(app.py)"]:::backend
        Routing["App Setup & Routing\n(main.py)"]:::backend
        Config["Configuration\n(config.py)"]:::backend
        Middleware["Middleware\n(JWT Auth, Rate Limit, CORS)"]:::backend
        PaymentAPI["Payment API & Webhooks\n(payment_system.py)"]:::backend
        AnalyticsAPI["Analytics Endpoints\n(analytics_dashboard.py)"]:::backend
    end

    %% AI Agent Orchestration
    subgraph "AI Agent Orchestration" 
        direction TB
        AgentOrch["Orchestrator\n(ai_chat.py)"]:::agents
        subgraph "Agents"
            direction TB
            FlightAgent["FlightAgent"]:::agents
            HotelAgent["HotelAgent"]:::agents
            ActivityAgent["ActivityAgent"]:::agents
            WeatherAgent["WeatherAgent"]:::agents
            BudgetAgent["BudgetAgent"]:::agents
            PlannerAgent["PlannerAgent"]:::agents
            BookingAgent["BookingAgent"]:::agents
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DBConn["Database Connection & ORM\n(database.py)"]:::datastores
        Models["Data Models / Schemas\n(models.py)"]:::datastores
        SQLiteDB["SQLite DB File\n(travel_agent.db)"]:::datastores
        Fixtures["Static JSON Fixtures\n(data/)"]:::datastores
        RedisCache["Redis Cache (optional)"]:::datastores
        FileStorage["File Storage\n(uploads, logs)"]:::datastores
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleMaps["Google Maps API"]:::external
        OpenWeather["OpenWeatherMap API"]:::external
        WikipediaAPI["Wikipedia API"]:::external
        Eventbrite["Eventbrite API"]:::external
        Amadeus["Amadeus API"]:::external
        BookingCom["Booking.com API"]:::external
        Stripe["Stripe"]:::external
        PayPal["PayPal"]:::external
    end

    %% Connections
    PWA -->|HTTP/HTTPS| APIGateway
    ChatUI -->|WebSocket| APIGateway
    AnalyticsUI -->|HTTP Polling / WS| AnalyticsAPI
    PaymentUI -->|HTTP| PaymentAPI

    APIGateway -->|init routing| Routing
    Routing -->|uses| Config
    Routing -->|calls| Middleware
    Routing -->|routes to| AgentOrch
    Routing -->|routes to| PaymentAPI
    Routing -->|routes to| AnalyticsAPI

    AgentOrch -->|calls| FlightAgent
    AgentOrch -->|calls| HotelAgent
    AgentOrch -->|calls| ActivityAgent
    AgentOrch -->|calls| WeatherAgent
    AgentOrch -->|calls| BudgetAgent
    AgentOrch -->|calls| PlannerAgent
    AgentOrch -->|calls| BookingAgent

    AgentOrch -->|reads/writes| DBConn
    DBConn -->|defines| Models
    AgentOrch -->|reads/writes| SQLiteDB
    AgentOrch -->|reads| Fixtures
    AgentOrch -->|caches| RedisCache
    AgentOrch -->|stores| FileStorage

    AgentOrch -->|external calls| GoogleMaps
    AgentOrch -->|external calls| OpenWeather
    AgentOrch -->|external calls| WikipediaAPI
    AgentOrch -->|external calls| Eventbrite
    AgentOrch -->|external calls| Amadeus
    AgentOrch -->|external calls| BookingCom
    PaymentAPI -->|process payments| Stripe
    PaymentAPI -->|process payments| PayPal

    %% Click Events
    click PWA "https://github.com/rohithcherukuri816/ai-based-travel-agent/tree/main/frontend/"
    click ChatUI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/frontend/src/components/ChatWindow.tsx"
    click AnalyticsUI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/frontend/src/components/AnalyticsDashboard.tsx"
    click BookingUI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/frontend/src/components/BookingConfirmationDisplay.tsx"
    click PaymentUI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/frontend/src/components/PaymentModal.tsx"
    click Entry "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/frontend/src/index.tsx"
    click APIGateway "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/app.py"
    click Routing "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/main.py"
    click Config "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/config.py"
    click AgentOrch "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/ai_chat.py"
    click GoogleMaps "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/real_apis.py"
    click PaymentAPI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/payment_system.py"
    click AnalyticsAPI "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/analytics_dashboard.py"
    click DBConn "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/database.py"
    click Models "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/models.py"
    click SQLiteDB "https://github.com/rohithcherukuri816/ai-based-travel-agent/blob/main/travel_agent.db"
    click Fixtures "https://github.com/rohithcherukuri816/ai-based-travel-agent/tree/main/data/"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef backend fill:#C8E6C9,stroke:#66BB6A,stroke-width:1px
    classDef agents fill:#FFE0B2,stroke:#FFB74D,stroke-width:1px
    classDef datastores fill:#E0E0E0,stroke:#BDBDBD,stroke-width:1px
    classDef external fill:#E1BEE7,stroke:#BA68C8,stroke-width:1px
```
