Skip to content

Repository files navigation

Train Tracker

A mobile railway information application built with React Native, Expo, and TypeScript.

Train Tracker provides features for checking train routes, retrieving live train running information, and checking Passenger Name Record (PNR) status through external API services.

Features

1. Train Route

  • Search for a train using its train number.
  • Retrieve train name and train number.
  • View the route and station information.
  • Display arrival and departure times.
  • View halt duration, distance from source, and journey day.

2. Live Train Status

  • Search using a train number.
  • Fetch live running-status information.
  • Display station-wise arrival and departure information.
  • View day/date and reported delay information.

3. PNR Status

  • Enter a 10-digit PNR number.
  • Retrieve booking and current passenger status.
  • Display train name and number.
  • View source and destination station information.
  • Display journey date, departure, arrival, and class.
  • View passenger booking and current seat details.
  • Display chart preparation status.

4. Recent PNR Information

  • Save successful PNR lookup responses locally.
  • Store recent PNR information using AsyncStorage.
  • Display the most recent saved PNR information on the home screen.

Technology Stack

Technology Purpose
React Native Mobile application development
Expo Development and build environment
TypeScript Type-safe application code
Expo Router File-based navigation
AsyncStorage Local PNR data storage
External REST APIs Train route, live status, and PNR information
React Native Components Mobile user interface

Project Structure

```text train-tracker/ ├── api/ │ ├── apiConfig.ts │ ├── liveTrainService.ts │ ├── pnrService.ts │ └── trainRouteService.ts ├── app/ │ ├── (tabs)/ │ │ ├── index.tsx │ │ └── settings.tsx │ ├── live.tsx │ ├── pnr.tsx │ └── _layout.tsx ├── components/ ├── constants/ ├── hooks/ ├── assets/ ├── app.json ├── package.json └── README.md ```

Getting Started

Prerequisites

  • Node.js
  • npm
  • Expo development environment
  • Android Studio or Xcode for emulator-based testing
  • Required API credentials

1. Clone the Repository

```bash git clone https://github.com/ItsHardikSoni/train-tracker.git ```

2. Navigate to the Project

```bash cd train-tracker ```

3. Install Dependencies

```bash npm install ```

4. Configure API Credentials

The application uses external API services for train route, live train status, and PNR information.

Configure the following values through your Expo application configuration:

  • API_KEY
  • API_HOST
  • PNR_API_HOST
  • TRAIN_ROUTE_API_HOST

The API configuration currently reads these values from Expo configuration extras.

Do not commit real API keys or private credentials to the repository. Use environment-based configuration and keep secrets out of source control.

5. Start the Application

```bash npx expo start ```

You can then open the application using an available development build, Android emulator, iOS simulator, or compatible Expo Go setup.

API Services

The application separates external API requests into dedicated service files:

  • liveTrainService.ts – retrieves live train running status.
  • pnrService.ts – retrieves PNR booking status.
  • trainRouteService.ts – retrieves train route and station information.
  • apiConfig.ts – provides API configuration values.

Local Data Storage

AsyncStorage is used to save successful PNR lookup information locally so that recent PNR details can be displayed when the user returns to the home screen.

Important Notes

  • Train information depends on the availability and response format of the configured external API services.
  • API access may require valid credentials and an active subscription.
  • The application does not operate as an official railway reservation or ticket-booking platform.
  • Live status and PNR results should be verified with official railway sources before making travel decisions.
  • The home screen includes some sample recent-search entries.

Future Improvements

Potential improvements include:

  • Station search functionality.
  • Better recent search history management.
  • Improved API error handling and loading states.
  • More detailed train schedule information.
  • Secure environment-based API credential management.

Author

Ayush

GitHub

Portfolio

Releases

Packages

Contributors

Languages