Skip to content

Tour-agensy — an AI-powered travel platform built with FastAPI. It integrates with Telegram bots and external AI services to generate travel ideas, descriptions, and images.

Notifications You must be signed in to change notification settings

Shaxob-py/tour-agents

Repository files navigation

🚀 FastAPI AI Travel Agent

Typing SVG

FastAPI PostgreSQL Redis Docker Python AI

🌟 Your Intelligent Travel Companion

Built with cutting-edge FastAPI, Redis caching, and PostgreSQL reliability
AI-powered trip planning • Real-time recommendations • Seamless user experience


🎯 Project Overview

🌟 What Makes This Special?

This AI Travel Agent is a modern, high-performance backend system designed to revolutionize travel planning. Combining the speed of FastAPI with the intelligence of AI, it delivers personalized travel recommendations, smart trip planning, and real-time travel insights.

Key Benefits:

  • 🚀 Lightning Fast: Sub-100ms response times
  • 🧠 AI-Powered: Intelligent recommendations and chat
  • 🔒 Enterprise Ready: Secure authentication and data protection
  • 📈 Scalable: Built for growth with Redis caching
  • 🌍 Global: Multi-country and category support
# 🚀 Quick Start Example
from fastapi import FastAPI
from routers import ai, auth

app = FastAPI(
    title="AI Travel Agent",
    description="Your Smart Travel Companion",
    version="1.0.0"
)

# Include routers
app.include_router(ai.router, prefix="/ai")
app.include_router(auth.router, prefix="/auth")

@app.get("/")
async def welcome():
    return {"message": "Welcome to AI Travel Agent! 🌟"}

✨ Core Features

🎨 Feature Showcase


High-Performance API
Async endpoints with automatic documentation

Robust Data Storage
Reliable relational database with migrations

Lightning Cache
In-memory caching for optimal performance

Smart Intelligence
AI-powered travel recommendations
🔥 Advanced Features

🎯 Authentication & Security

  • 🔐 JWT Token Authentication: Secure session management
  • 📱 OTP Verification: SMS-based two-factor authentication
  • 🛡️ Password Hashing: Bcrypt encryption for user data
  • 🔒 Rate Limiting: Redis-based request throttling

🤖 AI & Intelligence

  • 💬 Natural Language Chat: Conversational AI interface
  • 🎯 Smart Recommendations: ML-powered travel suggestions
  • 📊 Data Analysis: Intelligent trip pattern recognition
  • 🌍 Contextual Responses: Location-aware recommendations

🗄️ Data Management

  • 👥 User Profiles: Comprehensive user management
  • ✈️ Trip Planning: Full-featured trip creation and tracking
  • 🌍 Global Coverage: Countries and categories database
  • 📚 History Tracking: Complete user interaction history

🚀 Performance & Deployment

  • Async Operations: Non-blocking request handling
  • 🐳 Docker Containerization: Easy deployment and scaling
  • 📈 Monitoring Ready: Built-in health checks
  • 🔄 Database Migrations: Alembic-powered schema management

🚀 Quick Start

📋 Prerequisites

Python 3.11+ Docker PostgreSQL Redis

🎮 Option 1: Docker Compose (Recommended)

# 🔥 One-command setup
git clone https://github.com/your-username/fastapi-ai-agent.git
cd fastapi-ai-agent
docker-compose up -d

# 🎉 That's it! API is running at http://localhost:8000

🛠️ Option 2: Local Development

1️⃣ Clone & Setup:

git clone https://github.com/your-username/fastapi-ai-agent.git
cd fastapi-ai-agent

# Install UV (modern Python package manager)
curl -LsSf https://astral.sh/uv/install.sh | sh

2️⃣ Environment Setup:

# Create virtual environment and install deps
uv sync

# Copy environment template
cp .env.example .env

3️⃣ Database Setup:

# Start PostgreSQL & Redis
docker-compose up postgres redis -d

# Run migrations
uv run alembic upgrade head

4️⃣ Launch Application:

# Development server with hot reload
uv run uvicorn main:app --reload --host 0.0.0.0 --port 8000

# 🎊 Access: http://localhost:8000/docs

🎯 API Endpoints

🛣️ REST API Routes

🔐 Authentication
                    Register with Telegram bot

POST   /auth/login             # User authentication
POST   /auth/verify-otp        # Verify SMS OTP code
POST   /auth/refresh           # Refresh JWT token
🌍 Travel Data & Management
POST   /trips                  # Create new trip with ai and get photo for their trip
GET    /trips                  # User can see another trips
GET    /trip{id}               # User can see deteile trip
🔐 User
                    Register with Telegram bot

GET   /get/me                  # User profile
GET   /user                    # User can see another profile

📁 Project Architecture

🏗️ Clean Architecture Design

🎯 fastapi-ai-agent/
├── 🚀 main.py                    # 🌟 FastAPI application entry point
├── 📱 reply_markup.py            # 🤖 Telegram bot interface components
├── 📋 pyproject.toml             # 📦 UV package manager configuration
├── 🔒 uv.lock                    # 📌 Locked dependency versions
├── 🐳 Dockerfile                 # 🏗️ Container build instructions
├── 🐳 docker-compose.yml         # 🎼 Multi-service orchestration
├── ⚙️ Makefile                   # 🛠️ Development automation
├── 🔄 alembic.ini                # 🗄️ Database migration settings
├── 🧪 test_main.http             # 🧪 API testing scenarios
├── 📄 .gitignore                 # 🚫 Git ignore patterns
│
├── 🧠 core/                      # 🏛️ Application Core
│   ├── __init__.py
│   └── config.py                 # ⚙️ Configuration management
│
├── 🗄️ database/                  # 💾 Data Layer
│   ├── __init__.py
│   ├── base_model.py             # 🏗️ SQLAlchemy base model
│   ├── users.py                  # 👤 User data model
│   ├── trips.py                  # ✈️ Trip management model
│   ├── countries.py              # 🌍 Countries database model
│   ├── categories.py             # 📂 Travel categories model
│   └── history.py                # 📚 User history tracking
│
├── 🛣️ routers/                   # 🎯 API Routes
│   ├── __init__.py
│   ├── auth.py                   # 🔐 Authentication endpoints
│   └── ai.py                     # 🤖 AI service endpoints
│
├── 📋 schemas/                   # 📐 Data Validation
│   ├── __init__.py
│   ├── base_schema.py            # 🏗️ Pydantic base schemas
│   ├── auth.py                   # 🔐 Authentication schemas
│   └── ai_schema.py              # 🤖 AI response schemas
│
└── 🔧 services/                  # 🎪 Business Logic
    ├── __init__.py
    ├── otp_services.py           # 📱 OTP verification services
    └── utils/                    # 🛠️ Utility Functions
        ├── __init__.py
        └── utils.py              # 🔧 Helper functions

⚙️ Configuration

🎛️ Environment Variables

# 🗄️ Database Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5433
POSTGRES_DATABASE=tour_agents
POSTGRES_USER=postgres
POSTGRES_PASSWORD=*

REDIS_URL=*

TELEGRAM_BOT_TOKEN=*

GEMINI_AI_API_KEY=*
GEMINI_AI_MODEL=*
AI_URL=*

JWT_SECRET_KEY=*
JWT_ALGORITHM=*
JWT_ACCESS_TOKEN_EXPIRE_TIME=60
JWT_REFRESH_TOKEN_EXPIRE_TIME=3600

DEEPSEEK_AI_MODEL=*
DEEPSEEK_AI_API_TOKEN=*

UNSPLASH_ACCESS_KEY=*

🐳 Docker Deployment

🏗️ Production-Ready Setup

# docker-compose.yml
version: '3.9'

services:
  🚀 api:
    build: 
      context: .
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=postgresql://travel_user:secure_password@postgres:5432/travel_db
      - REDIS_URL=redis://redis:6379/0
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped
    networks:
      - travel_network

  🗄️ postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: travel_db
      POSTGRES_USER: travel_user
      POSTGRES_PASSWORD: secure_password
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U travel_user -d travel_db"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - travel_network

  ⚡ redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - travel_network

volumes:
  postgres_data:
  redis_data:

networks:
  travel_network:
    driver: bridge

🎨 API Documentation

📚 Interactive Documentation

Swagger UI ReDoc OpenAPI

🛠️ Development Workflow

🤝 Contributing Guidelines


🍴 Fork
Create your copy

📥 Clone
Get local copy

🌿 Branch
Create feature branch

💻 Code
Implement features

🧪 Test
Ensure quality

📝 Commit
Save changes

🔄 PR
Submit changes
# 🌿 Create feature branch
git checkout -b feature/amazing-new-feature

# 💻 Make your changes
# ... code, code, code ...

# 🧪 Test your changes
make test

# 📝 Commit with conventional commits
git commit -m "✨ feat(api): add trip recommendation endpoint"

# 🚀 Push and create PR
git push origin feature/amazing-new-feature

🔧 Technology Stack

🚀 Modern Backend Technologies

🎯 Category 🛠️ Technology 📝 Purpose 🏆 Version
🌐 Web Framework FastAPI High-performance async API Latest
🗄️ Database PostgreSQL Primary data storage 15+
Cache Redis Caching & session management 7+
📦 Package Manager UV Fast Python package manager Latest
🔄 Migrations Alembic Database schema management Latest
📐 Validation Pydantic Data validation & serialization V2
🐳 Containerization Docker Application containerization Latest
🤖 AI Integration OpenAI API AI chat & recommendations GPT-4

📈 Roadmap

🎯 2025 Development Plans

🔥 Q2 2025

  • 🌍 Multi-language AI responses (2 + languages)
  • 🔒 OAuth2 social login integration
  • 🤖 Custom AI model training
  • 🌐 Global CDN integration
  • 🚀 Serverless deployment options

🎉 Version History

📋 Changelog

🆕 v1.0.0 (2025-09-02)

  • ✨ Initial FastAPI application structure
  • 🗄️ PostgreSQL database models implementation
  • ⚡ Redis caching integration
  • 🔐 JWT-based authentication system
  • 📱 OTP verification services
  • 🤖 AI chat endpoints integration
  • 🐳 Docker containerization setup
  • 📚 Comprehensive API documentation

🔄 v0.9.0 (2025-08-25) - Beta

  • 🏗️ Project architecture design
  • 📋 Database schema planning
  • 🎯 API endpoint structure
  • 🔧 Development environment setup

🆘 Support & Resources

🤝 Get Help

GitHub Issues API Documentation Discussions

About

Tour-agensy — an AI-powered travel platform built with FastAPI. It integrates with Telegram bots and external AI services to generate travel ideas, descriptions, and images.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •