Skip to main content

A comprehensive travel itinerary management system with JSON storage

Project description

Itinerizer

PyPI Version Python Versions License Documentation Status Tests Coverage

A comprehensive travel itinerary management system with JSON storage, REST API, and web interface.

Features

  • Complete Itinerary Management: Create, update, and manage complex travel itineraries
  • Multiple Segment Types: Flights, hotels, meetings, activities, transfers, and custom segments
  • JSON Storage: Simple, file-based storage with automatic backups
  • REST API: Optional FastAPI server for building web applications
  • Web Interface: Optional Flask-based web UI with responsive design
  • Type Safety: Full type hints with Pydantic validation
  • Thread-Safe: Concurrent access with file locking
  • Extensible: Easy to extend with custom segment types and storage backends

Installation

Basic Installation

Install the core library:

pip install itinerizer

With Optional Components

Install with the REST API server:

pip install itinerizer[server]

Install with the web interface:

pip install itinerizer[web]

Install with everything:

pip install itinerizer[all]

Quick Start

Basic Usage

from datetime import date, datetime
from itinerizer import ItineraryManager, Traveler, TravelerType

# Create manager
manager = ItineraryManager()

# Create a traveler
traveler = Traveler(
    type=TravelerType.ADULT,
    first_name="Alice",
    last_name="Smith",
    email="alice@example.com"
)

# Create an itinerary
itinerary = manager.create_itinerary(
    title="Tokyo Business Trip",
    start_date=date(2025, 3, 15),
    end_date=date(2025, 3, 22),
    travelers=[traveler],
    trip_type="BUSINESS"
)

print(f"Created itinerary: {itinerary.id}")

Adding Segments

from itinerizer import FlightSegment, HotelSegment, Location, Company, Money
from decimal import Decimal

# Add a flight
flight = FlightSegment(
    flight_number="UA837",
    airline=Company(name="United Airlines", code="UA"),
    origin=Location(name="San Francisco", code="SFO"),
    destination=Location(name="Tokyo Narita", code="NRT"),
    departure_datetime=datetime(2025, 3, 15, 11, 30),
    arrival_datetime=datetime(2025, 3, 16, 15, 20),
    traveler_ids=[traveler.id],
    cabin="BUSINESS",
    total_price=Money(amount=Decimal("4500.00"), currency="USD")
)

# Add to itinerary
manager.add_segment(itinerary.id, flight)

# Add a hotel
hotel = HotelSegment(
    property=Company(name="Conrad Tokyo"),
    location=Location(name="Conrad Tokyo", city="Tokyo"),
    check_in_date=date(2025, 3, 16),
    check_out_date=date(2025, 3, 21),
    traveler_ids=[traveler.id],
    room_type="King Executive Room",
    total_price=Money(amount=Decimal("2500.00"), currency="USD")
)

manager.add_segment(itinerary.id, hotel)

Retrieving and Searching

# Get a specific itinerary
itinerary = manager.get_itinerary(itinerary_id)

# Search itineraries
business_trips = manager.search_itineraries(
    trip_type="BUSINESS",
    status="CONFIRMED"
)

# List all itineraries
all_ids = manager.list_itineraries()

REST API Server

Run the FastAPI server:

from itinerizer.server import create_app
import uvicorn

app = create_app()
uvicorn.run(app, host="0.0.0.0", port=8000)

Or from the command line:

uvicorn itinerizer.server.app:app --reload

API Endpoints

  • GET /health - Health check
  • GET /api/itineraries - List all itineraries
  • GET /api/itineraries/{id} - Get specific itinerary
  • POST /api/itineraries - Create new itinerary
  • PUT /api/itineraries/{id} - Update itinerary
  • DELETE /api/itineraries/{id} - Delete itinerary
  • POST /api/itineraries/{id}/segments - Add segment
  • DELETE /api/itineraries/{id}/segments/{segment_id} - Remove segment

API documentation available at http://localhost:8000/api/docs

Web Interface

The web interface provides a user-friendly way to manage itineraries:

cd web_ui
python app.py

Access at http://localhost:5000

Features:

  • Dashboard with itinerary overview
  • Create and edit itineraries
  • Manage travelers and segments
  • Natural language itinerary creation (with NLP addon)
  • Analytics and reporting

Data Models

Itinerary

The main container for a trip:

from itinerizer import Itinerary, ItineraryStatus

itinerary = Itinerary(
    title="European Vacation",
    status=ItineraryStatus.PLANNED,
    start_date=date(2025, 6, 1),
    end_date=date(2025, 6, 15),
    travelers=[...],
    segments=[...],
    trip_type="LEISURE"
)

Segments

Different types of travel segments:

  • FlightSegment: Air travel with airline, flight number, airports
  • HotelSegment: Accommodation with check-in/out dates
  • MeetingSegment: Business meetings with agenda and attendees
  • ActivitySegment: Tours, events, and activities
  • TransferSegment: Ground transportation
  • CustomSegment: Flexible segment for other needs

Validation

Built-in validation ensures data integrity:

from itinerizer import ItineraryValidator

validator = ItineraryValidator()
result = validator.validate(itinerary)

if not result.is_valid:
    for error in result.errors:
        print(f"Error: {error.message}")

Storage

JSON Storage (Default)

Itineraries are stored as JSON files:

data/
  itineraries/
    {uuid}.json
  backups/
    {uuid}_{timestamp}.json

Custom Storage Path

manager = ItineraryManager(storage_path="/path/to/storage")

Thread Safety

The storage system uses file locking for safe concurrent access:

from itinerizer.storage import JSONItineraryStore

store = JSONItineraryStore()
with store.singleton.edit_lock(itinerary_id):
    # Exclusive write access
    store.save(itinerary)

Advanced Features

Custom Segment Types

Extend the base segment for specialized needs:

from itinerizer import BaseSegment
from typing import Literal

class CruiseSegment(BaseSegment):
    type: Literal["CRUISE"] = "CRUISE"
    ship_name: str
    cabin_number: str
    departure_port: Location
    arrival_port: Location
    # ... additional fields

Preferences and Metadata

Store additional information:

from itinerizer import TravelPreferences

preferences = TravelPreferences(
    seat_preference="AISLE",
    meal_preference="Vegetarian",
    hotel_chain_preference=["Hilton", "Marriott"]
)

itinerary.preferences = preferences
itinerary.metadata = {
    "booking_source": "Corporate Portal",
    "approval_code": "MGR-2025-001"
}

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/bobmatnyc/itinerizer.git
cd itinerizer

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=itinerizer

Running Tests

# Unit tests
pytest tests/unit/

# Integration tests
pytest tests/integration/

# All tests with coverage
pytest --cov=itinerizer --cov-report=html

Code Quality

# Format code
black src/ tests/

# Lint
flake8 src/ tests/

# Type checking
mypy src/

Docker Support

Run with Docker:

# Build image
docker build -t itinerizer .

# Run container
docker run -p 8000:8000 itinerizer

# With docker-compose
docker-compose up

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Documentation

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with Pydantic for data validation
  • REST API powered by FastAPI
  • Web interface built with Flask
  • JSON operations optimized with orjson (optional)

Citation

If you use Itinerizer in your research or project, please cite:

@software{itinerizer,
  title = {Itinerizer: A Comprehensive Travel Itinerary Management System},
  author = {Itinerizer Contributors},
  year = {2025},
  url = {https://github.com/bobmatnyc/itinerizer}
}

Made with ❤️ by the Itinerizer Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

itinerizer-0.5.3.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itinerizer-0.5.3-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file itinerizer-0.5.3.tar.gz.

File metadata

  • Download URL: itinerizer-0.5.3.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for itinerizer-0.5.3.tar.gz
Algorithm Hash digest
SHA256 e98991d1592625ab92589dc9b6d2df918f08b6d9dee421de6a1a28f36ea4527c
MD5 404f4de0722d858440b1c00a3a31b1fb
BLAKE2b-256 2ef37388eb9cca909851222a9df059114391fff2a55fd4d46f528cd0c9a39ee4

See more details on using hashes here.

File details

Details for the file itinerizer-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: itinerizer-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for itinerizer-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 449bb3f173e879ccfb21acc04bdd89657ea8d8b08e4e696f3cfec70f4f5c5442
MD5 9dbdb80e853ac5898ede9e4f5aefac79
BLAKE2b-256 feb084b8cf88c530c0f965ce78e1cf4234478dab02d0d3cc6c65b01af9cc199f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page