Skip to content

jschae23/bahn.vibe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš‚ bahn.vibe

Find the cheapest train tickets for every day of the month

bahn.vibe is a Next.js application that helps you find the best train prices on Deutsche Bahn by searching multiple days at once. Originally converted from bahn.sensei PHP project, it provides a clean, modern interface for comparing train prices across different dates.

Screenshot 2025-07-26 at 19 55 47 Screenshot 2025-07-26 at 19 56 02 Screenshot 2025-07-26 at 19 56 11

✨ Features

  • πŸ” Multi-day Price Search: Search 1-30 consecutive days for the best prices
  • πŸ’° Price Comparison: Visual highlighting of cheapest and most expensive days
  • 🎯 Direct Booking Links: One-click booking to Deutsche Bahn with pre-filled details
  • ⚑ Fast Results: Configurable search duration (3 days default for quick results)
  • πŸ“± Responsive Design: Works perfectly on desktop and mobile
  • 🎨 Modern UI: Clean interface built with shadcn/ui components
  • πŸ”„ Station Search: Auto-complete station names with fuzzy matching
  • πŸ“Š Price Analytics: Shows min, max, and average prices across searched days

πŸš€ Quick Start

Prerequisites

  • Node.js
  • pnpm or yarn

Installation

  1. Clone the repository ```bash git clone https://github.com/jschae23/bahn.vibe.git cd bahn.vibe ```

  2. Install dependencies ```bash pnpm install ```

  3. Run the development server ```bash pnpm run dev ```

  4. Open your browser Navigate to http://localhost:3000

🎯 Usage

Basic Search

  1. Enter Stations: Type start and destination stations (e.g., "MΓΌnchen", "Berlin")
  2. Select Date: Choose your travel start date
  3. Set Day Limit: Choose how many consecutive days to search (1-30)
  4. Configure Options: Select class, max transfers, and preferences
  5. Search: Click "Bestpreise suchen" to find the best prices
  6. Book: Click "Buchen β†’" on any result to book directly on bahn.de

Advanced Options

  • Class Selection: Choose between 1st and 2nd class
  • Fast Connections: Prioritize speed over price
  • Deutschland-Ticket: Search only Deutschland-Ticket compatible routes
  • Max Transfers: Limit the number of connections (0-5)
  • Day Limit: Search 1-30 consecutive days

πŸ› οΈ Technical Details

Architecture

  • Framework: Next.js 15 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS + shadcn/ui
  • API: Deutsche Bahn REST API integration
  • Deployment: Vercel-ready - enter a valid NEXT_PUBLIC_BASE_URL as an Environment Variable

Key Components

``` β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ api/search-prices/ # Main price search API β”‚ β”œβ”€β”€ api/search-station/ # Station lookup API β”‚ β”œβ”€β”€ api/test-minimal/ # Debug endpoint β”‚ └── page.tsx # Main application page β”œβ”€β”€ components/ β”‚ β”œβ”€β”€ train-search-form.tsx # Search form component β”‚ β”œβ”€β”€ train-results.tsx # Results display β”‚ └── ui/ # shadcn/ui components └── lib/ └── train-api.ts # API client functions ```

API Integration

The application integrates with Deutsche Bahn's internal APIs:

  • Station Search: https://www.bahn.de/web/api/reiseloesung/orte
  • Price Search: https://www.bahn.de/web/api/angebote/tagesbestpreis

πŸ”§ Configuration

Environment Variables

No environment variables are required for local deployment. The app works out of the box.

Customization

  • Day Limits: Modify the max day limit in components/train-search-form.tsx
  • Styling: Customize colors and themes in tailwind.config.ts
  • API Timeouts: Adjust delays in app/api/search-prices/route.ts

πŸ“Š Performance

Search Times

  • 1 day: ~2-3 seconds
  • 7 days: ~14-21 seconds
  • 30 days: ~60-90 seconds

Rate Limiting

The application includes built-in rate limiting (1 second delay between requests) to respect Deutsche Bahn's API limits.

πŸ› Debugging

Debug Mode

Access the debug page at /debug to:

  • Test API connectivity
  • Validate station searches
  • Inspect request/response data
  • Troubleshoot 422 errors

Common Issues

  1. Station Not Found: Try major city names like "MΓΌnchen", "Berlin", "Hamburg"
  2. 422 Errors: Use the debug page to inspect API requests
  3. No Prices Found: Try different dates or reduce transfer limits

πŸš€ Deployment

Vercel (Recommended)

  1. Connect Repository: Import your GitHub repository to Vercel
  2. Deploy: Vercel will automatically detect Next.js and deploy
  3. Custom Domain: Configure your custom domain in Vercel settings

Other Platforms

The application works on any platform supporting Next.js:

  • Netlify
  • Railway
  • DigitalOcean App Platform
  • Self-hosted with Docker

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly
  5. Commit: git commit -m 'Add amazing feature'
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request

Code Style

  • Use TypeScript for all new code
  • Follow the existing component structure
  • Add proper error handling
  • Include JSDoc comments for complex functions

πŸ“ License

This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Deutsche Bahn: For providing the underlying train data
  • shadcn/ui: For the beautiful UI components
  • Next.js Team: For the excellent framework
  • Original PHP Version: This project was converted from a PHP implementation of hackgrid

Vibed with v0 for German train travelers