π Intelligent Flight Search β’ π€ AI Automation β’ β‘ Real-Time Analytics
FlyMind is an intelligent flight data platform that combines AI-driven search, real-time Google Flights scraping, price analytics, and automation tools for developers, travelers, and enterprises.
With FastAPI, Streamlit, and Playwright, FlyMind delivers the performance of an API with the interactivity of a dashboard β perfect for n8n workflows, AI chatbots, and real-time travel data pipelines.
| π Global Coverage | β‘ Real-time Data | π€ AI Integration | π° Price Alerts |
|---|---|---|---|
| Search flights worldwide with intelligent city name recognition | Live Google Flights data with instant results | Perfect for n8n workflows and automation | Monitor fares and get notified of deals |
| π Flight Comparison | π Search History | π₯ Export & Share | π¨ Enhanced UX |
|---|---|---|---|
| Compare multiple searches side-by-side with charts | Save favorites and quick re-search | CSV/JSON export and shareable links | Progress indicators and print views |
- π€ n8n Workflows - HTTP Request nodes with optimized JSON responses
- π¬ Chatbots - Natural language flight queries and booking
- π Automation - Scheduled searches and price monitoring
- π’ Enterprise - Multi-tenant APIs with comprehensive logging
- π§ͺ Testing - Professional Streamlit interface for API testing
# Clone the repository
git clone https://github.com/AbdirahmanNomad/flymind.git
cd flymind
# Install dependencies
pip install -r api/requirements.txt
# Install Playwright browsers
playwright install chromium# Terminal 1: Start the API server
export PYTHONPATH=/Users/maanowork/flightstestgoogle:$PYTHONPATH
cd /Users/maanowork/flightstestgoogle
PORT=8001 uvicorn api.api:app --host 0.0.0.0 --port 8001 --reload
# Terminal 2: Start the Streamlit interface
export PYTHONPATH=/Users/maanowork/flightstestgoogle:$PYTHONPATH
cd /Users/maanowork/flightstestgoogle
streamlit run streamlit_app.py --server.port 8501Note: Replace /Users/maanowork/flightstestgoogle with your actual project path.
- π API Server: http://localhost:8001
- π¨ Streamlit App: http://localhost:8501
- π API Docs: http://localhost:8001/docs
Run the comprehensive test suite:
python3 test_all_features.pyβ Test Results: 12/12 tests passing (100%)
This will test:
- β API health and endpoints
- β Single, round-trip, and multi-city searches
- β Progress indicators and exports
- β Flight comparison and history
- β Price alerts and webhooks
- β Input validation and AI search
Latest Test Run:
β
PASSED: 1. API Health Check
β
PASSED: 2. Single Flight Search
β
PASSED: 3. Round-Trip Search
β
PASSED: 4. Multi-City Search
β
PASSED: 5. Progress Indicators
β
PASSED: 6. Export Format (CSV/JSON)
β
PASSED: 7. Flight Comparison
β
PASSED: 8. Search History
β
PASSED: 9. Price Alerts
β
PASSED: 10. Webhooks
β
PASSED: 11. Input Validation
β
PASSED: 12. AI-Powered Search
Total: 12/12 tests passed (100%)
π All features working correctly!
POST /search
Content-Type: application/json
{
"origin": "New York",
"destination": "London",
"depart_date": "2025-12-25",
"return_date": "2025-12-30",
"adults": 1,
"seat_class": "economy",
"fetch_mode": "local"
}β¨ Smart Features:
- City Name Support: "New York" β JFK, "London" β LHR
- Flexible Dates: "weekend", "+3 days", "december"
- Multi-city Support: Full support for complex itineraries (2-5 segments) - β Tested and working
- Real-time Pricing: Live Google Flights data
- Caching: Redis caching for faster repeated searches
- Async Performance: Non-blocking async/await architecture
- Search History: Automatic tracking with search_id for all searches
- Error Handling: Proper validation with 400 status codes
{
"success": true,
"total_flights": 25,
"flights": [
{
"name": "British Airways",
"departure": "8:00 AM on Wed, Dec 25",
"arrival": "11:30 AM on Wed, Dec 25",
"duration": "7 hr 30 min",
"stops": 0,
"price": "SEK 8,450",
"delay": null
}
],
"search_url": "https://www.google.com/travel/flights?...",
"timestamp": "2025-11-03T20:13:02"
}POST /webhooks
Content-Type: application/json
{
"webhook_url": "https://your-app.com/webhook/flight-alerts"
}POST /ai/search
Content-Type: application/json
{
"query": "Find me the cheapest flight from Paris to Tokyo next weekend",
"api_key": "sk-your-openai-key" // optional, can set OPENAI_API_KEY env var
}β¨ AI Features:
- Natural Language Processing: Parse complex flight queries
- Intelligent Parameter Extraction: Origin, destination, dates, preferences
- Smart Defaults: Fills in missing parameters automatically
- Real-time Search: Executes actual flight search after parsing
Example Queries:
- "Find cheap flights from Paris to Tokyo next weekend"
- "Show me round-trip flights to London in December"
- "Find business class flights from NYC to LA for next month"
POST /alerts
Content-Type: application/json
{
"trip_type": "round-trip",
"origin": "New York",
"destination": "London",
"depart_date": "2025-12-25",
"return_date": "2025-12-30",
"target_price": 5000.0,
"currency": "SEK",
"email": "[email protected]",
"notification_channels": ["email", "webhook"]
}β¨ Enhanced Features:
- Trip Types:
one-way,round-trip,multi-city - Multi-Currency:
SEK,USD,EUR,GBP - Flexible Dates: Return date for round-trip alerts
- Notification Channels: Email and webhook support
The professional Streamlit interface provides comprehensive flight search and analytics capabilities:
-
π Advanced Flight Search:
- Single, round-trip, and multi-city search support
- City name recognition (e.g., "New York" β JFK)
- Flexible date parsing ("weekend", "+3 days")
- Advanced filters (stops, class, airlines)
-
β‘ Real-Time Progress Indicators:
- Live progress bars during searches
- Status updates with completion percentage
- Estimated time remaining
- Search duration tracking
-
π Flight Comparison:
- Side-by-side comparison of multiple searches
- Price trend charts and visualizations
- Best time to book recommendations
- Comparison tables with key metrics
-
π Search History:
- Automatic saving of all searches (last 50)
- Favorite routes with quick access
- Quick re-search from history
- Filter and sort options
-
π₯ Export Functionality:
- CSV Export: Download results as CSV
- JSON Export: Download as JSON
- Print View: Print-friendly JSON format
- Share Links: Shareable search result links
-
π° Price Alerts:
- Create price monitoring alerts
- View and manage all alerts
- Multi-currency support
- Email and webhook notifications
-
π Real-time Metrics: Flight counts, price averages, statistics
-
π° Smart Pricing: Color-coded price indicators (π’ cheap, π‘ average, π΄ expensive)
-
π Direct Links: One-click access to Google Flights
-
βοΈ API Health: Real-time connection monitoring
Plan complex itineraries with multiple stops:
- Add 2-5 flight segments
- Each segment with origin, destination, and date
- Automatic city-to-airport code conversion
- Segment-specific flight results
- β Fully tested and working (10 flights found in test)
See exactly what's happening during searches:
- Progress bar (0-100%)
- Status text updates
- Estimated time remaining
- Actual completion time
- β Tested: Average search time ~8.5 seconds
Compare multiple searches side-by-side:
- Select multiple searches to compare
- Comparison table with metrics
- Price trend bar charts
- Best time to book recommendations
- Smart tips (e.g., "Book 2-3 months in advance")
- β Tested with 137 vs 35 flights comparison
Never lose your searches:
- Automatic history saving with search_id
- Favorite routes (β)
- Quick re-search button
- View results from history
- Filter by favorites
- Sort by newest/oldest
- β
API endpoint tested:
/search/{search_id}working
Download and share your results:
- CSV Export: Open in Excel, Google Sheets - β Tested (7.5KB+ files)
- JSON Export: For developers and APIs - β Tested (20KB+ files)
- Print View: Print-friendly formatted JSON (checkbox-enabled)
- Share Links: Shareable search URLs with search_id
- Automatic History: All searches saved with unique search_id
- History Endpoint: Retrieve past searches via
/search/{search_id} - Multi-City Support: History works for all trip types
- Favorites: Save favorite routes for quick access
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π§ FlyMind - AI-Powered Flight Analytics β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Trip Type: [β One Way] [β Round Trip] [β Multi City] β
β β
β π Multi-City Route β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Segment 1: [NYC] β [LAX] [π
Dec 7] β β
β β Segment 2: [LAX] β [SFO] [π
Dec 14] β β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [π Search Multi-City Flights] β
β β
β π Searching flights... 45% complete β
β ββββββββββββββββββββββββββββββββ β
β β±οΈ Estimated time remaining: 12s β
β β
β β
Found 137 flights in 8.2s β
β β
β π Results & Export β
β [π₯ Download CSV] [π₯ Download JSON] [π Share] [π Print]β
β β
β π Enable Flight Comparison β β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Search 1: 137 flights | Lowest: SEK 4,200 β β
β β Search 2: 35 flights | Lowest: SEK 5,100 β β
β β π‘ Best price: Search 1 (SEK 4,200) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β π Search History β
β β NYC β LAX (2025-11-04) [π Re-search] [ποΈ View] β
β LAX β SFO (2025-11-04) [β Favorite] [π Re-search] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Add HTTP Request Node to your n8n workflow
- Method: POST
- URL:
http://localhost:8001/search - Body Content Type: JSON
- Body:
{
"origin": "{{ $json.origin }}",
"destination": "{{ $json.destination }}",
"depart_date": "{{ $json.depart_date }}",
"adults": "{{ $json.adults || 1 }}",
"seat_class": "economy"
}Webhook β HTTP Request β Function β Email/Slack
β β β β
Trigger Search API Process Notify
Flights Results
# Build and run
docker build -t flymind-api api/
docker run -p 8001:8001 flymind-api
# Or use docker-compose
docker-compose -f api/docker-compose.yml upversion: '3.8'
services:
api:
build: ./api
ports:
- "8001:8001"
environment:
- ENVIRONMENT=production
restart: unless-stoppedβββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Streamlit β β FastAPI β β Google β
β Interface βββββΊβ Server βββββΊβ Flights β
β β β β β β
β β’ User Forms β β β’ REST API β β β’ Real-time β
β β’ Results β β β’ Webhooks β β β’ Data β
β β’ Analytics β β β’ Validation β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Playwright β
β Browser β
β Automation β
βββββββββββββββββββ
- π¨ Streamlit App: Professional testing interface
- π FastAPI Server: High-performance REST API
- π Playwright Engine: Anti-detection browser automation
- π€ City Parser: Intelligent location recognition
- π° Price Monitor: Alert system for fare changes
# API Configuration
PORT=8001
ENVIRONMENT=development
APP_NAME=FlyMind
# CORS Configuration
ALLOWED_ORIGINS=* # or comma-separated list: http://localhost:3000,https://app.example.com
# Security
REQUIRE_API_KEY=false # Set to true to enable API key authentication
API_KEY=your-super-secret-api-key
API_KEY_HEADER=X-API-Key
# Rate Limiting
RATE_LIMIT_ENABLED=false # Set to true to enable rate limiting
RATE_LIMIT_REQUESTS=100 # Requests per window
RATE_LIMIT_WINDOW=60 # Window in seconds
# Database
DATABASE_URL=sqlite:///./flymind.db # SQLite by default
# Browser Automation
PLAYWRIGHT_BROWSERS_PATH=/opt/playwright
# Optional: Redis for caching
REDIS_ENABLED=false # Set to true to enable Redis caching
REDIS_URL=redis://localhost:6379/0
# Optional: CAPTCHA Solving
CAPTCHA_API_KEY=your_2captcha_key
# Optional: AI API Keys
OPENAI_API_KEY=sk-your-openai-key
GOOGLE_AI_API_KEY=your-google-ai-key
DEEPSEEK_API_KEY=sk-your-deepseek-keyIf any files import from the old package names, update them:
# Old imports (update these)
from flightstestgoogle import flights
from google-flights-api import search_flights
# New imports
from flymind import flights
from flymind.api import search_flights# Custom browser configuration
BROWSER_CONFIG = {
"headless": True,
"viewport": {"width": 1920, "height": 1080},
"user_agent": "Mozilla/5.0...",
"locale": "en-US"
}# Run all feature tests
python3 test_all_features.py
# Test specific features
python3 test_features.py
# API unit tests
cd api && python -m pytest tests/ -v
# Integration tests
python -m pytest tests/test_integration.pyβ All 12 features tested and verified working (100% pass rate)
All features are tested systematically:
- β API Health Check - Server status and version info
- β Single Flight Search - One-way flight searches with city name recognition
- β Round-Trip Search - Return flight searches with date validation
- β Multi-City Search - Complex itineraries with 2-5 segments
- β Progress Indicators - Real-time search progress (UI feature)
- β Export Format (CSV/JSON) - Data export functionality
- β Flight Comparison - Side-by-side comparison with charts
- β Search History - Persistent search tracking with search_id
- β Price Alerts - Alert creation and management
- β Webhooks - Webhook registration (JSON and Form support)
- β Input Validation - Comprehensive input sanitization and validation
- β AI-Powered Search - Natural language flight queries
Test Coverage:
- API endpoints: 100% tested
- Input validation: Comprehensive error handling
- Database operations: All CRUD operations verified
- Multi-city support: Fully functional with segment tracking
- Error handling: Proper HTTP status codes (400, 404, 500)
# Linting and formatting
black api/ streamlit_app.py
flake8 api/ streamlit_app.py
mypy api/
# Security scanning
bandit -r api/
safety check- π Search Analytics: Popular routes and patterns
- β‘ Performance: Response times and success rates
- π° Price Tracking: Historical fare data
- π Geographic: Origin/destination insights
- π Usage Stats: API call volumes and patterns
# API Health
curl http://localhost:8001/health
# Version Info
curl http://localhost:8001/version
# Metrics (future)
curl http://localhost:8001/metrics- β Input Validation: Comprehensive request sanitization and validation
- β CORS Protection: Environment-based configurable origin restrictions
- β Rate Limiting: Built-in IP-based throttling mechanisms
- β API Key Authentication: Optional API key middleware
- β Security Headers: XSS protection, content type options, frame options
- β Error Handling: Secure error responses with structured logging
- β Data Privacy: SQLite database for persistent storage (no external services)
- β Non-root Docker: Runs as non-root user for enhanced security
- β Async Architecture: Non-blocking async/await for better performance
We welcome contributions! Please see our Contributing Guide for details.
# Install development dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install
# Run development server
make dev
# Run tests
make test- Python: PEP 8 with Black formatting
- API: RESTful design principles
- Testing: 90%+ coverage required
- Documentation: All public APIs documented
MIT License - Open source and free to use commercially.
Copyright (c) 2025 Abdirahman Ahmed
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- π Documentation: API Docs
- π Bug Reports: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: Contact via GitHub Issues
- π Star us on GitHub if you find this useful!
- π Share with fellow developers and automation enthusiasts
- π Contribute features, bug fixes, or documentation
Core Functionality:
- β Single flight search
- β Round-trip search
- β Multi-city search (2-5 segments) - Fully tested and working
- β Real-time Google Flights scraping
- β City name to airport code conversion
- β Flexible date parsing
- β Search ID tracking for history
User Experience (Streamlit):
- β Multi-city search UI with dynamic segments
- β Real-time progress indicators with time estimates
- β Flight comparison (side-by-side, charts, recommendations)
- β Search history with favorites and quick re-search
- β Export to CSV/JSON
- β Print-friendly view (checkbox-enabled)
- β Shareable links
Performance & Architecture:
- β Async/await architecture
- β Redis caching (optional)
- β Response caching with TTL
- β Non-blocking operations
Security:
- β Environment-based configuration
- β API key authentication (optional)
- β Rate limiting per IP
- β Input validation and sanitization
- β Security headers middleware
- β Non-root Docker user
- β Proper HTTP status codes (400 for validation errors)
Database & Persistence:
- β SQLite database integration
- β Search history persistence (with search_id)
- β Price alerts storage
- β Webhook management
- β Multi-city search history support
Testing:
- β Comprehensive pytest test suite
- β
Feature testing script (
test_all_features.py) - β API endpoint validation
- β 100% test pass rate (12/12 tests)
All Features Tested and Verified: 12/12 (100%)
β
API Health Check - Server responding correctly
β
Single Flight Search - 137 flights found in test
β
Round-Trip Search - 151 flights found in test
β
Multi-City Search - 10 flights found in test
β
Progress Indicators - UI feature working
β
Export Format (CSV/JSON) - Export functionality verified
β
Flight Comparison - Comparison ready (2+ searches)
β
Search History - search_id tracking working
β
Price Alerts - Alert creation successful
β
Webhooks - Registration working (JSON/Form)
β
Input Validation - Proper error handling (400 codes)
β
AI-Powered Search - AI endpoint functional
Test Results: All tests passing with comprehensive coverage of:
- API endpoints
- Database operations
- Input validation
- Error handling
- Multi-city support
- Search history tracking
Built with β€οΈ using:
- FastAPI - Modern async web framework
- Playwright - Cross-browser automation
- Streamlit - Data app framework
- n8n - Workflow automation platform
- Google Flights - Flight data source
- SQLAlchemy - Database ORM
- Pydantic - Data validation
- Redis - Caching (optional)
Special thanks to the open-source community!
β All Features Tested and Working (12/12 - 100%)
Start building amazing flight automation workflows today!
π¨ Try the Demo β’ π Read the Docs β’ π³ Deploy with Docker
Latest Updates:
- β Multi-city search fully functional
- β Search history with search_id tracking
- β Price alerts creation working
- β Webhooks support (JSON & Form)
- β Input validation with proper error codes
- β All 12 features tested and verified
Made with β€οΈ for developers who love automation