How hariharakrishnanofficial/railway-ticketing-app works
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: App.jsx App route controller · api.js Axios API service · useApi.js API lifecycle hook · main.jsx React entry
Components 20
Frontend Runtime
- Vite build & dev server · Builds the SPA and proxies local /api requests.
vite.config.js - React entry
src/main.jsx - App route controller · Selects passenger, admin, auth, reporting, and integration pages.
src/App.jsx - Authentication gate
src/components/RequireAuth.jsx - Experience layouts · Provides shared, passenger, and admin page structure.
src/components/Layout.jsx - Settings & toast state · Supplies cross-cutting settings and notifications.
src/context/SettingsContext.jsx - Shared UI & resilience · Shared components, global styling, and rendering failure containment.
src/components/UI.jsx - Axios API service · Centralizes authenticated browser-to-backend requests.
src/services/api.js - API lifecycle hook
src/hooks/useApi.js
Passenger Experience
- Search & booking start · Home and search initiate availability and booking journeys.
src/pages/SearchPage.jsx - Booking management · Customers view bookings and request cancellations.
src/pages/MyBookings.jsx - PNR & vacancy lookup
src/pages/PNRStatus.jsx
Admin Operations
- Dashboard & logs
src/pages/AdminDashboard.jsx - Railway CRUD · Manages trains, stations, and booking records.
src/pages/TrainsPage.jsx - Master data & routes
src/pages/admin/MasterDataAdmin.jsx - Inventory, fares & charts
src/pages/InventoryPage.jsx - CRUD table & forms · Standardizes editing, filtering, confirmation, and list workflows.
src/components/CRUDTable.jsx
Integration Surfaces
- AI & MCP interfaces · AI test and MCP interaction surfaces.
src/pages/AITestAgent.jsx - Zoho explorer
src/pages/ZohoExplorerPage.jsx
Other components
- Railway backend · Owns railway records, transactions, and external integrations.
Connections 24
- 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