A comprehensive console-based train ticket booking application built with Java, demonstrating clean architecture, secure authentication, and efficient data management.
This project showcases a full-featured ticket booking system that allows users to search trains, book seats, manage bookings, and handle user authentication. Built with modern Java practices and enterprise-grade libraries, it demonstrates real-world software development skills.
- Secure Registration & Authentication: BCrypt password hashing with salt
- User Session Management: Persistent login state during application runtime
- Input Validation: Username format validation and duplicate prevention
- Intelligent Train Search: Filter trains by source and destination with route validation
- Real-time Seat Management: Visual seat map with live availability updates
- Route Validation: Ensures logical travel paths (source before destination)
- Interactive Seat Selection: Row/column-based seat booking with visual feedback
- Booking History: View all user bookings with detailed information
- Cancellation System: Remove bookings with automatic seat release
- JSON-based Storage: Lightweight file-based database using Jackson
- Atomic Operations: Consistent data updates across user and train records
- Auto-save Functionality: Automatic persistence after each transaction
src/main/java/ticket/booking/
├── entities/ # Data models (User, Train, Ticket)
├── services/ # Business logic layer
├── utils/ # Utility functions and helpers
└── localDb/ # JSON data storage
- Java 21: Latest LTS version with modern language features
- Gradle: Build automation and dependency management
- Jackson: High-performance JSON processing
- BCrypt: Industry-standard password hashing
- JUnit: Testing framework for quality assurance
- Password Hashing: Uses BCrypt with salt for secure password storage
- Input Sanitization: Prevents malformed input and injection attacks
- Session Management: Proper user authentication flow
- Stream API: Functional programming for data filtering and processing
- Optional: Null-safe operations throughout the codebase
- Lambda Expressions: Clean, readable code with functional interfaces
- Service Layer Pattern: Clear separation between business logic and presentation
- Repository Pattern: Abstracted data access through service classes
- Single Responsibility: Each class has a focused, well-defined purpose
- Dependency Injection: Constructor-based dependency management
- Java 21 or higher
- Gradle (included via wrapper)
# Clone the repository
git clone <repository-url>
cd TicketBookingSystem
# Run the application
./gradlew run
# Run tests
./gradlew testWelcome to my Ticket Booking System!
Choose option:
1. Sign up
2. Login
3. Fetch Bookings
4. Search Trains
5. Book a Seat
6. Cancel my Booking
7. Exit the App
{
"train_id": "T123",
"train_no": "12345",
"seats": [[1,1,0,0,0], [0,0,0,0,0]],
"station_times": {
"kandivali": "08:00 AM",
"borivali": "09:00 AM"
},
"stations": ["kandivali", "borivali", "goregaon"]
}{
"username": "john_doe",
"user_id": "uuid-string",
"hashed_password": "$2a$10$...",
"tickets_booked": [...]
}- Clean Code: Readable, maintainable code with proper naming conventions
- Error Handling: Comprehensive exception management and user feedback
- Data Validation: Input sanitization and business rule enforcement
- Testing: Unit test structure for quality assurance
- Build Tools: Gradle configuration and dependency management
- External Libraries: Integration with Jackson, BCrypt, and testing frameworks
- File I/O: Efficient JSON serialization and file system operations
- Collections Framework: Advanced usage of Lists, Maps, and Streams
- Algorithm Design: Efficient search and filtering algorithms
- Data Structure Selection: Appropriate use of collections for different use cases
- State Management: Consistent application state across operations
- User Experience: Intuitive CLI interface with clear feedback
- Consistent Formatting: Professional code style throughout
- Comprehensive Comments: Clear documentation for complex logic
- Modular Design: Reusable components and clear interfaces
- Error Recovery: Graceful handling of edge cases and failures
This project demonstrates:
- Full-Stack Thinking: Understanding of data flow from storage to presentation
- Security Awareness: Implementation of authentication and data protection
- Scalable Architecture: Foundation that could easily extend to web/API layers
- Production Readiness: Error handling, validation, and data persistence
- REST API implementation for web/mobile clients
- Database integration (PostgreSQL/MySQL)
- Advanced booking features (seat preferences, multi-leg journeys)
- Payment processing integration
- Admin panel for train management
- Microservices architecture adoption
Skills Demonstrated: Java, OOP, Clean Architecture, Security, JSON Processing, Build Tools, Testing, Problem Solving, Software Design Patterns