Developing an Indian Train 🚆 Booking App requires official approval from IRCTC since it controls railway ticketing in India. This tutorial will guide you through the official approach to building an IRCTC-approved railway booking app using Jetpack Compose (Android) and Node.js (Backend).
1. Features:
- Train Search (by source & destination)
- PNR Status Check
- Live Train Status
- Seat Availability
- Train Fare Inquiry
- Tatkal & Sleeper Class Booking
- Payment Gateway Integration (UPI, Cards, Wallets)
- User Authentication & Profile
- Notifications (for PNR updates, train delays)
- Offline Mode for recent searches
Tech Stack:
- Frontend: Jetpack Compose
- Backend: Firebase (or custom Node.js/Python backend)
- Database: Firestore / Room (for offline caching)
- APIs: Indian Railways API (IRCTC, NTES, RapidAPI)
- Payment: Razorpay, PhonePe, Paytm
2. Getting Train Data via API
Indian Railways provides APIs via:
- IRCTC Official APIs (Requires IRCTC partnership)
- NTES (National Train Enquiry System) API for live status
- RapidAPI’s Indian Railways API (for PNR status, train schedules)
Example API Endpoints:
- GET /pnr-status/{pnr_number}
- GET /train-between/{source}/{destination}
- GET /live-train-status/{train_number}
- POST /book-ticket
3. Building the Jetpack Compose UI
Authentication & Onboarding
- Google Sign-In / OTP-based login
- Store user profile & preferences (preferred trains, stations)
Home Screen
- Search Trains (AutoCompleteTextField for source/destination)
- Recent Searches & Upcoming Journeys
- Live Train Status button
Train List Screen
- Display trains, timings, seat availability
- Filters (AC/Sleeper, Fastest, Cheapest)
- Sort by departure, duration, price
PNR & Booking Screen
- Fetch PNR status, show seat details
- Select class, quota (General, Tatkal, Ladies, etc.)
- Payment Gateway Integration (Razorpay, UPI)
- IRCTC login for ticket confirmation
Live Train Status
- Show real-time train tracking on Google Maps
- Display estimated arrival time at next station
4. Backend Development
- Firebase Firestore: Store user bookings, recent searches
- Node.js / Python Backend: Handle API requests, store logs
- Secure API Requests: Use OAuth for IRCTC API calls
- Notifications: Firebase Cloud Messaging (FCM) for train alerts
5. Ticket Booking & Payment
- IRCTC mandates partnerships for direct ticket booking
- Alternative: Redirect users to IRCTC’s ticket booking page
- Integrate UPI & Razorpay for payment
6. Additional Features
- Train Coach Position Display
- Offline Mode for PNR status
- Dark Mode UI
- Refer & Earn System
7. Deployment & Optimization
- Optimize Jetpack Compose UI for smooth scrolling
- Use WorkManager for background API updates
- Release on Play Store with IRCTC approval
Challenges:
- IRCTC API access requires approval & partnership
- Payment gateway integration for ticket booking
- Handling API rate limits efficiently
- Would you like code samples for API integration or specific UI components? 🚆
IRCTC API access requires approval and a partnership because IRCTC (Indian Railway Catering and Tourism Corporation) has strict guidelines for third-party ticket booking. Here’s what you need to know about eligibility and approval:
1. Key Requirements for IRCTC Approval
Before building the app, you must get approval from IRCTC. Here’s how:
- A. Official IRCTC API Access
- Visit IRCTC API Registration.
- Apply for IRCTC B2C (Business to Customer) API.
- Required Documents:
- Company Registration Certificate
- GST Number
- PAN & Aadhaar Card of Owner
- Website & App Details
- Security Deposit (₹2-5 Lakh depending on API usage)
- B. IRCTC Agent Registration (If Needed)
- If you're planning to work as an agent instead of API integration, register as an IRCTC PSP (Principal Service Provider).
- Apply via IRCTC Agent Registration.
To integrate comprehensive train booking features into your app, including PNR enquiry, live train status, train search, and support for Tatkal and sleeper classes, collaborating with the Indian Railway Catering and Tourism Corporation (IRCTC) is essential. IRCTC offers opportunities through its Affiliate Program and Authorized Agent Program, each catering to different business models.
IRCTC Affiliate Program
The IRCTC Affiliate Program allows individuals and businesses to promote IRCTC's tourism products and earn commissions on successful bookings made through their referral links. This program is ideal for bloggers, influencers, and marketers who wish to monetize their platforms by sharing IRCTC services.
Key Features:
Commission Earnings: Earn up to 4% commission on every successful referral, including train and bus bookings.
EARNKARO.COM
Easy Registration: Sign up as an individual or business by providing a government-issued ID, address proof, and bank account details.
AFFILIATICS.COM
Promotion Tools: Utilize affiliate links to promote IRCTC tourism products across various platforms such as blogs, social media, and messaging apps.
How to Join:
Register: Visit the IRCTC Affiliate Program registration page and sign up by providing the necessary details.
Account Activation: Submit the required documents, including ID proof and bank account information, for verification.
Start Promoting: Once approved, access your affiliate dashboard to obtain referral links and start promoting IRCTC products.
IRCTC Authorized Agent Program
For businesses aiming to offer direct train ticket booking services within their app, becoming an IRCTC Authorized Agent is the appropriate route. This program permits agents to book tickets on behalf of customers and provides access to IRCTC's booking systems.
Key Features:
Unlimited Bookings: Agents can book an unlimited number of e-tickets, including General, Tatkal, Waiting List, and RAC tickets.
ERAIL.IN
Commission Structure: Earn commissions per PNR, with rates such as Rs.20 for Non-AC and Rs.40 for AC classes.
INDIRAIL.IN
Official Recognition: Your agency's name and contact details will be printed on tickets, and you'll receive an authorized agent certificate from IRCTC.
How to Become an Authorized Agent:
Choose a Principal Service Provider (PSP): IRCTC appoints PSPs to manage agent registrations. Entities like Akbar Travels and IndiRail are examples.
Registration Process:
Fill Application Form: Complete the online registration form provided by the chosen PSP.
Submit Documents: Provide necessary documents, including PAN card, Aadhaar card, photograph, mobile number, and email address.
Pay Fees: Pay the applicable registration fees as specified by the PSP.
Training and Activation: Upon successful verification, receive your agent login credentials. Many PSPs offer training sessions to familiarize agents with the booking process.
Considerations:
Compliance: Ensure adherence to IRCTC's guidelines and policies to maintain authorization status.
Technical Integration: Develop a secure and user-friendly interface within your app to handle bookings, payments, and real-time updates.
User Support: Establish a support system to assist users with booking inquiries, cancellations, and other related services.
By aligning with IRCTC through the Affiliate or Authorized Agent programs, you can enhance your app's offerings, provide valuable services to users, and establish a sustainable revenue model.
Let's Build an Android Train Ticket Booking App using Jetpack Compose:
Step 1: Setup Jetpack Compose
Add Compose dependencies in build.gradle:
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
implementation ("com.squareup.retrofit2:converter-gson:2.9.0")
implementation ("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
// Room Database (Using KSP)
implementation("androidx.room:room-runtime:2.6.1")
implementation("androidx.room:room-ktx:2.6.1")
implementation("androidx.navigation:navigation-compose:2.8.7")
ksp("androidx.room:room-compiler:2.6.1")
// Firebase for authentication & notifications
implementation ("com.google.firebase:firebase-auth-ktx")
implementation ("com.google.firebase:firebase-messaging-ktx:24.1.0")
// Payment Gateway (Razorpay)
implementation ("com.razorpay:checkout:1.6.26")
// Hilt Dependency Injection
implementation("com.google.dagger:hilt-android:2.48")
ksp("com.google.dagger:hilt-compiler:2.48") // Use KSP for Hilt
Add in build.gradle.kts(Module :app):
Add in build.gradle.kts(Project):id("com.google.devtools.ksp")
id("com.google.devtools.ksp") version "2.0.21-1.0.27" apply false
Step 2: Setup Navigation
Create a Navigation Graph in Jetpack Compose.