This was also made for a University Course of Mine. Just a basic simple project of my old self!
This is a comprehensive Student Database Management System implemented in C with multi-service architecture, background tasks, and advanced security features. The system provides robust student record management with department-based access control and automatic backups.
Highlights:
- Thread-safe implementation using POSIX mutexes
- Modular design with clear separation of concerns
- Comprehensive error handling and logging
- Production-ready security measures
Four independent background services running concurrently:
- Auto-save service (30-second intervals) - Prevents data loss during unexpected shutdowns
- Backup rotation service (5-minute intervals) - Maintains data recovery points with automatic cleanup
- Statistics monitoring service (1-minute intervals) - Real-time system performance tracking
- REST API service (port 8080) - Web interface for remote access (placeholder,just had the idea but not really interested to fully implement at the time)
- Department-based access control - Users can only access their assigned departments
- Multi-role authentication - Administrator and department-specific user roles
- Comprehensive audit logging - All security-sensitive operations are logged
- Input sanitization - Protection against SQL injection and command injection attacks
- Thread-safe operations - Mutex protection for concurrent access
- CSV import/export with complete metadata preservation (timestamps, departments)
- Timestamp tracking - Creation and modification times for all records
- Automatic backup rotation - Configurable retention policies to manage disk space
- Binary data storage - Efficient storage format with full data integrity
- Exact name matching - Case-insensitive search by first name
- Department-specific searches - Filter students by academic department
- Regex-based pattern matching - Advanced search using regular expressions
- Partial name matching - Find students with incomplete name information
- Academic ID (AM) lookup - Fast exact match search by student identifier
- Real-time statistics dashboard - Live system performance metrics
- Memory usage monitoring - Automatic alerts for high memory consumption
- Service status reporting - Health checks for all background services
- Graceful shutdown handling - Clean termination with data preservation
- Comprehensive logging - Structured logging with severity levels
student_db_system/
├── include/ # Header files
│ └── student_db.h # Main header with declarations, constants, and function prototypes
├── src/ # Source code files
│ ├── main.c # Application entry point and main menu system
│ ├── database.c # Core database operations (CRUD operations, search functions)
│ ├── persistence.c # Data persistence functions (save/load, backup management, CSV I/O)
│ ├── services.c # Background services implementation (auto-save, backup, stats, API)
│ ├── security.c # Security and logging functions (authentication, access control, audit)
│ └── utils.c # Utility functions (input validation, string formatting, system utilities)
├── backups/ # Backup storage directory (automatically created)
├── obj/ # Compiled object files (generated during build)
├── bin/ # Executable output directory (generated during build)
├── Makefile # Build automation with multiple targets
└── README.md # Project documentation
- Linux/Unix environment with POSIX threads library (pthread) installed on local system.
- GCC or compatible C compiler(Clang etc.)
- Approximately 10MB disk space for backups and build artifacts
# Clone the repository
git clone https://github.com/Je0Dev/cli_student_database_system
cd cli_student_database_system
# Create required directories
mkdir -p backups obj bin
# Build the project
make
# Run the application
make run
# Clean build artifacts
make clean
# Complete cleanup (removes all generated files and directories)
make distcleanmake- Compile the project and create executablemake run- Build and execute the applicationmake clean- Remove object files and executablemake distclean- Remove all generated files and directories
The system includes predefined user accounts with different permission levels:
- Username:
admin - Password:
securepass - Permissions: Full system access - can add students from ANY department (AM starting with 11, 12, or 13)
-
Mechanical Engineering User
- Username:
mech_user - Password:
mechpass - Permissions: Can ONLY add students with AM starting with 11 (Mechanical Engineering)
- Username:
-
Electrical Engineering User
- Username:
elec_user - Password:
elecpass - Permissions: Can ONLY add students with AM starting with 12 (Electrical Engineering)
- Username:
-
Civil Engineering User
- Username:
civil_user - Password:
civilpass - Permissions: Can ONLY add students with AM starting with 13 (Civil Engineering)
- Username:
Note: All users can perform read operations (search, view, list) across all departments, but write operations (add, edit, delete) are restricted by department access.
The system enforces a strict Academic ID format:
- Format: 5 digits in pattern
1[1-3][001-999] - Examples: 11001, 12045, 13999
- Structure:
- First digit: University code (always 1)
- Second digit: Department code (1=Mechanical, 2=Electrical, 3=Civil)
- Last three digits: Student number (001-999)
- Role-based permissions prevent unauthorized operations
- Department isolation ensures data privacy
- Audit trail logs all sensitive operations
- Academic ID format validation
- Name format validation with regex patterns
- Input sanitization to prevent injection attacks
- Buffer overflow protection
- Thread-safe operations with mutex protection
- Automatic backup creation and rotation
- Graceful error handling without data corruption
- Operating System: Linux/Unix with POSIX support
- Compiler: GCC 4.8+ or compatible C compiler
- Memory: 64MB RAM (recommended 256MB for optimal performance)
- Disk Space: 10MB (for application and backup storage)
- Libraries: pthread (POSIX threads), regex (for pattern matching)
- Build System: GNU Make
- Debugging: GDB (optional, for development)
- Code Analysis: Valgrind (optional, for memory leak detection)
- This project is licensed under the MIT License
Copyright © 2026 Je0Dev
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Use meaningful variable and function names
- Include explanatory comments for complex logic
- Implement proper error handling and logging
- Maintain thread safety in all database operations