Built with cutting-edge FastAPI, Redis caching, and PostgreSQL reliability
AI-powered trip planning • Real-time recommendations • Seamless user experience
|
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:
|
# 🚀 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! 🌟"} |
🔥 Advanced Features
- 🔐 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
- 💬 Natural Language Chat: Conversational AI interface
- 🎯 Smart Recommendations: ML-powered travel suggestions
- 📊 Data Analysis: Intelligent trip pattern recognition
- 🌍 Contextual Responses: Location-aware recommendations
- 👥 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
- ⚡ Async Operations: Non-blocking request handling
- 🐳 Docker Containerization: Easy deployment and scaling
- 📈 Monitoring Ready: Built-in health checks
- 🔄 Database Migrations: Alembic-powered schema management
# 🔥 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|
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 | sh2️⃣ 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 head4️⃣ 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 |
🔐 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🎯 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
# 🗄️ 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-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|
🍴 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🎯 2025 Development Plans
- 🌍 Multi-language AI responses (2 + languages)
- 🔒 OAuth2 social login integration
- 🤖 Custom AI model training
- 🌐 Global CDN integration
- 🚀 Serverless deployment options
📋 Changelog
- ✨ 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
- 🏗️ Project architecture design
- 📋 Database schema planning
- 🎯 API endpoint structure
- 🔧 Development environment setup
