A comprehensive travel itinerary management system with JSON storage
Project description
Itinerizer
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 checkGET /api/itineraries- List all itinerariesGET /api/itineraries/{id}- Get specific itineraryPOST /api/itineraries- Create new itineraryPUT /api/itineraries/{id}- Update itineraryDELETE /api/itineraries/{id}- Delete itineraryPOST /api/itineraries/{id}/segments- Add segmentDELETE /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/yourusername/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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- 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/yourusername/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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file itinerizer-0.5.0-py3-none-any.whl.
File metadata
- Download URL: itinerizer-0.5.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed194a226f646c35fea47e7471aa2495ceab86797c14fe46e532b3de6a9e413
|
|
| MD5 |
40c571dbd7be09cb5078cf8d8d6dc18d
|
|
| BLAKE2b-256 |
dcb18bd67ed5bf96a1d7824b78cfde40de3e17e780eec4d1060c4d1a377be4b7
|