A JavaFX desktop application for managing a public library. Built for the COMP306 Database Systems project (Phase 4). Provides separate interfaces for library members and admin staff, fully connected to a MySQL database.
| Layer | Technology |
|---|---|
| Language | Java 17 |
| UI Framework | JavaFX 21 (FXML + CSS) |
| Database | MySQL 8 (comp306 schema) |
| Build Tool | Maven (via mvnw wrapper) |
| DB Driver | MySQL Connector/J 8.3.0 |
src/main/java/com/comp306/project/
├── HelloApplication.java Entry point — starts JavaFX, loads Login.fxml
├── Launcher.java Wraps HelloApplication for module compatibility
├── Session.java Singleton holding logged-in user state (role, ID)
├── controller/
│ ├── LoginController Handles login form and hotkey shortcuts
│ ├── AdminDashboardController Admin outer shell — wires sidebar nav to content panels
│ ├── UserDashboardController User outer shell — wires sidebar nav to content panels
│ ├── DashboardHomeController Live stats panel (member/loan/fine counts from DB)
│ ├── BookController Book + copy CRUD (admin)
│ ├── MemberController Person/member/staff CRUD (admin)
│ ├── LoanController Borrow / return / renew loans (admin)
│ ├── DonationController Book and monetary donation management (admin)
│ ├── BranchController Branch + staff assignment management (admin)
│ ├── AdminTablesController Raw table viewer with generic CRUD for all 28 tables
│ ├── ReportsController 3 analytical report screens (admin)
│ └── UserTablesController All user-facing views (books, loans, fines, profile)
├── service/
│ ├── AuthenticationService SHA-256 password hashing, login validation
│ ├── BorrowingService Borrow, return, renew, digital concurrency logic
│ ├── UserPortalService Member-scoped queries (available books, fines, payments)
│ ├── AdminSqlService Generic CRUD + whitelist-validated table access
│ ├── DonationService Book and monetary donation transactions
│ ├── PaymentService Fine payment processing
│ └── MemberService Member lookup helpers
├── db/
│ └── DatabaseConnection JDBC connection factory (localhost:3306/comp306)
└── model/
├── Person, Member, Staff Data model classes
├── Book, Loan Data model classes
└── BorrowableBookRow UI table row model for available books
src/main/resources/com/comp306/project/views/
├── Login.fxml Login screen
├── Dashboard.fxml Admin outer shell (sidebar + content area)
├── AdminDashboard.fxml Admin home panel — live stats grid + recent activity
├── ReportsView.fxml 3-tab report panel (analytical queries)
├── BookView.fxml Book + copy management
├── MemberView.fxml People management (members + staff)
├── LoanView.fxml Borrowing management
├── DonationView.fxml Donation management
├── BranchView.fxml Branch management
├── AdminTablesView.fxml Raw table viewer
├── UserDashboard.fxml User outer shell (sidebar + content area)
├── UserAvailableBooksView.fxml Available books browser
├── UserBorrowedBooksView.fxml Currently borrowed books
├── UserLoanHistoryView.fxml Full borrowing history
├── UserFinesView.fxml Outstanding and paid fines
├── UserPaymentsView.fxml Payment history + make payment
└── UserProfileView.fxml Edit personal info + change password
- Database name:
comp306 - Connection:
localhost:3306— credentials stored inDatabaseConnection.java - Tables: 28 tables covering persons, members, staff, books, formats, loans, fines, payments, donations, branches, memberships, and their sub-type tables
- Stored procedures:
BorrowBook(memberID, formatID),PayFine(memberID, fineID, amount) - Triggers:
trg_max_loans(max 5 active loans),trg_return_processing(auto-overdue),trg_create_fine(auto-fine on return)
# Requires Java 17+ and a running MySQL instance with the comp306 schema loaded
./mvnw javafx:runOn Linux you may need:
chmod +x mvnwbefore running.
| Role | ID | Password | Hotkey |
|---|---|---|---|
| Admin | 4 | default123 | Alt+A |
| User | 1 | default123 | Alt+U |
Press Alt+A or Alt+U on the login screen to auto-fill credentials and log in instantly.
- Select the Member radio button on the login screen (or press Alt+U for instant dev login).
- Enter your MemberID and password, then click Login.
- On success the Member Portal window opens, showing your name in the sidebar.
- The table loads all available physical and digital copies from the database.
- Columns show: FormatID, Book Title, Copy Type (Physical/Digital), File Type, Publisher, Year, Category, available slots, and status.
- Digital books can be borrowed directly from this screen: select a row and click Borrow Digital Book. The system checks concurrent user limits and the member's active loan count before allowing the borrow.
- Physical books must be requested at a branch — use the FormatID shown to tell a librarian.
- Shows all loans where status is
ActiveorOverdue. - Columns: LoanID, Title, Copy Type, File Type, Issue Date, Due Date, Status.
- Return Digital Book: Select a digital loan and click the button. This inserts a return record, marks the loan
Returned, and frees up a concurrent slot. - Renew Loan: Select any active/overdue loan, confirm a new due date (defaults to +14 days), and click Renew. Only active and overdue loans can be renewed.
- Shows the complete history of all your loans, including returned ones.
- Columns: LoanID, Title, Copy Type, Issue Date, Due Date, Status, Return Date, Item Condition.
- Read-only view — no actions available.
- Lists all fines linked to your account.
- Fines are generated automatically by database triggers when a book is returned late, damaged, or lost.
- Columns: FineID, Issue Date, Fine Type (Late Return / Damage / Lost), Book Title, Amount (R), Payment Status.
- Read-only view — pay fines from the Payments screen.
- Shows three live balance cards at the top: Total Owed (sum of all your fines), Total Paid (sum of all your payments), Balance (owed minus paid).
- The table below lists all past payments with date, amount, method, and settlement type.
- Click Make Payment to open a dialog: choose a payment method (Cash / Card / EFT) and enter an amount. This inserts a record into the
paymenttable linked to your MemberID.
- Loads your personal record from
memberandpersontables. - Editable fields: Full Name, Email Address, Phone Number, Date of Birth, Home Address.
- Read-only fields: MemberID, Account Status, ID Number, Membership Tier, Membership Status, Expiry Date.
- Click Save Personal Information to commit changes to the
persontable. - Change Password: enter your current password (verified against the stored SHA-256 hash), then enter and confirm a new password (minimum 6 characters). Click Change Password to update.
- Click Logout in the sidebar to return to the login screen. The session is cleared.
- Select the Admin radio button (or press Alt+A for instant dev login).
- Enter your StaffID and password, then click Login.
- The Admin Dashboard window opens with a sidebar listing all management modules.
- Displays 9 live statistics queried from the database at load time:
- Total Members, Total Staff, Total Books
- Active Loans (Active + Overdue), Available Copies, Unpaid Fines count
- Total Donations, Total Payments (R), Outstanding Fine Amount (R)
- Recent Activity panel shows the most recent loan, most recent return, and most recent donation — each pulled live from the database with member name, book title, and date.
- Combined view of all members and staff.
- Search by name, email, or ID.
- Add Person: Creates a
personrecord and assigns a role (Member, Librarian, or Head Librarian). Librarian and Head Librarian roles require a BranchID and salary; Head Librarian also updates the branch'sHStaffID. - Assign Role: Assigns a role to an existing person without re-entering personal details.
- Modify Person: Updates name, email, phone, date of birth, or address.
- Delete Person: Cascades through all related tables (librarian, headlibrarian, staff, memberships, member, donor, person) in the correct dependency order before deleting the person record.
- Books table: shows title, author(s), and category. Searchable by title, ISBN, category, or author.
- Copies table: shows all format copies, filtered to the selected book when a row is selected.
- Add Resource: Creates a book record and optionally creates/links an author.
- Modify Resource: Updates book fields and/or replaces the author link.
- Delete Resource: Removes the book and its author links (cascades to formats if no active loans).
- Add Copy: Creates a
formatrecord plus either aphysicalcopy(shelf location, condition) ordigitalcopy(file type, concurrent user limit). - Assign Branch / Modify Copy / Delete Copy: Manage individual format records.
- Table shows all loans with member, resource, dates, status, and return date.
- Borrow Copy: Enter a MemberID and FormatID. The system checks availability and inserts a 14-day loan via
BorrowingService.borrowBook(). - Return Copy: Select a loan (or enter a LoanID), set the return date and item condition. Works for both
ActiveandOverdueloans. Inserts areturnrecord; database triggers auto-generate fines if applicable. - Renew: Extends the due date. Allowed for
ActiveandOverdueloans. - Delete Record: Removes a loan record entirely (admin correction only).
- Clicking Refresh also calls
syncReturnedLoanStatuses()to repair any loans that have a return record but were not yet markedReturned.
- Table of all donations with donor, type, description, and date.
- Record Donation: Choose type (Book or Monetary). Book donations require an ISBN and BranchID; monetary donations require an amount and purpose. The donor is resolved from their DonorID.
- Modify Donation: Update the date, type, description, and type-specific fields.
- Delete Donation: Removes the donation and its sub-type record.
- Three-panel view: branch list (top left), staff at the selected branch (bottom left), and book copies held at that branch (right).
- Selecting a branch row automatically refreshes the staff and copies panels.
- Add Branch / Modify Branch / Assign Staff / Delete Branch: Full branch management including head librarian linking.
Three analytical screens, each joining four or more tables:
| Report | Description | Tables Joined |
|---|---|---|
| Member Borrowing Summary | All members ranked by total loan count, broken down by active / overdue / returned | member, person, loan, membership |
| Overdue Loans & Fines | All currently active/overdue loans with days overdue and accumulated fine amounts | loan, member, person, format, book, returnrecord, fine |
| Branch Inventory & Activity | Per-branch summary of copy counts, availability, staff count, and active loans | branch, format, librarian, loan |
Each tab has a Refresh button to re-run the query live.
- Raw table browser: select any of the 28 tables from a dropdown to view all rows.
- Generic Add / Modify / Delete dialogs are available for direct record manipulation across any table.
- Intended for administrative correction and data inspection.
- Returns to the login screen. The session is cleared.
| Requirement | Implementation |
|---|---|
| Create record | All management screens (People, Resources, Borrowing, Donations, Branches, All Tables) |
| Update record | Modify actions on every management screen + user profile self-edit |
| Delete record | Delete actions on every management screen with dependency-safe cascade handling |
| 3 report screens (SQL ≥ 3 tables) | Reports tab: Member Borrowing Summary, Overdue Loans & Fines, Branch Inventory & Activity |
| Stored procedures | BorrowBook, PayFine |
| Triggers | trg_max_loans, trg_return_processing, trg_create_fine |
| Supertype/subtype hierarchies | Person → Member / Staff / Donor; Membership → AdultMembership / ChildMembership; Format → PhysicalCopy / DigitalCopy; Fine → LateReturnFee / DamageFee / LostFee |
| ≥ 15 entities | 28 tables in the schema |