Carriage Train Monitor is a React application developed by Antonio Baldari to showcase a production-ready front-end architecture. The project simulates live Belgian rail data, allowing users to inspect carriage compositions, accessibility facilities, and passenger occupancy in real time.
- Search for trains by station with debounced filtering and instant feedback.
- Live mocked updates refresh occupancy and service status without reloading the page.
- Detailed carriage layout highlighting accessibility and amenity information.
- Responsive Bootstrap-driven interface with keyboard navigation and ARIA semantics.
- Configurable API layer prepared for swapping the mock service with a production endpoint.
npm installnpm startThe development server runs on http://localhost:3000. Updates from the mocked API stream are simulated every 10 seconds.
- Components – Presentational UI broken down into reusable pieces inside
src/components. - Hooks – Custom hooks in
src/hooksencapsulate debouncing and live data subscriptions. - Utilities – Mock API and shared helpers live in
src/utils, making it simple to replace with a real service. - Assets – Static files such as logos are stored in
src/assets. - Styles – Component-scoped styles and global layout utilities ensure consistent presentation.
SearchBarhandles keyboard-accessible station search and submissions.TrainDisplayorchestrates loading, error, and data states while rendering train cards.TrainHeader,TrainDetails, andCarriageListpresent schedule metadata, live KPIs, and carriage compositions respectively.StatusMessagedelivers reusable alert styling for system feedback.
- React 18 with functional components and hooks.
- Bootstrap-inspired utility classes for layout and spacing consistency.
- Jest and React Testing Library for unit and snapshot testing.
- ESLint and Prettier for code quality enforcement.
npm testThis command runs the Jest test suite with React Testing Library, including snapshot coverage for the primary UI components.
The project is deployment-ready for static hosting providers such as Netlify or Vercel.
- Create a new Netlify site linked to this repository.
- Use the build command
npm run buildand publish thebuilddirectory. - Configure an environment variable
REACT_APP_API_BASE_URLif pointing to a live API.
- Import the repository into Vercel.
- Set the build command to
npm run buildand the output directory tobuild. - Add
REACT_APP_API_BASE_URLunder project Environment Variables when connecting to a production backend.
The mock API layer emits fresh train data every 10 seconds, updating carriage occupancy and service status. The useTrainSearch hook listens to this stream, merges updates with the current filter, and debounces user input to avoid unnecessary requests.
Keyboard navigation, ARIA roles, and semantic HTML ensure the interface is usable with assistive technologies. Layouts adapt to small screens with responsive CSS and Bootstrap utility classes for spacing and alignment.
This project is licensed under the MIT License.