# aneekbiswas/irctc-train-search-and-booking-prototype architecture

> Architecture diagram of the GitHub repository aneekbiswas/irctc-train-search-and-booking-prototype, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aneekbiswas/irctc-train-search-and-booking-prototype
- Repository: https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype

## Overview

1. **Project type**
   - This is a **static, browser-side prototype** for train search and booking, modeled after an IRCTC-style flow.
   - There is no sign of a backend, database, authentication service, or build pipeline in the repo structure.

2. **Entry points**
   - `index.html` is the main landing/search page.
   - `booking/booking.html` is the booking/details page reached after selecting a train or itinerary.
   - The application appears to be split into two screen-level experiences rather than a single SPA route system.

3. **Presentation layer**
   - Styles are separated by page:
     - `styles/indexStyle.css` for the search/home screen
     - `styles/bookingStyle.css` for the booking screen
   - This suggests each page owns its own UI layout and visual behavior rather than sharing a large common stylesheet.

4. **Client-side logic**
   - `script.js` likely drives the search/home page behavior.
   - `booking/booking.js` likely handles the booking page interactions and any passenger/confirmation flow.
   - The architecture is therefore **JavaScript-enhanced static pages**, with logic running entirely in the browser.

5. **Data layer**
   - `data/trains.json` and `data/stations.json` are local JSON datasets used by the UI.
   - These files imply the search experience is backed by **static reference data**, not live API calls.
   - The app likely filters trains by station pairs and uses the station list for lookup/autocomplete or validation.

6. **Primary data flow**
   - User enters search criteria on `index.html`.
   - `script.js` reads station/train data from `data/*.json`, computes candidate trains, and renders results.
   - A selected train then moves the user into `booking/booking.html`, where `booking/booking.js` likely consumes the chosen train context and completes the mock booking flow.

7. **Boundary between pages**
   - The handoff from search to booking is a key architectural boundary.
   - Since there is no server-side session layer visible, state is probably passed through the browser using URL parameters, local storage, or in-memory navigation state.

8. **Functional subsystems**
   - **Search subsystem:** station input, train matching, result rendering.
   - **Booking subsystem:** itinerary display, passenger or booking confirmation interactions.
   - **Reference data subsystem:** station and train catalogs in JSON.
   - **UI styling subsystem:** page-specific CSS files.

9. **External dependencies**
   - No external services are visible in the repository structure.
   - If any libraries are used, they are not evident from the file tree; the architecture should be treated as **self-contained and offline-capable** unless the HTML reveals otherwise.

10. **Likely runtime model**
   - The entire app runs in a standard web browser.
   - There is no evidence of a server, framework runtime, or compiled artifact generation.
   - This makes deployment likely a simple static hosting setup.

11. **Repository organization**
   - Root-level files provide the landing/search experience.
   - The `booking/` directory isolates the booking page assets.
   - The `data/` directory centralizes reusable domain data, keeping train and station definitions separate from UI code.

12. **Architecture diagram implication**
   - A good diagram would show:
     - Browser users interacting with two HTML pages
     - Each page loading its own CSS and JavaScript
     - JavaScript consuming local JSON datasets
     - A page-to-page transition from search to booking
   - The dominant pattern is **static front-end app with local data-driven UI**, not client-server architecture.

Main entry points: [`script.js`](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/script.js) (Search logic), [`index.html`](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/index.html) (Search page), [`booking/booking.html`](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.html) (Booking page), [`booking/booking.js`](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.js) (Booking logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Search page"]
  node_n2["Search page<br/>html entry<br/>[index.html]"]
  node_n3["Search logic<br/>ui script<br/>[script.js]"]
  node_n4["Search styles<br/>css<br/>[indexStyle.css]"]
  node_n11["Search results<br/>view"]
end

subgraph group_g2["Booking page"]
  node_n5["Booking page<br/>html entry<br/>[booking.html]"]
  node_n6["Booking logic<br/>ui script<br/>[booking.js]"]
  node_n7["Booking styles<br/>css<br/>[bookingStyle.css]"]
end

subgraph group_g3["Reference data"]
  node_n8["Stations<br/>json catalog<br/>[stations.json]"]
  node_n9["Trains<br/>json catalog<br/>[trains.json]"]
end

subgraph group_g4["Browser runtime"]
  node_n1(("Browser<br/>runtime"))
  node_n10{{"Static site<br/>deployment"}}
  node_n12["Booking context<br/>state handoff"]
end

node_n1 -->|"opens"| node_n2
node_n2 -->|"drives"| node_n3
node_n2 -->|"styles with"| node_n4
node_n3 -->|"reads"| node_n8
node_n3 -->|"reads"| node_n9
node_n3 -->|"renders"| node_n11
node_n11 -->|"selects"| node_n12
node_n12 -->|"opens"| node_n5
node_n5 -->|"drives"| node_n6
node_n5 -->|"styles with"| node_n7
node_n6 -->|"consumes"| node_n12
node_n6 -->|"updates"| node_n1
node_n10 -->|"hosts"| node_n2
node_n10 -->|"hosts"| node_n5
node_n10 -->|"serves"| node_n8
node_n10 -->|"serves"| node_n9

click node_n2 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/index.html"
click node_n3 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/script.js"
click node_n4 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/styles/indexStyle.css"
click node_n5 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.html"
click node_n6 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.js"
click node_n7 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/styles/bookingStyle.css"
click node_n8 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/data/stations.json"
click node_n9 "https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/data/trains.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n2,node_n3,node_n4,node_n11 toneBlue
class node_n5,node_n6,node_n7 toneAmber
class node_n8,node_n9 toneMint
class node_n1,node_n10,node_n12 toneRose
```

## Components

### Search page

Landing and train search experience.

- [Search page](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/index.html): html entry · Main landing page for searching trains. · `index.html`
- [Search logic](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/script.js): ui script · Client-side behavior for station input, filtering, and results rendering. · `script.js`
- [Search styles](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/styles/indexStyle.css): css · Visual styling for the search/home screen. · `styles/indexStyle.css`
- **Search results**: view · Computed list of candidate trains produced by the search experience.

### Booking page

Passenger and booking flow after selection.

- [Booking page](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.html): html entry · Booking/details page reached after selecting a train. · `booking/booking.html`
- [Booking logic](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/booking/booking.js): ui script · Client-side booking interactions and confirmation flow. · `booking/booking.js`
- [Booking styles](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/styles/bookingStyle.css): css · Visual styling for the booking screen. · `styles/bookingStyle.css`

### Reference data

Static JSON catalogs used by the UI.

- [Stations](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/data/stations.json): json catalog · Station reference data for lookup, validation, or autocomplete. · `data/stations.json`
- [Trains](https://github.com/aneekbiswas/irctc-train-search-and-booking-prototype/blob/main/data/trains.json): json catalog · Train reference data used to match routes and render results. · `data/trains.json`

### Browser runtime

Client-side execution in a static web browser.

- **Browser**: runtime · End user runs the prototype in a standard web browser.
- **Static site**: deployment · Self-contained static front-end prototype with no visible backend.
- **Booking context**: state handoff · Selected itinerary state passed from search to booking, likely via URL or browser storage.

## Connections

- Browser → Search page: opens · User starts at the search page.
- Search page → Search logic: drives · The page loads its browser-side search behavior.
- Search page → Search styles: styles with · Search page uses its dedicated stylesheet.
- Search logic → Stations: reads · Search logic uses station reference data.
- Search logic → Trains: reads · Search logic uses train reference data.
- Search logic → Search results: renders · Search logic computes and displays matching trains.
- Search results → Booking context: selects · Choosing a train creates handoff state for booking.
- Booking context → Booking page: opens · Selected itinerary is carried into the booking page.
- Booking page → Booking logic: drives · The booking page loads its browser-side logic.
- Booking page → Booking styles: styles with · Booking page uses its dedicated stylesheet.
- Booking logic → Booking context: consumes · Booking logic consumes the selected itinerary context.
- Booking logic → Browser: updates · All interaction stays within the browser runtime.
- Static site → Search page: hosts · Static hosting serves the HTML entry pages.
- Static site → Booking page: hosts · Static hosting serves the booking page.
- Static site → Stations: serves · Static hosting makes local data files available to scripts.
- Static site → Trains: serves · Static hosting makes local data files available to scripts.
