Skip to content

🎯 Hunt for the cheapest Deutsche Bahn train tickets with flexible routing, parallel search, and interactive CLI. Save searches, compare prices across dates, and never overpay for train travel again!

License

Notifications You must be signed in to change notification settings

anshamray/db-price-hunter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 DB Price Hunter

Hunt for the cheapest Deutsche Bahn train tickets with flexible routing, time preferences, and fun train emoji animations. Never overpay for train travel again!

Node.js License: MIT

✨ Features

🎯 Smart Price Hunting

  • Flexible routing: Return from different cities (Berlin β†’ Munich, Dortmund β†’ Berlin)
  • Multiple trip types: Same-day returns, multi-day trips, one-way journeys
  • Time preferences: Early (04:00-07:59), Morning, Afternoon, Evening, Late departures
  • Custom time constraints: Arrive before/after specific times, time ranges
  • Parallel search: Configurable concurrency (1-8 parallel searches) for faster results

πŸš… Interactive & Visual

  • Fun train animations: Animated emoji trains while searching πŸš‚πŸ’¨
  • Progress indicators: Real-time search progress with elapsed time
  • Color-coded results: Clear visual feedback for all operations
  • Date-by-date progress: See results as they're found

πŸ’» Multiple Interfaces

  • Interactive CLI: Guided prompts for easy use
  • Command-line mode: Direct arguments for automation
  • Multiple output formats: Console, table, JSON, CSV
  • File export: Save results for further analysis

βš™οΈ Advanced Configuration

  • Persistent settings: Save preferences in ~/.db-price-hunter/config.json
  • Common routes: Pre-configured popular routes (Berlin-Munich, etc.)
  • Favorite stations: Bookmark frequently used stations
  • Saved searches: Save and reuse search parameters for frequent trips
  • Retry logic: Automatic retry with exponential backoff
  • Performance tuning: Configurable batch processing and API rate limiting

πŸš€ Quick Start

# Clone and install
git clone https://github.com/yourusername/db-price-hunter.git
cd db-price-hunter
npm install

# Interactive mode (guided prompts)
node db-price-analyzer.js

# Quick search with predefined route
node db-price-analyzer.js --route berlin-munich --date 08-15

# Morning departures with JSON export
node db-price-analyzer.js --route hamburg-frankfurt --date 2025-08-20 --morning --output json

πŸ“‹ Command Examples

# Basic searches
node db-price-analyzer.js --route berlin-munich --date 08-15
node db-price-analyzer.js --route hamburg-frankfurt --date 08-15 --trip-type one-way

# With time preferences
node db-price-analyzer.js --route berlin-munich --date 08-15 --morning
node db-price-analyzer.js --route cologne-dortmund --date 08-15 --evening

# Performance options
node db-price-analyzer.js --route berlin-munich --date 08-15 --concurrency 6
node db-price-analyzer.js --route hamburg-frankfurt --date 08-15 --concurrency 2

# Output formats
node db-price-analyzer.js --route berlin-munich --date 08-15 --output table
node db-price-analyzer.js --route berlin-munich --date 08-15 --output json --output-file results.json

# Save and reuse searches
node db-price-analyzer.js --route berlin-munich --date 08-15 --save-search "weekend-trip"
node db-price-analyzer.js --load-search "weekend-trip"
node db-price-analyzer.js --list-searches
node db-price-analyzer.js --delete-search "old-search"

# Utility commands
node db-price-analyzer.js --list-routes
node db-price-analyzer.js --help
npm run demo  # Watch train animations

πŸ“Š Output Examples

Console Output (Default)

🎯 DB Price Hunter

πŸš… Checking Sat, Aug 15, 2025... βœ… Found: €89.90
πŸš„ Checking Sun, Aug 16, 2025... βœ… Found: €76.90

1. πŸ’° €76.90 - Available on 1 date:
   πŸ“… Sun, Aug 16, 2025
      πŸš„ Out: ICE 587 | 08:34 β†’ 12:28 | €38.45 | Direct
      πŸ”„ Ret: ICE 1006 | 18:32 β†’ 22:28 | €38.45 | Direct

Table Format

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Date        β”‚ Out Trainβ”‚ Out Depβ”‚ Out Arrβ”‚ Ret Trainβ”‚ Ret Depβ”‚ Ret Arrβ”‚ Total Price β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Aug 16      β”‚ ICE 587  β”‚ 08:34  β”‚ 12:28  β”‚ ICE 1006 β”‚ 18:32  β”‚ 22:28  β”‚ €76.90      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Configuration

Auto-generated config at ~/.db-price-hunter/config.json:

{
  "preferences": {
    "outputFormat": "console",
    "useTrainAnimations": true,
    "maxResults": 10,
    "defaultTripType": "same-day",
    "maxConcurrency": 3
  },
  "commonRoutes": {
    "berlin-munich": {
      "departure": { "id": "8011160", "name": "Berlin Hbf" },
      "destination": { "id": "8000261", "name": "MΓΌnchen Hbf" }
    }
  },
  "savedSearches": {
    "weekend-trip": {
      "departureStation": { "id": "8011160", "name": "Berlin Hbf" },
      "destinationStation": { "id": "8000261", "name": "MΓΌnchen Hbf" },
      "tripType": "same-day",
      "savedAt": "2025-06-25T10:30:00.000Z"
    }
  }
}

πŸ—οΈ Project Structure

db-price-hunter/
β”œβ”€β”€ db-price-analyzer.js      # Main CLI application
β”œβ”€β”€ src/                      # Core modules
β”‚   β”œβ”€β”€ journey-search.js    # All search functions (same-day, one-way, multi-day)
β”‚   β”œβ”€β”€ user-interface.js    # Interactive prompts & input handling
β”‚   β”œβ”€β”€ results-display.js   # Results formatting & output
β”‚   β”œβ”€β”€ cli-handler.js       # Command-line mode processing
β”‚   β”œβ”€β”€ journey-utils.js     # Date/time utilities & journey extraction
β”‚   β”œβ”€β”€ cli-args.js          # Command-line parsing & concurrency options
β”‚   β”œβ”€β”€ config.js            # Configuration management
β”‚   β”œβ”€β”€ search-management.js # Save/load search functionality
β”‚   β”œβ”€β”€ output-formatters.js # Output formats & parallel search progress
β”‚   β”œβ”€β”€ error-handler.js     # Parallel search with batch processing
β”‚   β”œβ”€β”€ time-preferences.js  # Time filtering logic
β”‚   β”œβ”€β”€ time-selector.js     # Time preference UI
β”‚   β”œβ”€β”€ station-selector.js  # Station selection UI
β”‚   └── cities.js            # City/station data & search
β”œβ”€β”€ examples/                 # Demo scripts
β”‚   β”œβ”€β”€ animation-demo.js    # Train animation showcase
β”‚   └── ...                  # Debug utilities
└── README.md

🀝 Contributing

Contributions welcome! Please open an issue or submit a Pull Request.

πŸ“ License

MIT License - see LICENSE file.

πŸ™ Acknowledgments

  • Built with db-vendo-client
  • Train emoji animations make CLI tools fun! πŸš‚βœ¨

Happy train travels! πŸš„πŸŽ«

About

🎯 Hunt for the cheapest Deutsche Bahn train tickets with flexible routing, parallel search, and interactive CLI. Save searches, compare prices across dates, and never overpay for train travel again!

Topics

Resources

License

Stars

Watchers

Forks