Skip to content

A modern React/TypeScript web app for real-time Indian Railways information. Features train search, PNR status checking, live tracking, station database, and seat availability. Built with Tailwind CSS, mobile-responsive, and integrates multiple railway APIs for reliable data. Your complete Indian Railways companion. πŸš‚βœ¨

Notifications You must be signed in to change notification settings

himrd95/train-search-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TrainSearch - Real-Time Indian Railways App

A modern, real-time train search application for Indian Railways built with React, TypeScript, and Tailwind CSS. Get live train information, check PNR status, track trains, and find seat availability.

πŸš€ Features

  • Real-time Train Search: Search trains between stations with live data
  • Auto-suggestion Search: Intelligent station search with suggestions
  • PNR Status Check: Check booking status with real-time updates
  • Live Train Tracking: Track train location and delays
  • Seat Availability: Check real-time seat availability for all classes
  • Route Information: Complete train route with station details
  • Mobile Responsive: Beautiful UI that works on all devices
  • Refresh Functionality: Real-time data refresh throughout the app
  • Multiple API Support: Fallback to multiple APIs for reliability

πŸ› οΈ Tech Stack

  • Frontend: React 18 + TypeScript
  • Styling: Tailwind CSS
  • Build Tool: Vite
  • Icons: Lucide React
  • Date Picker: React DatePicker
  • HTTP Client: Axios
  • Routing: React Router DOM

πŸ“¦ Installation

  1. Clone the repository

    git clone <repository-url>
    cd train-search-app
  2. Install dependencies

    npm install
  3. Set up environment variables Create a .env file in the root directory:

    # RapidAPI Configuration (Optional - for enhanced features)
    VITE_RAPIDAPI_KEY=your_rapidapi_key_here
    
    # Indian Railways API (Optional - for enhanced features)
    VITE_RAILWAY_API_KEY=your_railway_api_key_here
    
    # App Configuration
    VITE_APP_NAME=TrainSearch
    VITE_APP_VERSION=1.0.0
  4. Start the development server

    npm run dev
  5. Open your browser Navigate to http://localhost:5173

πŸ”‘ API Setup

Free APIs (No Key Required) βœ…

The app works out of the box with free APIs:

  • Indian Railways Free API
  • Alternative Railway APIs

Enhanced APIs (Optional)

For better features and reliability, you can add:

RapidAPI

  1. Sign up at RapidAPI
  2. Subscribe to "Indian Railways API"
  3. Get your API key
  4. Add to .env: VITE_RAPIDAPI_KEY=your_key

Railway API

  1. Visit Railway API
  2. Register and get API key
  3. Add to .env: VITE_RAILWAY_API_KEY=your_key

🎯 Usage

Train Search

  1. Enter source and destination stations (with auto-suggestions)
  2. Select journey date
  3. Click "Search Trains"
  4. View results with real-time availability
  5. Use filters to narrow down results

PNR Status

  1. Enter 10-digit PNR number
  2. Click "Check"
  3. View booking status and passenger details
  4. Refresh for latest updates

Live Status

  1. Enter train number
  2. Click "Check"
  3. View current location and delays
  4. Switch to "Complete Route" tab for full journey

Seat Availability

  1. Select a train from search results
  2. Click "Check Availability"
  3. Select travel class
  4. View real-time availability and fares

πŸ”„ Refresh Functionality

The app includes refresh buttons throughout:

  • Station Search: Refresh suggestions
  • Train Search: Refresh results
  • PNR Status: Refresh booking status
  • Live Status: Refresh train location
  • Seat Availability: Refresh availability data

πŸ“± Mobile Responsive

The app is fully responsive and optimized for:

  • Mobile phones
  • Tablets
  • Desktop computers
  • Touch interfaces

🎨 UI/UX Features

  • Apple-inspired Design: Clean, modern interface
  • Smooth Animations: Loading states and transitions
  • Intuitive Navigation: Easy-to-use interface
  • Error Handling: User-friendly error messages
  • Loading States: Visual feedback during API calls
  • Auto-suggestions: Smart station search

🚨 Error Handling

The app includes comprehensive error handling:

  • Network connectivity issues
  • API rate limiting
  • Invalid inputs
  • No results found
  • Server errors

πŸ”§ Configuration

Environment Variables

# Required for enhanced features
VITE_RAPIDAPI_KEY=your_key_here
VITE_RAILWAY_API_KEY=your_key_here

# Optional app configuration
VITE_APP_NAME=TrainSearch
VITE_APP_VERSION=1.0.0

API Configuration

The app automatically tries multiple APIs in order:

  1. Free Indian Railways API
  2. RapidAPI (if configured)
  3. Railway API (if configured)
  4. Alternative free APIs

πŸ“Š API Endpoints

Train Search

GET /trains?from=NDLS&to=BCT&date=2024-01-15

Station Search

GET /stations?q=delhi

PNR Status

GET /pnr?pnr=1234567890

Live Status

GET /live-status?train=12301

Route Information

GET /route?train=12301

Seat Availability

GET /availability?train=12301&from=NDLS&to=BCT&date=2024-01-15&class=SL

πŸš€ Deployment

Vercel (Recommended)

  1. Push code to GitHub
  2. Connect repository to Vercel
  3. Add environment variables in Vercel dashboard
  4. Deploy automatically

Netlify

  1. Build the project: npm run build
  2. Upload dist folder to Netlify
  3. Add environment variables in Netlify dashboard

Other Platforms

The app can be deployed to any static hosting platform:

  • GitHub Pages
  • Firebase Hosting
  • AWS S3
  • Cloudflare Pages

πŸ” Troubleshooting

Common Issues

  1. "API key not configured"

    • Check your .env file
    • Ensure environment variables are loaded
    • Restart the development server
  2. "No trains found"

    • Verify station names are correct
    • Check if the train runs on selected date
    • Try different date ranges
  3. "Rate limit exceeded"

    • Upgrade to paid plan
    • Use multiple API providers
    • Implement caching
  4. "Network error"

    • Check internet connection
    • Verify API endpoints are accessible
    • Check CORS settings

Getting Help

  1. Check the browser console for error messages
  2. Verify API keys are correct
  3. Test with Postman or similar tools
  4. Check API documentation
  5. Contact API providers for support

πŸ“ˆ Performance

  • Fast Loading: Optimized bundle size
  • Caching: Intelligent API response caching
  • Retry Logic: Automatic retry on API failures
  • Fallback APIs: Multiple API providers for reliability

πŸ”’ Security

  • Environment Variables: API keys stored securely
  • Input Validation: All user inputs validated
  • Error Handling: No sensitive data exposed in errors
  • HTTPS Only: Secure API communications

🀝 Contributing

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

πŸ“„ License

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

πŸ™ Acknowledgments

  • Indian Railways for providing train data
  • RapidAPI for API marketplace
  • Vercel for hosting free APIs
  • Open source community for tools and libraries

πŸ“ž Support

For support and questions:

  • Create an issue on GitHub
  • Check the API_SETUP.md file
  • Review the troubleshooting section

Happy traveling! πŸš‚βœ¨

About

A modern React/TypeScript web app for real-time Indian Railways information. Features train search, PNR status checking, live tracking, station database, and seat availability. Built with Tailwind CSS, mobile-responsive, and integrates multiple railway APIs for reliable data. Your complete Indian Railways companion. πŸš‚βœ¨

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages