A cross-platform library management system based on C++20 and SQLite
Overview • Features • Building • Usage • Structure
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