Library is a small Java application for keeping track of books, members, cards, and loans. It was built as a school project.
- Adds and updates books and members.
- Issues and regenerates library cards.
- Creates and returns loans while enforcing availability and loan limits.
- Keeps archived books in loan history without making them borrowable.
- Shows basic lending statistics.
- Stores related changes in SQLite transactions.
CLI and Swing are adapters around the same manager. A single application context owns database access and is passed to every GUI window, so opening two windows does not create two independent copies of the data. Each snapshot is rebuilt as one complete users → cards → loans object graph.
SQLite assigns record IDs. Loan creation, return, card regeneration, and user registration each run as one transaction: either every related change is committed or none is. Books have an explicit archived state, independent from their available-copy count.
Deactivating a lost card does not remove or rewrite its loans. Regeneration is a separate operation. It replaces the active card and moves open loans to the replacement in the same transaction.
The project rule allows at most three active loans per member. That limit, the 60-day default loan period, and the one-year card validity are named in LibraryRules.
- JDK 17 or newer
- Apache Maven 3.9 or newer
Run the complete verification pipeline:
mvn clean verifyThis compiles the project, runs the JUnit regression suite, packages both applications, and starts each packaged JAR in non-interactive smoke-test mode. The regressions include failed writes, restarts, stale windows, ID continuity, and concurrent loan attempts. The resulting executable files are:
target/library-cli.jartarget/library-gui.jar
Start the terminal interface:
java -jar target/library-cli.jarStart the Swing interface:
java -jar target/library-gui.jarBy default, the application creates data/library.db. To keep the data directory elsewhere, set library.data.dir:
java -Dlibrary.data.dir=/path/to/data -jar target/library-cli.jarsrc/main/java/model: domain objects and lending rulessrc/main/java/service: operations shared by CLI and GUIsrc/main/java/storage: SQLite schema and transaction handlingsrc/main/java/app: terminal interfacesrc/main/java/ui: Swing interfacesrc/test/java/tests: regression, persistence, concurrency, and packaged-JAR testsdata: default location for the local database