Skip to content

Train-WebApp is a full-stack web application for managing train seat reservations across three car classes (first, second and economy). Users can browse seat availability, authenticate (with optional 2-factor TOTP) and make or cancel bookings. The server exposes REST endpoints for authentication, seat maps, reservations and uses a relational schema

Notifications You must be signed in to change notification settings

sroman0/Train-WebApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Train Reservation System

A web application for managing train seat reservations with three car classes (first, second, economy) and user authentication with optional 2FA.

1. Server-side

HTTP APIs offered by the server

  • POST /api/sessions: Login endpoint - Parameters: {username, password} - Returns: User object with authentication status
  • POST /api/login-totp: 2FA TOTP verification - Parameters: {totpCode} - Returns: Complete authentication with 2FA
  • GET /api/sessions/current: Get current user session - Parameters: none (uses session cookies) - Returns: Current user info or 401
  • DELETE /api/sessions/current: Logout endpoint - Parameters: none - Returns: Logout confirmation
  • GET /api/seats/:carClass: Get seat map for a car class - Parameters: carClass (first|second|economy) - Returns: Seats array and statistics
  • GET /api/reservations: Get user's reservations - Parameters: none (requires auth) - Returns: Array of user reservations with seats
  • POST /api/reservations: Create new reservation - Parameters: {seatIds: [array]} - Returns: New reservation object
  • DELETE /api/reservations/:id: Delete reservation - Parameters: reservation id in URL - Returns: Deletion confirmation

Database tables

  • users: User accounts (id, username, name, hash, salt, otp_secret)
  • seats: Train seats (id, car_class, row_number, seat_number, seat_code, is_occupied)
  • reservations: Reservation records (id, user_id, timestamp)
  • reservation_seats: Links reservations to seats (reservation_id, seat_id)

2. Client-side

React application routes

  • / (MainSeatView): Main page showing seat availability for each car class without authentication required
  • /login: Login page with username/password and optional 2FA TOTP verification
  • /reservations: Authenticated page for managing user reservations with seat selection and booking

Main React components

  • App: Main application component handling routing, authentication state, and global notifications
  • LoginForm: Login interface supporting both standard and 2FA authentication methods
  • MainSeatView: Public seat availability view with car class selection and real-time seat status
  • SeatSelectionView: Authenticated reservation management with interactive seat maps and booking functionality

3. Overall

Screenshot

Login page

Login Page

Totp page

Totp Page

Seat View page

Seat View Page

Seat Reservation page

Seat Reservation Page

404 page

404 Page

Usernames and passwords

Regular Users (All can optionally use 2FA)

  • Username: mario | Password: password - Regular user with two reservations in first class
  • Username: lucia | Password: password - Regular user with reservations in second and economy classes
  • Username: giovanni | Password: password - Regular user with one reservation in each class (first, second, economy)
  • Username: anna | Password: password - Regular user with no reservations

Note: All users can choose to enable 2FA for enhanced security or skip it for standard access. TOTP secret: LXBSMDTMSP2I5XFXIYRGFVWSFI.

About

Train-WebApp is a full-stack web application for managing train seat reservations across three car classes (first, second and economy). Users can browse seat availability, authenticate (with optional 2-factor TOTP) and make or cancel bookings. The server exposes REST endpoints for authentication, seat maps, reservations and uses a relational schema

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published