# hariharakrishnanofficial/railway-ticketing-app architecture

> Architecture diagram of the GitHub repository hariharakrishnanofficial/railway-ticketing-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hariharakrishnanofficial/railway-ticketing-app
- Repository: https://github.com/hariharakrishnanofficial/railway-ticketing-app

## Overview

#### Purpose and Runtime

RailAdmin is a React 18/Vite single-page frontend for a railway ticketing backend described as Flask/Zoho-backed. It serves both passenger ticketing flows and administrative operations, with production output committed under `dist/`. The browser app starts at `src/main.jsx`, renders the route/application shell in `src/App.jsx`, and is built/served by Vite (`vite.config.js`).

#### Application Composition and Routing

`src/App.jsx` is the primary route/control boundary, selecting passenger, admin, authentication, reporting, and AI/explorer pages. Route-specific shells separate user experiences:
- Passenger-facing structure: `src/components/PassengerLayout.jsx`, `src/pages/PassengerHome.jsx`, `src/pages/SearchPage.jsx`
- Administrative structure: `src/components/AdminLayout.jsx`, `src/components/AdminMasterLayout.jsx`, `src/pages/AdminDashboard.jsx`
- Shared/general layout: `src/components/Layout.jsx`

Authentication enforcement is centralized in `src/components/RequireAuth.jsx`; sign-in/login UI is provided by `src/components/LoginModal.jsx` and `src/components/SignInModal.jsx`.

#### Backend API Boundary

All browser-to-backend communication should flow through the Axios service layer in `src/services/api.js`, with request lifecycle abstractions in `src/hooks/useApi.js`. The configured API base URL is environment-driven (`.env.example`) and Vite proxies `/api/*` to the local backend in development (`vite.config.js`).

The backend owns railway domain records and transactions: trains, stations, users, bookings, inventory, fares, schedules, PNR/status, cancellations, and administrative/master data. The frontend is a client boundary rather than a backend implementation; `app.py` is present at repository root but the documented primary runtime is the Vite React app.

#### Passenger Booking Flow

Passenger activity begins from the home/search surfaces and moves through train availability, booking history, status, and cancellation views:
- Search and booking initiation: `src/pages/SearchPage.jsx`, `src/pages/PassengerHome.jsx`
- Customer booking management: `src/pages/MyBookings.jsx`, `src/pages/CancelTicket.jsx`
- Ticket/status and availability lookup: `src/pages/PNRStatus.jsx`, `src/pages/ChartVacancy.jsx`

These pages consume API results, maintain local React state, and render user-facing actions through shared UI components rather than owning transport logic.

#### Admin Operations and Master Data

Administrative workflows manage operational entities and ticketing records:
- Dashboard and operational logs: `src/pages/AdminDashboard.jsx`, `src/pages/AdminLogsPage.jsx`
- Core CRUD domains: `src/pages/TrainsPage.jsx`, `src/pages/StationsPage.jsx`, `src/pages/BookingsPage.jsx`
- Railway configuration/master data: `src/pages/admin/MasterDataAdmin.jsx`, `src/pages/admin/TrainRoutesAdmin.jsx`
- Related operational areas: `src/pages/InventoryPage.jsx`, `src/pages/FaresPage.jsx`, `src/pages/ReservationChartPage.jsx`

Reusable table/form primitives (`src/components/CRUDTable.jsx`, `src/components/FormFields.jsx`) standardize list, edit, create, delete, filtering, and confirmation interactions across these domains.

#### Shared State, Feedback, and Resilience

Cross-cutting UI state is provided through React contexts:
- Application settings: `src/context/SettingsContext.jsx`
- Toast notifications: `src/context/ToastContext.jsx`

The common UI/design system resides in `src/components/UI.jsx`, while `src/components/ErrorBoundary.jsx` prevents rendering failures from collapsing the full application. Global styling and visual tokens are defined in `src/styles/global.css`.

#### External/AI Integration Surfaces

The repository includes dedicated interfaces for AI and external-system exploration, indicating backend-mediated integrations rather than direct browser credentials:
- AI chat/test agent: `src/components/AIChatWidget.jsx`, `src/pages/AITestAgent.jsx`
- MCP interaction: `src/pages/MCPChatPage.jsx`
- Zoho data exploration: `src/pages/ZohoExplorerPage.jsx`

These should remain behind the same API/authentication boundary as ticketing and admin operations.

Main entry points: [`src/App.jsx`](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/App.jsx) (App route controller), [`src/services/api.js`](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/services/api.js) (Axios API service), [`src/hooks/useApi.js`](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/hooks/useApi.js) (API lifecycle hook), [`src/main.jsx`](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/main.jsx) (React entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Frontend Runtime"]
  node_vite{{"Vite build &amp; dev server<br/>build runtime<br/>[vite.config.js]"}}
  node_entry["React entry<br/>browser entry<br/>[main.jsx]"]
  node_app["App route controller<br/>routing shell<br/>[App.jsx]"]
  node_auth["Authentication gate<br/>route guard<br/>[RequireAuth.jsx]"]
  node_layouts["Experience layouts<br/>layout shells<br/>[Layout.jsx]"]
  node_state["Settings &amp; toast state<br/>React contexts"]
  node_ui["Shared UI &amp; resilience<br/>UI system<br/>[UI.jsx]"]
  node_api["Axios API service<br/>browser API boundary<br/>[api.js]"]
  node_api_hook["API lifecycle hook<br/>React hook<br/>[useApi.js]"]
end

subgraph group_passenger["Passenger Experience"]
  node_passenger_search["Search &amp; booking start<br/>passenger pages<br/>[SearchPage.jsx]"]
  node_passenger_bookings["Booking management<br/>passenger pages<br/>[MyBookings.jsx]"]
  node_passenger_status["PNR &amp; vacancy lookup<br/>passenger pages<br/>[PNRStatus.jsx]"]
end

subgraph group_admin["Admin Operations"]
  node_admin_dashboard["Dashboard &amp; logs<br/>admin pages<br/>[AdminDashboard.jsx]"]
  node_admin_crud["Railway CRUD<br/>admin pages<br/>[TrainsPage.jsx]"]
  node_admin_master["Master data &amp; routes<br/>admin pages"]
  node_admin_operations["Inventory, fares &amp; charts<br/>admin pages<br/>[InventoryPage.jsx]"]
  node_crud_primitives["CRUD table &amp; forms<br/>reusable admin UI<br/>[CRUDTable.jsx]"]
end

subgraph group_integrations["Integration Surfaces"]
  node_ai_mcp["AI &amp; MCP interfaces<br/>integration pages<br/>[AITestAgent.jsx]"]
  node_zoho_explorer["Zoho explorer<br/>integration page"]
end

node_backend[("Railway backend<br/>Flask/Zoho-backed services")]

node_vite -->|"serves/builds"| node_entry
node_entry -->|"mounts"| node_app
node_app -->|"protects routes with"| node_auth
node_app -->|"selects shells"| node_layouts
node_app -->|"routes to"| node_passenger_search
node_app -->|"routes to"| node_passenger_bookings
node_app -->|"routes to"| node_passenger_status
node_app -->|"routes to"| node_admin_dashboard
node_app -->|"routes to"| node_admin_crud
node_app -->|"routes to"| node_admin_master
node_app -->|"routes to"| node_admin_operations
node_app -->|"routes to"| node_ai_mcp
node_app -->|"routes to"| node_zoho_explorer
node_entry -->|"provides"| node_state
node_layouts -->|"uses"| node_ui
node_admin_crud -->|"uses"| node_crud_primitives
node_passenger_search -->|"loads through"| node_api_hook
node_passenger_bookings -->|"loads through"| node_api_hook
node_admin_crud -->|"loads through"| node_api_hook
node_api_hook -->|"delegates requests"| node_api
node_api -->|"API calls"| node_backend
node_ai_mcp -->|"backend-mediated requests"| node_api
node_zoho_explorer -->|"backend-mediated requests"| node_api
node_auth -.->|"enforces authenticated access"| node_api

click node_vite "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/vite.config.js"
click node_entry "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/main.jsx"
click node_app "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/App.jsx"
click node_auth "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/RequireAuth.jsx"
click node_layouts "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/Layout.jsx"
click node_state "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/context/SettingsContext.jsx"
click node_ui "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/UI.jsx"
click node_passenger_search "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/SearchPage.jsx"
click node_passenger_bookings "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/MyBookings.jsx"
click node_passenger_status "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/PNRStatus.jsx"
click node_admin_dashboard "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/AdminDashboard.jsx"
click node_admin_crud "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/TrainsPage.jsx"
click node_admin_master "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/admin/MasterDataAdmin.jsx"
click node_admin_operations "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/InventoryPage.jsx"
click node_crud_primitives "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/CRUDTable.jsx"
click node_ai_mcp "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/AITestAgent.jsx"
click node_zoho_explorer "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/ZohoExplorerPage.jsx"
click node_api "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/services/api.js"
click node_api_hook "https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/hooks/useApi.js"

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_vite,node_entry,node_app,node_auth,node_layouts,node_state,node_ui,node_api,node_api_hook toneBlue
class node_passenger_search,node_passenger_bookings,node_passenger_status toneAmber
class node_admin_dashboard,node_admin_crud,node_admin_master,node_admin_operations,node_crud_primitives toneMint
class node_ai_mcp,node_zoho_explorer toneRose
class node_backend toneNeutral
```

## Components

### Frontend Runtime

- [Vite build & dev server](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/vite.config.js): build runtime · Builds the SPA and proxies local /api requests. · `vite.config.js`
- [React entry](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/main.jsx): browser entry · `src/main.jsx`
- [App route controller](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/App.jsx): routing shell · Selects passenger, admin, auth, reporting, and integration pages. · `src/App.jsx`
- [Authentication gate](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/RequireAuth.jsx): route guard · `src/components/RequireAuth.jsx`
- [Experience layouts](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/Layout.jsx): layout shells · Provides shared, passenger, and admin page structure. · `src/components/Layout.jsx`
- [Settings & toast state](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/context/SettingsContext.jsx): React contexts · Supplies cross-cutting settings and notifications. · `src/context/SettingsContext.jsx`
- [Shared UI & resilience](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/UI.jsx): UI system · Shared components, global styling, and rendering failure containment. · `src/components/UI.jsx`
- [Axios API service](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/services/api.js): browser API boundary · Centralizes authenticated browser-to-backend requests. · `src/services/api.js`
- [API lifecycle hook](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/hooks/useApi.js): React hook · `src/hooks/useApi.js`

### Passenger Experience

- [Search & booking start](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/SearchPage.jsx): passenger pages · Home and search initiate availability and booking journeys. · `src/pages/SearchPage.jsx`
- [Booking management](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/MyBookings.jsx): passenger pages · Customers view bookings and request cancellations. · `src/pages/MyBookings.jsx`
- [PNR & vacancy lookup](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/PNRStatus.jsx): passenger pages · `src/pages/PNRStatus.jsx`

### Admin Operations

- [Dashboard & logs](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/AdminDashboard.jsx): admin pages · `src/pages/AdminDashboard.jsx`
- [Railway CRUD](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/TrainsPage.jsx): admin pages · Manages trains, stations, and booking records. · `src/pages/TrainsPage.jsx`
- [Master data & routes](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/admin/MasterDataAdmin.jsx): admin pages · `src/pages/admin/MasterDataAdmin.jsx`
- [Inventory, fares & charts](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/InventoryPage.jsx): admin pages · `src/pages/InventoryPage.jsx`
- [CRUD table & forms](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/components/CRUDTable.jsx): reusable admin UI · Standardizes editing, filtering, confirmation, and list workflows. · `src/components/CRUDTable.jsx`

### Integration Surfaces

- [AI & MCP interfaces](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/AITestAgent.jsx): integration pages · AI test and MCP interaction surfaces. · `src/pages/AITestAgent.jsx`
- [Zoho explorer](https://github.com/hariharakrishnanofficial/railway-ticketing-app/blob/master/src/pages/ZohoExplorerPage.jsx): integration page · `src/pages/ZohoExplorerPage.jsx`

### Other components

- **Railway backend**: Flask/Zoho-backed services · Owns railway records, transactions, and external integrations.

## Connections

- Vite build & dev server → React entry: serves/builds
- React entry → App route controller: mounts
- App route controller → Authentication gate: protects routes with
- App route controller → Experience layouts: selects shells
- App route controller → Search & booking start: routes to
- App route controller → Booking management: routes to
- App route controller → PNR & vacancy lookup: routes to
- App route controller → Dashboard & logs: routes to
- App route controller → Railway CRUD: routes to
- App route controller → Master data & routes: routes to
- App route controller → Inventory, fares & charts: routes to
- App route controller → AI & MCP interfaces: routes to
- App route controller → Zoho explorer: routes to
- React entry → Settings & toast state: provides
- Experience layouts → Shared UI & resilience: uses
- Railway CRUD → CRUD table & forms: uses
- Search & booking start → API lifecycle hook: loads through
- Booking management → API lifecycle hook: loads through
- Railway CRUD → API lifecycle hook: loads through
- API lifecycle hook → Axios API service: delegates requests
- Axios API service → Railway backend: API calls
- AI & MCP interfaces → Axios API service: backend-mediated requests
- Zoho explorer → Axios API service: backend-mediated requests
- Authentication gate → Axios API service: enforces authenticated access
