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.



- π 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
- Node.js
- pnpm or yarn
-
Clone the repository ```bash git clone https://github.com/jschae23/bahn.vibe.git cd bahn.vibe ```
-
Install dependencies ```bash pnpm install ```
-
Run the development server ```bash pnpm run dev ```
-
Open your browser Navigate to http://localhost:3000
- Enter Stations: Type start and destination stations (e.g., "MΓΌnchen", "Berlin")
- Select Date: Choose your travel start date
- Set Day Limit: Choose how many consecutive days to search (1-30)
- Configure Options: Select class, max transfers, and preferences
- Search: Click "Bestpreise suchen" to find the best prices
- Book: Click "Buchen β" on any result to book directly on bahn.de
- 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
- 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
``` βββ 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 ```
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
No environment variables are required for local deployment. The app works out of the box.
- 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
- 1 day: ~2-3 seconds
- 7 days: ~14-21 seconds
- 30 days: ~60-90 seconds
The application includes built-in rate limiting (1 second delay between requests) to respect Deutsche Bahn's API limits.
Access the debug page at /debug
to:
- Test API connectivity
- Validate station searches
- Inspect request/response data
- Troubleshoot 422 errors
- Station Not Found: Try major city names like "MΓΌnchen", "Berlin", "Hamburg"
- 422 Errors: Use the debug page to inspect API requests
- No Prices Found: Try different dates or reduce transfer limits
- Connect Repository: Import your GitHub repository to Vercel
- Deploy: Vercel will automatically detect Next.js and deploy
- Custom Domain: Configure your custom domain in Vercel settings
The application works on any platform supporting Next.js:
- Netlify
- Railway
- DigitalOcean App Platform
- Self-hosted with Docker
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
- Commit:
git commit -m 'Add amazing feature'
- Push:
git push origin feature/amazing-feature
- Open a Pull Request
- Use TypeScript for all new code
- Follow the existing component structure
- Add proper error handling
- Include JSDoc comments for complex functions
This project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.
- 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