Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
"# Online-Bus-Booking-Platform"
# Online-Bus-Booking-Platform

## Prerequisites
- **Java 21 JDK** installed (javac and java in PATH)
- **JavaFX SDK** bundled at `lib/javafx-sdk-21.0.6`
- **MySQL Connector/J** at `lib/mysql-connector-j-9.2.0/mysql-connector-j-9.2.0.jar`
- **jbcrypt** at `lib/jbcrypt-0.4.jar`
- A running **MySQL** server with a database named `bus_booking`

## Setup
1. Update database credentials in `src/database/DatabaseConnection.java` if needed.
2. Import schema and seed data if you have any SQL: `bus_booking.sql`.

## Build
```bash
./compile.sh
```

## Run
```bash
./run.sh
```

The app starts at the login screen (`views/login.fxml`).

## Notes
- If you are on Wayland or a headless server, JavaFX may require additional flags or a virtual display.
- To change window size, edit `src/Main.java`.
32 changes: 32 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

# Directories
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
SRC_DIR="$ROOT_DIR/src"
OUT_DIR="$ROOT_DIR/out"
JFX_LIB_DIR="$ROOT_DIR/lib/javafx-sdk-21.0.6/lib"
MYSQL_JAR="$ROOT_DIR/lib/mysql-connector-j-9.2.0/mysql-connector-j-9.2.0.jar"
JBCRYPT_JAR="$ROOT_DIR/lib/jbcrypt-0.4.jar"

mkdir -p "$OUT_DIR"

# Compile
javac \
--class-path "$MYSQL_JAR:$JBCRYPT_JAR" \
--module-path "$JFX_LIB_DIR" \
--add-modules javafx.controls,javafx.fxml \
-d "$OUT_DIR" \
$(find "$SRC_DIR" -name "*.java")

# Copy non-Java resources (FXML, images, styles) preserving relative paths (no rsync)
(
cd "$SRC_DIR"
find . -type f \( -name "*.fxml" -o -name "*.css" -o -name "*.png" -o -name "*.jpg" -o -name "*.jpeg" -o -name "*.gif" \) | while IFS= read -r rel; do
dest_dir="$OUT_DIR/$(dirname "$rel")"
mkdir -p "$dest_dir"
cp "$rel" "$dest_dir/"
done
)

echo "Compilation successful. Classes in $OUT_DIR"
Binary file added out/Main.class
Binary file not shown.
Binary file added out/controllers/AddBusController$1.class
Binary file not shown.
Binary file added out/controllers/AddBusController$2.class
Binary file not shown.
Binary file added out/controllers/AddBusController$3.class
Binary file not shown.
Binary file added out/controllers/AddBusController$4.class
Binary file not shown.
Binary file added out/controllers/AddBusController$5.class
Binary file not shown.
Binary file added out/controllers/AddBusController.class
Binary file not shown.
Binary file added out/controllers/AddScheduleController$1.class
Binary file not shown.
Binary file added out/controllers/AddScheduleController$2.class
Binary file not shown.
Binary file added out/controllers/AddScheduleController.class
Binary file not shown.
Binary file added out/controllers/AdminController.class
Binary file not shown.
Binary file added out/controllers/LoginController.class
Binary file not shown.
Binary file added out/controllers/PaymentController.class
Binary file not shown.
Binary file added out/controllers/RegisterController.class
Binary file not shown.
Binary file added out/controllers/UserBookingController.class
Binary file not shown.
Binary file added out/controllers/UserController.class
Binary file not shown.
Binary file added out/database/DatabaseConnection.class
Binary file not shown.
Binary file added out/models/Bus.class
Binary file not shown.
Binary file added out/models/BusSchedule.class
Binary file not shown.
50 changes: 50 additions & 0 deletions out/views/addBus.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="controllers.AddBusController" prefWidth="1000" prefHeight="600">
<children>
<HBox spacing="50" layoutX="30" layoutY="30" alignment="CENTER_LEFT">
<!-- VBox for input form -->
<VBox alignment="CENTER" spacing="15" prefWidth="250" prefHeight="500"
style="-fx-background-color: #f8f8f8; -fx-padding: 20; -fx-border-color: #ccc; -fx-border-radius: 10; -fx-background-radius: 10;">

<Label text="Add New Bus" style="-fx-font-size: 20px; -fx-font-weight: bold;" />

<TextField fx:id="busNameField" promptText="Bus Name" prefWidth="200"/>
<TextField fx:id="sourceField" promptText="Source" prefWidth="200"/>
<TextField fx:id="destinationField" promptText="Destination" prefWidth="200"/>
<TextField fx:id="timeField" promptText="Time" prefWidth="200"/>
<TextField fx:id="seatsField" promptText="Seats" prefWidth="200"/>
<TextField fx:id="priceField" promptText="Price" prefWidth="200"/>
<TextField fx:id="dateField" promptText="Date" prefWidth="200"/>

<Button text="Add Bus" onAction="#handleAddBus" prefWidth="200"
style="-fx-background-color: #4CAF50; -fx-text-fill: white;">
<tooltip><Tooltip text="Add this bus route"/></tooltip>
</Button>

<Button text="Back to Dashboard" onAction="#handleBack" prefWidth="200"
style="-fx-background-color: #2196F3; -fx-text-fill: white;">
<tooltip><Tooltip text="Return to admin dashboard"/></tooltip>
</Button>
</VBox>

<!-- TableView on the right -->
<TableView fx:id="busTable" prefWidth="740" prefHeight="500" editable="true"
style="-fx-border-color: #ccc; -fx-border-radius: 5; -fx-padding: 10; -fx-background-color: #ffffff;">
<columns>
<TableColumn fx:id="idCol" text="Bus ID" prefWidth="50"/>
<TableColumn fx:id="nameCol" text="Bus Name" prefWidth="150"/>
<TableColumn fx:id="sourceCol" text="Source" prefWidth="100"/>
<TableColumn fx:id="destCol" text="Destination" prefWidth="100"/>
<TableColumn fx:id="timeCol" text="Departure Time" prefWidth="150"/>
<TableColumn fx:id="seatsCol" text="Seats" prefWidth="80"/>
<TableColumn fx:id="priceCol" text="Price" prefWidth="80"/>
<TableColumn fx:id="editCol" text="Edit" prefWidth="80"/>
</columns>
</TableView>
</HBox>
</children>
</AnchorPane>
71 changes: 71 additions & 0 deletions out/views/addSchedule.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="controllers.AddScheduleController"
prefWidth="1600" prefHeight="800">
<children>
<HBox spacing="50" layoutX="30" layoutY="30" alignment="CENTER_LEFT">
<!-- Left Form Section -->
<VBox alignment="CENTER" spacing="15" prefWidth="300" prefHeight="500"
style="-fx-background-color: #f8f8f8; -fx-padding: 20; -fx-border-color: #ccc; -fx-border-radius: 10; -fx-background-radius: 10;">

<Label text="Add New Schedule" style="-fx-font-size: 20px; -fx-font-weight: bold;"/>

<GridPane hgap="10" vgap="10">
<Label text="Bus ID:" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<TextField fx:id="busIdField" promptText="Bus ID" GridPane.columnIndex="1" GridPane.rowIndex="0" prefWidth="200"/>

<Label text="Bus Name:" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="busNameField" editable="false" GridPane.columnIndex="1" GridPane.rowIndex="1" prefWidth="200"/>

<Label text="Travel Date:" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<DatePicker fx:id="travelDatePicker" GridPane.columnIndex="1" GridPane.rowIndex="2" prefWidth="200"/>

<Label text="Travel Time:" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<TextField fx:id="travelTimeField" promptText="HH:mm" GridPane.columnIndex="1" GridPane.rowIndex="3" prefWidth="200"/>

<Label text="Source:" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
<TextField fx:id="sourceField" GridPane.columnIndex="1" GridPane.rowIndex="4" prefWidth="200"/>

<Label text="Destination:" GridPane.columnIndex="0" GridPane.rowIndex="5"/>
<TextField fx:id="destinationField" GridPane.columnIndex="1" GridPane.rowIndex="5" prefWidth="200"/>

<Label text="Price:" GridPane.columnIndex="0" GridPane.rowIndex="6"/>
<TextField fx:id="priceField" GridPane.columnIndex="1" GridPane.rowIndex="6" prefWidth="200"/>

<Label text="Available Seats:" GridPane.columnIndex="0" GridPane.rowIndex="7"/>
<TextField fx:id="availableSeatsField" GridPane.columnIndex="1" GridPane.rowIndex="7" prefWidth="200"/>
</GridPane>

<Button text="Add Schedule" onAction="#handleAddSchedule" prefWidth="200"
style="-fx-background-color: #4CAF50; -fx-text-fill: white;">
<tooltip><Tooltip text="Add new schedule"/></tooltip>
</Button>

<Button text="Back to Dashboard" onAction="#handleBack" prefWidth="200"
style="-fx-background-color: #2196F3; -fx-text-fill: white;">
<tooltip><Tooltip text="Return to admin dashboard"/></tooltip>
</Button>
</VBox>

<!-- Right Table Section -->
<TableView fx:id="scheduleTable" prefWidth="1050" prefHeight="500" editable="true"
style="-fx-border-color: #ccc; -fx-border-radius: 5; -fx-padding: 10; -fx-background-color: #ffffff;">
<columns>
<TableColumn fx:id="scheduleIdCol" text="Schedule ID" prefWidth="100"/>
<TableColumn fx:id="busIdCol" text="Bus ID" prefWidth="80"/>
<TableColumn fx:id="busNameCol" text="Bus Name" prefWidth="150"/>
<TableColumn fx:id="dateCol" text="Travel Date" prefWidth="120"/>
<TableColumn fx:id="timeCol" text="Travel Time" prefWidth="120"/>
<TableColumn fx:id="sourceCol" text="Source" prefWidth="120"/>
<TableColumn fx:id="destinationCol" text="Destination" prefWidth="120"/>
<TableColumn fx:id="priceCol" text="Price" prefWidth="100"/>
<TableColumn fx:id="availableSeatsCol" text="Seats" prefWidth="80"/>
</columns>
</TableView>
</HBox>
</children>
</AnchorPane>
81 changes: 81 additions & 0 deletions out/views/adminDashboard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.*?>
<?import javafx.scene.control.*?>
<?import javafx.geometry.Insets?>

<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="controllers.AdminController" prefWidth="1000" prefHeight="600">
<children>
<HBox spacing="40" layoutX="20" layoutY="20" alignment="TOP_LEFT">
<!-- Sidebar with admin actions -->
<VBox alignment="CENTER" spacing="15" prefWidth="250" prefHeight="560" style="-fx-background-color: #f0f2f5; -fx-padding: 20; -fx-border-color: #dcdcdc; -fx-border-radius: 8; -fx-background-radius: 8;">
<Label text="Admin Panel" style="-fx-font-size: 22px; -fx-font-weight: bold; -fx-text-fill: #333;" />

<Button text="Add Bus" onAction="#handleAddBus" prefWidth="180">
<tooltip>
<Tooltip text="Add new bus details" />
</tooltip>
</Button>

<Button text="Delete Bus" onAction="#handleDeleteBus" prefWidth="180">
<tooltip>
<Tooltip text="Delete selected bus" />
</tooltip>
</Button>

<Button text="Add Schedule" onAction="#handleAddSchedule" prefWidth="180">
<tooltip>
<Tooltip text="Add travel schedule for a bus" />
</tooltip>
</Button>

<Button text="Delete Schedule" onAction="#handleDeleteSchedule" prefWidth="180">
<tooltip>
<Tooltip text="Delete schedule for selected bus" />
</tooltip>
</Button>

<Separator prefWidth="180" />

<Button text="Refresh Bus List" onAction="#handleRefreshBusList" prefWidth="180" style="-fx-background-color: #28a745; -fx-text-fill: white;">
<tooltip>
<Tooltip text="Reload all bus records" />
</tooltip>
</Button>

<Separator prefWidth="180" />

<Button text="Logout" onAction="#handleLogout" prefWidth="180" style="-fx-background-color: #dc3545; -fx-text-fill: white;">
<tooltip>
<Tooltip text="Logout from Admin Panel" />
</tooltip>
</Button>
</VBox>

<!-- Main content area -->
<VBox spacing="15" prefWidth="820" prefHeight="560">
<HBox spacing="10" alignment="CENTER_LEFT">
<Label text="Filter Schedules:" style="-fx-font-size: 14px; -fx-font-weight: bold;" />
<ComboBox fx:id="dateFilterCombo" prefWidth="160" promptText="Select Filter">
<tooltip>
<Tooltip text="Choose to filter by Today, Tomorrow, or Onward" />
</tooltip>
</ComboBox>
</HBox>

<TableView fx:id="busTable" prefWidth="820" prefHeight="500" style="-fx-border-color: #ccc; -fx-border-radius: 5; -fx-padding: 10; -fx-background-color: #ffffff;">
<columns>
<TableColumn fx:id="idCol" text="Bus ID" prefWidth="50" />
<TableColumn fx:id="nameCol" text="Bus Name" prefWidth="150" />
<TableColumn fx:id="sourceCol" text="Source" prefWidth="120" />
<TableColumn fx:id="destCol" text="Destination" prefWidth="120" />
<TableColumn fx:id="timeCol" text="Departure Time" prefWidth="120" />
<TableColumn fx:id="seatsCol" text="Seats" prefWidth="70" />
<TableColumn fx:id="priceCol" text="Price (₹)" prefWidth="80" />
<TableColumn fx:id="dateCol" text="Travel Date" prefWidth="120" />
</columns>
</TableView>
</VBox>
</HBox>
</children>
</AnchorPane>
43 changes: 43 additions & 0 deletions out/views/login.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>

<StackPane stylesheets="@../styles/login.css" xmlns="http://javafx.com/javafx/21"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="controllers.LoginController">
<!-- Login Card -->
<VBox styleClass="login-card" alignment="CENTER" spacing="25">
<!-- Logo -->
<ImageView fitWidth="80" fitHeight="80" preserveRatio="true">
<Image url="@../images/bus-logo.png" />
</ImageView>

<!-- Title -->
<Label text="Welcome Back" styleClass="login-title"/>
<Label text="Sign in to continue" styleClass="login-subtitle"/>

<!-- Form -->
<VBox spacing="15" alignment="CENTER" styleClass="form-container">
<TextField fx:id="usernameField" styleClass="auth-input" promptText="Email or Username">
<padding><Insets left="15"/></padding>
</TextField>

<PasswordField fx:id="passwordField" styleClass="auth-input" promptText="Password">
<padding><Insets left="15"/></padding>
</PasswordField>

<Button text="LOGIN" styleClass="auth-button" onAction="#handleLogin" />

<!-- Footer Links -->
<HBox spacing="10" alignment="CENTER">
<Hyperlink text="Forgot Password?" styleClass="auth-link" />
<Label text="•" styleClass="separator"/>
<Hyperlink text="Create Account" styleClass="auth-link" onAction="#goToRegister"/>
</HBox>
</VBox>
</VBox>
</StackPane>
Loading