A cross-platform library management system based on C++20 and SQLite
Overview โข Features โข Building โข Usage โข Structure
๐บ๐ธ English | ๐จ๐ณ ็ฎไฝไธญๆ
libraryManagementSystem is a local, terminal-based library management system built on an SQLite database, which also offers visual management capabilities via a web interface. The system is developed using the C++20 standard, built with CMake, and supports the three major operating systems: Windows, Linux, and macOS.
The system implements role-based access control with two user types:
| Role | Functions |
|---|---|
| Administrator | Book management (CRUD), user management, borrowing record queries |
| Student | Book search, borrow/return/renew books, personal account management |
| Feature | Description |
|---|---|
| Cross-Platform | Native support for Windows, Linux, macOS |
| Embedded SQLite | SQLite amalgamation fetched via CMake FetchContent |
| Secure Passwords | SHA-256 encrypted password storage |
| Security Token | Support for password recovery security tokens |
| Overdue Alerts | Automatic detection and notification of overdue books |
| Adaptive UI | Tables automatically adjust to terminal width |
| Multi-Language Support | Switch between English and Chinese interface languages |
| Web Interface | A Modern Vue 3 WebUI |
| RESTful API | Node.js Express API server for web integration |
| Logging System | Comprehensive logging with query capabilities |
| Enhanced Admin Panel | Full book, user, and borrowing management capabilities |
| User Management | Complete user registration, authentication, and profile management |
| Responsive Design | Optimized for desktop and mobile devices |
| Dependency | Version |
|---|---|
| CMake | >= 3.11 |
| C++ Compiler | C++20 support |
Compiler options by platform:
- Windows: MinGW-w64 or Visual Studio 2019+
- Linux: g++ >= 9.0
- macOS: Apple Clang or gcc
Check CMake installation:
cmake --versionNote: CMake will download the SQLite amalgamation during the configure step.
# Navigate to project directory
cd /path/to/libraryManagementSystem
# Create build directory and compile
cmake -B build && cmake --build build
# Run the program
cd build
./lib# Navigate to project directory
cd /d /path/to/libraryManagementSystem
# Create build directory and compile
cmake -B build -G "MinGW Makefiles" && cmake --build build
# Run the program
cd build
lib.exe# Create Visual Studio solution
cmake -B build -G "Visual Studio 17 2022"
# Build (or open build directory in IDE)
cmake --build build --config Release
# Run the program
build\Release\lib.exe| IDE | Steps |
|---|---|
| CLion | Open project โ Auto-detect CMake โ Click Run |
| Visual Studio | Open folder โ Select lib.exe as startup โ Run |
Note: For legacy IDEs like VC++ 6.0, consider using CMake or modern IDEs
Compile Windows executables on macOS/Linux:
# Install dependencies
brew install cmake mingw-w64
# Create build directory
mkdir build && cd build
# Configure cross-compilation
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Windows-x86.cmake
# Build
cmake --build .# Install dependencies
sudo apt-get update
sudo apt-get install -y cmake g++-mingw-w64-x86-64 gcc-mingw-w64-x86-64
# Create build directory
mkdir build && cd build
# Configure cross-compilation
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Windows-x86.cmake
# Build
cmake --build .โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Program Start โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Initialize Database (library.db) โ
โ - Create table structures โ
โ - Check for administrator account โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Main Menu โ
โ 1. Login 2. Register 3. Forgot Password 0. Exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Login โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Admin (ADMIN) โ โ Student (STUDENT)โ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ Admin Menu โ โ Student Menu โ
โ 1. Book Mgmt โ โ 1. Search Books โ
โ - Add/Edit/ โ โ 2. Borrow Book โ
โ Delete/Find โ โ 3. Return Book โ
โ 2. User Mgmt โ โ 4. Renew Book โ
โ - Add User โ โ 5. My Borrowings โ
โ - Change Pass โ โ 6. Account Mgmt โ
โ 3. Borrow Mgmt โ โ - View Info โ
โ - Query Studentโ โ - Edit Info โ
โ - All Records โ โ - Change Pass โ
โโโโโโโโโโโโโโโโโโโโ โ - Set Token โ
โโโโโโโโโโโโโโโโโโโโ
| Function | Description |
|---|---|
| Add Book | Add new book with ISBN, title, author, publisher, category, quantity |
| Edit Book | Modify book information by ISBN |
| Delete Book | Remove book (requires no active borrowings) |
| Search Books | Search by keyword (title/author/ISBN) |
| List All Books | Display all books, sortable by title/author/ISBN |
| Function | Description |
|---|---|
| Borrow Book | Enter ISBN and borrowing days (1-90 days) |
| Return Book | Return borrowed book by record ID |
| Renew Book | Extend borrowing period |
| View Borrowings | View personal borrowing records |
| Function | Description |
|---|---|
| Change Password | Admin can change any user's password; students can only change their own |
| Security Token | Set password recovery token for verification |
| Forgot Password | Reset password using username and security token |
- Automatic detection of overdue books
- Students are notified of overdue books upon login
- Admin can view all borrowing records with overdue status
- Switch between English and Chinese interface languages
- Language preference is saved in config.ini file
- Accessible from the main menu (option 4)
--- Welcome to Library Management System ---
1. Login
2. Student Registration
3. Forgot Password
4. Choose Language / ้ๆฉ่ฏญ่จ
0. Exit
--------------------------------------------
Please enter your choice:
--- Choose Language ---
1. English
2. ไธญๆ
0. Return
-----------------------------
Please enter your choice:
--- Admin Menu (admin) ---
1. Book Management - Add/Edit/Delete/Search
2. User Management - Add User/Change Password
3. Borrowing Management - Query Student/All Records
0. Logout
-----------------------------
Please enter your choice:
--- Student Menu (Zhang San) ---
1. Search Books
2. Borrow Book
3. Return Book
4. Renew Book
5. View My Borrowings
6. Account Management (View Info/Change Password/Set Token)
0. Logout
---------------------------------
Please enter your choice:
+----------------------+------------------------+----------------+--------+--------+
| ISBN | Title | Author | Avail | Total |
+----------------------+------------------------+----------------+--------+--------+
| 978-7-111-40701-0 | Computer Systems | Randal E. Bryant| 3 | 5 |
| 978-7-302-33227-9 | C++ Primer Plus | Stephen Prata | 2 | 3 |
+----------------------+------------------------+----------------+--------+--------+
+--------+----------------------+------------------------+--------------+--------------+
| Rec ID | ISBN | Title | Borrow Date | Due Date |
+--------+----------------------+------------------------+--------------+--------------+
| 1 | 978-7-111-40701-0 | Computer Systems | 2025-03-01 | 2025-03-31 |
+--------+----------------------+------------------------+--------------+--------------+
libraryManagementSystem/
โโโ CMakeLists.txt # CMake build configuration
โโโ cmake/
โ โโโ Windows-x86.cmake # Windows cross-compilation toolchain
โโโ header/
โ โโโ database.h # Database manager class declaration
โ โโโ logger.h # Logger class for system logging
โ โโโ sha256.h # SHA-256 encryption header
โ โโโ utils.h # Utility functions (clear screen, terminal width, etc.)
โ โโโ localization.h # Localization and language switching functionality
โโโ src/
โ โโโ main.cpp # Program entry point and UI logic
โ โโโ database.cpp # Database operations implementation
โ โโโ logger.cpp # Logger implementation
โ โโโ logging_functions.cpp # Log query functions
โ โโโ sha256.cpp # SHA-256 encryption implementation
โโโ api-server/ # Node.js Express API server
โ โโโ server.js # API server implementation
โ โโโ package.json # Node.js dependencies
โ โโโ README.md # API server documentation
โโโ webui/ # Vue 3 WebUI (updated to white theme)
โ โโโ src/
โ โ โโโ api/ # API service layer
โ โ โโโ views/ # Vue components and pages
โ โ โโโ router/ # Vue Router configuration
โ โ โโโ store/ # Pinia state management
โ โ โโโ plugins/ # Vue plugins (i18n, etc.)
โ โโโ package.json # Frontend dependencies
โ โโโ vite.config.ts # Vite configuration
โโโ build/ # Build output directory
โโโ docs/
โโโ README_zh-CN.md # Chinese documentation
โโโ CMake ๅฎ่ฃ
ๆ็จ.md # CMake installation guide (Chinese)
โโโ API_SERVER_GUIDE.md # API server implementation guide
โโโ DEPLOYMENT_GUIDE.md # Complete deployment guide
| Technology | Description |
|---|---|
| C++20 | Modern C++ features (structured bindings, smart pointers, etc.) |
| SQLite3 | Lightweight embedded database, zero configuration |
| CMake | Cross-platform build system |
| SHA-256 | Password encryption algorithm |
| Localization | Multi-language support with English/Chinese |
| Node.js + Express | RESTful API server for web integration |
| Vue 3 + TypeScript | Modern reactive frontend framework |
| Element Plus | Vue 3 UI component library |
| Vite | Next generation frontend tooling |
| Enhanced UI/UX | White theme with improved accessibility and contrast |
| Complete Admin Panel | Full book, user, and borrowing management |
| Improved Logging | Comprehensive system monitoring and audit trails |
# Build the C++ program
cmake -B build && cmake --build build
# Run
cd build
./lib# 1. Start API server
cd api-server
npm install
npm start
# 2. Start frontend (in another terminal)
cd webui
npm install
npm run dev
# 3. Open browser
# Visit http://localhost:3000Default admin account:
- Username:
admin - Password:
admin
For detailed deployment instructions, see DEPLOYMENT_GUIDE.md
On first run, the program will automatically:
- Create
library.dbdatabase file - Initialize table structures (books, users, borrowing records)
- Create default administrator account (username:
admin, password:admin)
| Role | Username | Password |
|---|---|---|
| Admin | admin | admin |
- Select
2. Student Registrationfrom main menu - Enter student ID, name, college, class information
- Set login username and password
- Registration complete, ready to login
- Select
3. Forgot Passwordfrom main menu - Enter username
- Enter previously set security token
- Set new password
- From the main menu, select
4. Choose Language / ้ๆฉ่ฏญ่จ - Choose between
1. Englishor2. ไธญๆ - The interface language will change immediately
- Language preference is saved in config.ini file
| Item | Description |
|---|---|
| Database File | library.db is saved in the running directory, do not delete |
| Configuration File | config.ini stores language preferences and other settings |
| Terminal Encoding | Use UTF-8 encoding (Windows: chcp 65001) |
| Borrowing Limits | 1-90 days borrowing period, book quantity cannot be negative |
| Deletion Limits | Books with active borrowings cannot be deleted |
- Reference project for university C++ programming courses
- Database application development teaching case
- CMake cross-platform build practice
- Terminal UI design reference
This project is licensed under the MIT License - see the LICENSE file for details.
Issues and Pull Requests are welcome!
Made with โค๏ธ by @Rouxiv