A comprehensive desktop application for train ticket booking and management, built with Java and Swing. This system provides a complete railway reservation experience with secure user authentication, interactive seat selection, and efficient booking management.
- Features
- Technology Stack
- Architecture
- Installation
- Usage
- Project Structure
- Security Features
- Screenshots
- Future Enhancements
- Contributing
- License
- Secure Registration: New user registration with input validation
- Encrypted Login: Password hashing using BCrypt for enhanced security
- Session Management: Maintains user state throughout the application
- Smart Search: Find trains by source, destination, and travel date
- Interactive Seat Selection: Visual seat map with real-time availability
- Instant Booking: Quick and efficient ticket booking process
- Seat Availability: Real-time checking to prevent double bookings
- View Bookings: Comprehensive list of all user bookings
- Booking Details: Detailed information for each reservation
- Cancellation: Easy booking cancellation with confirmation dialogs
- Booking History: Complete transaction history tracking
- Modern Design: Clean, intuitive interface with custom styling
- Responsive Layout: Optimized for different screen sizes
- Form Validation: Real-time input validation and error handling
- Interactive Components: Dynamic tables, dialogs, and buttons
| Component | Technology |
|---|---|
| Language | Java 17 |
| UI Framework | Java Swing (Custom Styling) |
| Build Tool | Gradle |
| Database | JSON with Jackson |
| Security | BCrypt Password Hashing |
| Libraries | Jackson, BCrypt, JavaTimeModule |
The application follows MVC (Model-View-Controller) architecture with additional design patterns:
- Model: Entity classes (
User,Train,Booking) - View: GUI panels and components (Swing-based)
- Controller: Service classes handling business logic
- Repository Pattern:
DatabaseManagerfor data access abstraction - Singleton Pattern: Database and theme management
- Service Layer Pattern: Encapsulated business logic
- Java 17 or higher
- Gradle 7.0+
-
Clone the repository
git clone https://github.com/yourusername/train-booking-system.git cd train-booking-system -
Build the project
./gradlew build
-
Run the application
./gradlew run
-
Launch the Application
- Run the main class to start the GUI application
-
Register/Login
- New users: Click "Register" and fill in your details
- Existing users: Enter your credentials to login
-
Search Trains
- Select source and destination cities
- Choose your travel date
- Browse available trains
-
Book Tickets
- Select your preferred train
- Choose seats from the interactive seat map
- Confirm your booking
-
Manage Bookings
- View all your bookings in the "My Bookings" section
- Cancel bookings if needed
src/
βββ main/
β βββ java/
β βββ models/ # Entity classes
β β βββ User.java
β β βββ Train.java
β β βββ Booking.java
β βββ services/ # Business logic
β β βββ UserService.java
β β βββ TrainService.java
β β βββ BookingService.java
β βββ views/ # GUI panels
β β βββ LoginPanel.java
β β βββ SearchPanel.java
β β βββ BookingPanel.java
β βββ database/ # Data persistence
β β βββ DatabaseManager.java
β βββ utils/ # Utility classes
β βββ SecurityUtils.java
βββ resources/
βββ data/ # JSON data files
βββ users.json
βββ trains.json
βββ bookings.json
- Password Encryption: BCrypt hashing with salt for secure password storage
- Input Validation: Comprehensive validation to prevent injection attacks
- Session Security: Secure session management throughout the application
- Error Handling: Robust error handling to prevent information leakage
| Login Screen | Registration Screen |
|---|---|
![]() |
![]() |
| Main Dashboard | Booking Statistics |
|---|---|
![]() |
![]() |
| Search Interface | Train Results | Seat Selection |
|---|---|---|
![]() |
![]() |
![]() |
| Confirmation Dialog |
|---|
![]() |
- Clean, Modern Interface: Professional blue gradient theme with intuitive navigation
- Interactive Dashboard: Real-time statistics showing active bookings, available trains, and popular destinations
- Advanced Search: Easy-to-use search form with popular routes for quick selection
- Visual Seat Map: Color-coded seat selection with real-time availability (Green: Available, Red: Booked, Blue: Selected)
- Data Visualization: Route popularity charts and booking analytics
- Responsive Design: Well-organized layout that works across different screen sizes
- User-Friendly Dialogs: Clear confirmation messages and smooth user experience
- Database Migration: Migrate to MySQL/PostgreSQL for better scalability
- Payment Integration: Add payment gateway for online transactions
- Notification System: Email/SMS notifications for booking confirmations
- Reporting Module: Generate booking statistics and reports
- Mobile App: Develop companion mobile application
- Multi-language Support: Support for regional languages
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Aaryan Soni
- GitHub: @aaryann20
- LinkedIn: LinkedIn
- Email: soniaaryan2020@gmail.com
- Thanks to the Java Swing community for UI inspiration
- BCrypt library for secure password hashing
- Jackson library for JSON processing
β Star this repository if you found it helpful!







