Skip to content

Ashish-Ramrakhiani/TicketBookingSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Train Ticket Booking System

A comprehensive console-based train ticket booking application built with Java, demonstrating clean architecture, secure authentication, and efficient data management.

Project Overview

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.

Key Features

User Management

  • 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

Train Operations

  • 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)

Booking Management

  • 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

Data Persistence

  • 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

Technical Architecture

Clean Architecture Implementation

src/main/java/ticket/booking/
├── entities/          # Data models (User, Train, Ticket)
├── services/          # Business logic layer
├── utils/            # Utility functions and helpers
└── localDb/          # JSON data storage

Technology Stack

  • 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

Technical Highlights

Security Best Practices

  • Password Hashing: Uses BCrypt with salt for secure password storage
  • Input Sanitization: Prevents malformed input and injection attacks
  • Session Management: Proper user authentication flow

Modern Java Features

  • Stream API: Functional programming for data filtering and processing
  • Optional: Null-safe operations throughout the codebase
  • Lambda Expressions: Clean, readable code with functional interfaces

Design Patterns & Principles

  • 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

Getting Started

Prerequisites

  • Java 21 or higher
  • Gradle (included via wrapper)

Installation & Running

# Clone the repository
git clone <repository-url>
cd TicketBookingSystem

# Run the application
./gradlew run

# Run tests
./gradlew test

Usage Example

Welcome 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

Sample Data Structure

Train Data

{
  "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"]
}

User Data

{
  "username": "john_doe",
  "user_id": "uuid-string",
  "hashed_password": "$2a$10$...",
  "tickets_booked": [...]
}

Key Learning Outcomes

Software Engineering Skills

  • 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

Java Ecosystem Proficiency

  • 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

Problem-Solving Approach

  • 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

Code Quality Features

  • 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

Professional Development Highlights

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

Future Enhancements

  • 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

About

Console-based train booking system demonstrating enterprise-grade software engineering practices. Features BCrypt authentication, clean architecture with service layers, intelligent search algorithms, and atomic transaction management with JSON persistence.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages