Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blackbossx/busticketgeneratingsystem
This is our second semester project .
https://github.com/blackbossx/busticketgeneratingsystem
google-maps-api googledistancematrixapi java maven maven-repository mysql mysql-database qrcode-generator ticketgeneration ticketing-system
Last synced: 4 days ago
JSON representation
This is our second semester project .
- Host: GitHub
- URL: https://github.com/blackbossx/busticketgeneratingsystem
- Owner: BlackBossX
- Created: 2024-12-26T16:27:14.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-01-22T07:31:05.000Z (9 days ago)
- Last Synced: 2025-01-22T08:27:51.525Z (9 days ago)
- Topics: google-maps-api, googledistancematrixapi, java, maven, maven-repository, mysql, mysql-database, qrcode-generator, ticketgeneration, ticketing-system
- Language: Java
- Homepage:
- Size: 168 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# QR Bus Ticket Generating System
π Welcome to the **QR Bus Ticket Generating System**! This project streamlines bus ticket booking with modern technologies like Google Cloud APIs and QR codes.
---
## π Features
1. **π Secure User Management**
- User sign-up and login with bcrypt for password hashing.
- Unique User IDs generated via database triggers.2. **π Location-Based Ticketing**
- Calculates distance and travel duration using Google Cloud Distance Matrix API.
- Dynamic fare calculation based on distance.3. **ποΈ QR Code Tickets**
- QR codes generated for tickets using the [goqr.me API](https://goqr.me/api/).
- Tickets can be scanned for validation.4. **πΎ Database Management**
- MySQL database to store user and trip information.
- Automated ID generation for users and trips using SQL triggers.5. **π οΈ Modular and Scalable**
- Built with Maven for dependency management.
- Organized into clear, reusable components.---
## π οΈ Technologies Used
- **Java**
- **Maven**
- **Google Cloud Distance Matrix API**
- **[goqr.me API](https://goqr.me/api/)**
- **bcrypt**
- **MySQL**---
## βοΈ Setup Instructions
1. Clone the repository and navigate to the project directory.
2. Set up a MySQL database and execute the provided schema and triggers.
3. Configure API keys for:
- Google Cloud Distance Matrix API.
- [goqr.me API](https://goqr.me/api/).4. Configure the **.env** file
- _**GOOGLE_MAPS_API_KEY**_
- _**DB_URL**_
- _**DB_USERNAME**_
- _**DB_PASSWORD**_
- _**QR_API_URL**_
5. Build the project with Maven:
```bash
mvn clean install
```---
## π Database Schema
## π§βπ€βπ§Users Table
```sql
CREATE TABLE Users (
user_id VARCHAR(10) PRIMARY KEY,
name VARCHAR(50) NOT NULL,
email VARCHAR(75) UNIQUE NOT NULL,
password VARCHAR(60) NOT NULL,
phone VARCHAR(10),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```**Trigger for User ID Generation:**
```sql
DELIMITER $$
CREATE TRIGGER before_insert_users
BEFORE INSERT ON Users
FOR EACH ROW
BEGIN
DECLARE next_id INT;
SELECT COALESCE(MAX(CAST(SUBSTRING(user_id, 2) AS UNSIGNED)), 0) + 1 INTO next_id FROM Users;
SET NEW.user_id = CONCAT('U', LPAD(next_id, 4, '0'));
END$$;
DELIMITER ;
```## π£οΈTrips Table
```sql
CREATE TABLE Trips (
trip_id VARCHAR(10) PRIMARY KEY,
start_location VARCHAR(100) NOT NULL,
end_location VARCHAR(100) NOT NULL,
distance VARCHAR(20) NOT NULL,
duration VARCHAR(20) NOT NULL,
fare DECIMAL(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```**Trigger for Trip ID Generation:**
```sql
DELIMITER $$
CREATE TRIGGER before_insert_trips
BEFORE INSERT ON Trips
FOR EACH ROW
BEGIN
DECLARE next_id INT;
SELECT COALESCE(MAX(CAST(SUBSTRING(trip_id, 2) AS UNSIGNED)), 0) + 1 INTO next_id FROM Trips;
SET NEW.trip_id = CONCAT('R', LPAD(next_id, 4, '0'));
END$$;
DELIMITER ;
```
## ποΈTickets Table
```sql
CREATE TABLE Tickets (
ticket_id VARCHAR(10) PRIMARY KEY,
user_name VARCHAR(50) NOT NULL,
start_location VARCHAR(100) NOT NULL,
end_location VARCHAR(100) NOT NULL,
distance VARCHAR(20) NOT NULL,
duration VARCHAR(20) NOT NULL,
total_fare DECIMAL(10, 2) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);```
**Trigger for Ticket ID Generation:**
```sql
DELIMITER $$
CREATE TRIGGER before_insert_tickets
BEFORE INSERT ON Tickets
FOR EACH ROW
BEGIN
DECLARE next_id INT;
SELECT COALESCE(MAX(CAST(SUBSTRING(ticket_id, 2) AS UNSIGNED)), 0) + 1 INTO next_id
FROM Tickets;
SET NEW.ticket_id = CONCAT('T', LPAD(next_id, 4, '0'));
END$$
DELIMITER ;
```## πΊSeats Table
```sql
CREATE TABLE Seats (
seat_id VARCHAR(10) NOT NULL PRIMARY KEY,
ticket_id VARCHAR(10) NOT NULL,
user_id VARCHAR(10) NOT NULL,
availability TINYINT(1) NOT NULL DEFAULT 1
);
```
**Trigger for Seat ID Generation:**
```sql
DELIMITER $$
CREATE TRIGGER before_insert_seats
BEFORE INSERT ON Seats
FOR EACH ROW
BEGIN
DECLARE next_id INT;
SELECT COALESCE(MAX(CAST(SUBSTRING(seat_id, 2) AS UNSIGNED)), 0) + 1 INTO next_id
FROM Seats;
SET NEW.seat_id = CONCAT('S', LPAD(next_id, 4, '0'));
END;
DELIMITER ;
```
**Trigger to Limit the Seat Count to 50:**
```sql
DELIMITER $$
CREATE TRIGGER limit_seats_before_insert
BEFORE INSERT ON Seats
FOR EACH ROW
BEGIN
DECLARE row_count INT;-- Count the current number of rows in the table
SELECT COUNT(*) INTO row_count FROM Seats;-- Check if the row count exceeds 50
IF row_count >= 50 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Cannot add more rows. Maximum seat limit (50) reached.';
END IF;
END;
DELIMITER ;
```---
## π Future Enhancements
- Integrate a payment gateway for online payments.
- Add analytics for trip data.
- Upgrade the user interface with modern frameworks.---
## π€ Support
For support, email [email protected]