This project consists of a backend Flask API and a React frontend for managing seat reservations in a train coach. The system allows users to book seats with a preference for reserving seats in a single row when possible, and to book nearby seats if a single row cannot accommodate the entire request.
The backend is a Flask application that provides two endpoints:
- GET
/seats
: Retrieves the current seat map of the coach. - POST
/reserve
: Reserves a specified number of seats.
-
Navigate to the
backend
directory:cd backend
-
Install Flask and Flask-CORS:
pip install Flask Flask-CORS
-
Run the Flask application:
python app.py
The frontend is a React application that displays the seat map and allows users to reserve seats. It interacts with the Flask API to fetch the current seat map and to send seat reservation requests.
- SeatMap: Displays the seat map and provides an interface for reserving seats.
-
Navigate to the
frontend
directory:cd frontend
-
Install dependencies:
npm install axios
-
Run the React application:
npm start
- Start the Flask backend and the React frontend.
- Access the React application in your browser (typically at
http://localhost:3000
). - The seat map will be displayed, and you can enter the number of seats to reserve and click "Reserve Seats."