How reviealnow/aws_aibot works
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