# reviealnow/aws_aibot architecture

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

- Interactive diagram: https://gitdiagram.com/reviealnow/aws_aibot
- Repository: https://github.com/reviealnow/aws_aibot

## Overview

##### Project Type & Purpose
- Full-stack (monolithic) web application using Flask.
- Purpose: Provide a web UI and REST API that generate personalized travel itineraries by calling Google’s Gemini AI.
- Key features: multi‐language support, cost estimates, caching, rate limiting, logging, and a modern web interface.

##### File Structure
- app.py – the Flask application entry point, defines HTTP routes.
- templates/ – Jinja2 HTML templates (index.html) and a sample request payload.
- utils/aibrain_client.py – wrapper around Google Gemini AI API.
- requirements.txt & .env – dependency management and environment configuration (.env holds GOOGLE_API_KEY).
- .github/workflows/python-app.yml – CI pipeline (unit tests, linting, deploy checks).

##### Extract Architecture Insights from the README
- Web interface (Tailwind CSS via CDN implied).
- Endpoints: GET /, GET /api/docs, GET /health, POST /generate-itinerary, POST /clear-cache.
- In-process rate limiting & in-memory caching (lru_cache).
- Logging and REST best practices.
- External dependency: Google Gemini AI.

##### Main Components & Interactions
a. Client Layer
– Web Browser (UI)
– External API Clients (other services/consumers)
b. Web Server Layer (Flask app.py)
– HTTP Router (defines endpoints)
– Rate Limiter Middleware
– Cache Layer (lru_cache decorator)
– Template Renderer (serves index.html)
– JSON API Handlers (generate-itinerary, clear-cache, health, docs)
– Logging Module
c. Business Logic Layer
– utils/aibrain_client.py (constructs prompts, calls Google Gemini AI)
d. External System
– Google Gemini AI Service (external REST API)
e. Configuration & CI
– .env (GOOGLE_API_KEY)
– .github/workflows (CI/CD pipeline)

##### Relationships & Data Flow
1. Browser → Flask GET “/” → Template Renderer → index.html → Browser
2. Browser/API Client → Flask POST “/generate-itinerary”
- Request passes Rate Limiter → Cache lookup →
– if cached, return cached itinerary
– else, forward to aibrain_client
- aibrain_client → Google Gemini AI → response → Flask → JSON back to client
3. Browser/API Client → Flask POST “/clear-cache” → clears in-memory cache → response
4. Browser/API Client → Flask GET “/health” or “/api/docs” → static JSON/docs
5. Logging is invoked at each request.

##### Architectural Patterns & Principles
- Monolithic MVC-style (Views: templates, Controllers: Flask routes, no DB Model layer).
- Single code-base, in-process caching & rate limiting.
- External AI integration via a distinct client module (separation of concerns).
- Environment-driven configuration.
- CI pipeline ensures code quality.

– Clear labels on every component (e.g., “Rate Limiter”, “Cache (lru_cache)”)
– Call out environment variables (.env) and CI pipeline as side notes
– A title (e.g., “AI Travel Assistant System Architecture”) and version/date

## Diagram (Mermaid)

```mermaid
graph TB
    classDef client fill:#ffa500,stroke:#333,stroke-width:1px
    classDef server fill:#a0d995,stroke:#333,stroke-width:1px
    classDef external fill:#80bfff,stroke:#333,stroke-width:1px
    classDef infra fill:#cccccc,stroke:#333,stroke-width:1px

    Browser["Web Browser / API Client"]:::client

    subgraph "Web Server (Flask App)"
        App["Flask App (app.py)"]:::server
        Router["HTTP Router"]:::server
        RateLimiter["Rate Limiter"]:::server
        Cache["Cache (lru_cache)"]:::server
        APIHandlers["API Handlers"]:::server
        TemplateRenderer["Template Renderer"]:::server
        Logging["Logging Module"]:::server
    end

    AIClient["AI Client Module"]:::server
    ExternalAI["Google Gemini AI Service"]:::external

    dotEnv[".env Configuration"]:::infra
    CICD["CI/CD Pipeline"]:::infra
    Dependencies["Requirements (requirements.txt)"]:::infra
    README["README.md"]:::infra
    License["LICENSE"]:::infra
    GitIgnore[".gitignore"]:::infra
    SampleRequest["Sample Request Payload"]:::infra

    Browser -->|"HTTP requests\n(GET /, POST /generate-itinerary, etc)"| Router
    Router --> RateLimiter
    RateLimiter --> Cache
    Cache -->|cache miss| APIHandlers
    Cache -->|cache hit| APIHandlers
    APIHandlers --> TemplateRenderer
    TemplateRenderer --> Browser
    APIHandlers --> AIClient
    AIClient --> ExternalAI
    ExternalAI --> AIClient
    APIHandlers -->|clears cache| Cache
    Router --> Logging
    RateLimiter --> Logging
    Cache --> Logging
    APIHandlers --> Logging
    Router -->|"GET /health, /api/docs"| APIHandlers
    Router --> SampleRequest

    App -.-> dotEnv
    App -.-> CICD
    App -.-> Dependencies
    App -.-> README
    App -.-> License
    App -.-> GitIgnore

    click App "https://github.com/reviealnow/aws_aibot/blob/main/app.py"
    click TemplateRenderer "https://github.com/reviealnow/aws_aibot/blob/main/templates/index.html"
    click SampleRequest "https://github.com/reviealnow/aws_aibot/blob/main/templates/sample_request.json"
    click AIClient "https://github.com/reviealnow/aws_aibot/blob/main/utils/aibrain_client.py"
    click CICD "https://github.com/reviealnow/aws_aibot/blob/main/.github/workflows/python-app.yml"
    click Dependencies "https://github.com/reviealnow/aws_aibot/blob/main/requirements.txt"
    click README "https://github.com/reviealnow/aws_aibot/blob/main/README.md"
    click License "https://github.com/reviealnow/aws_aibot/tree/main/LICENSE"
    click GitIgnore "https://github.com/reviealnow/aws_aibot/blob/main/.gitignore"
```
