RailTC Logo

Your Journey, Our Analyzer

RailTCProject Architecture & Explanation

5 min read

About This Document

This document acts as a complete architectural overview of the RailTC system. Accessing this allows anyone (Technical or Non-technical) to understand the project's core mission and inner workings.

1. Project Goal

Problem: The Indian Railways PNR confirmation system is complex. Existing apps often provide a simple "Yes/No" or offer false hope without explanation.

Solution (RailTC): We are building a Transparent System that provides users not just with a prediction, but with the logic behind it.

Individual Prediction

Risk is calculated for each passenger individually (e.g., Senior Citizen confirm vs. General waiting).

Transparency

We show the math: Quota penalty, Route bonus, etc.

Accountability

We grade ourselves with a visible Accuracy Score.

2. High-Level Architecture

Imagine a restaurant:

  • Frontend (Waiter): Takes the PNR from the user and delivers the result.
  • Backend (Kitchen): Where the real work happens (Data fetching, Calculation).
  • Database (Store Room): Where old records and predictions are stored.
  • Cron Job (Manager): Checks nightly: "How many predictions were correct today?"
User -> Frontend (React) -> Backend API (FastAPI) -> Prediction Engine -> Result

3. Core Components

A. Frontend (The Face)

  • Technology: React.js / Next.js
  • Function: Takes user PNR, fetches data, and displays it beautifully using components like TicketDisplay.jsx and the RiskMeter (visualizing "Safe/Medium/Risky").

B. Backend (The Brain)

  • Technology: Python (FastAPI)
  • File: backend/main.py
  • Function: The system's control center receiving all frontend requests.

C. The Prediction Engine (The Magic) ✨

The most crucial part. This is not "AI Magic" but a sophisticated Rule-Based System.

Logic File: backend/utils/prediction_engine.py

How it thinks:

  • Quota Check: RLWL? Chances reduce (-15%).
  • Class Check: 1AC? Chances reduce further (-25%).
  • Days Left: 10 days to go? (+15% chance).
  • Route Factor: Business route (e.g., Mumbai-Bangalore)? (+10% chance).
Formula: Base(100) - Penalty + Bonus = Final Probability

D. Route Analyzer

File: backend/utils/route_logic.py

Function: Determines if a train is on a Business route (high cancellation) or Leisure route (low cancellation).

E. Database & Supervisor

  • Database: SQLAlchemy (SQLite/Postgres) saving all PNRs.
  • Audit Script: backend/analyze_predictions.py. After train departure, it verifies if our "Confirm" prediction was correct, updating the Accuracy Score.

4. Data Flow (Step-by-Step)

  1. Step 1: User enters PNR on Frontend.
  2. Step 2: Backend checks live status with IRCTC.
  3. Step 3: PredictionEngine combines factors (Quota, Class, Route) to generate a % Score.
  4. Step 4: Result is sent to the Frontend.
  5. Step 5 (Hidden): Prediction is saved to Database.
  6. Step 6 (Future): Supervisor verifies accuracy after chart preparation.

5. Future Plan

We are currently using heuristics ("Rules"). The future lies in Dynamic Learning.

Meaning: If predictions for a specific train (e.g., 12345) are consistently wrong, the system will automatically adjust its rules (Self-healing).