Skip to content

kents00/Library-Attendance-Management

Repository files navigation

Library Attendance Management

A modern web-based library attendance system built with Flask, designed to streamline student attendance management in libraries. This application provides an intuitive interface for students to check in via ID and offers comprehensive admin tools for viewing attendance metrics, generating reports, and managing user data.

image

Features

Core Functionality

  • Student Check-In: Quick ID-based attendance tracking with real-time student information display
  • Modern Admin Dashboard: Interactive dashboard with real-time analytics and visual charts
  • User Role Management: Separate authentication for students and administrators
  • Real-time Notifications: Flash message system with modern pop-up notifications using Notiflix

Admin Features

  • Comprehensive Dashboard:
    • Interactive visitor statistics charts with course-based filtering
    • Real-time attendance data with customizable time ranges (weekly, monthly, yearly, custom)
    • Location-based visitor analytics
    • Recently logged-in students tracking
  • Student Management: Complete CRUD operations for student records
  • Course Management: Add, edit, and delete courses with enrollment tracking
  • Profile Management: Admin profile settings with image upload support
  • Advanced Filtering: Filter data by time periods, courses, and locations

Data Management & Export

  • Multiple Export Formats: CSV and PDF export options with custom date ranges
  • Advanced Analytics:
    • Attendance by course, age group, and residence
    • Peak hours analysis
    • Monthly/weekly trends
  • Comprehensive Backup System: Automatic backup of deleted records in both CSV and SQLite formats
  • Location Management: Hierarchical location system (Province > Municipality > Barangay)

Security & Authentication

  • Password Reset System: Email-based password recovery with verification codes
  • Secure Admin Authentication: Role-based access control
  • Session Management: Secure session handling with proper logout functionality

User Experience

  • Responsive Design: Mobile-friendly interface that works on all devices
  • Modern UI: Clean, intuitive design with Bootstrap 5
  • Real-time Updates: Live dashboard updates and notifications
  • Flash Message System: Consistent notification system across all pages
  • Loading Indicators: Visual feedback for all operations

Project Structure

Library-Attendance-Management/
β”œβ”€β”€ app.py                      # Main Flask application
β”œβ”€β”€ config.py                   # Configuration settings
β”œβ”€β”€ init_db.py                  # Database initialization
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ models/                     # Database models
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ attendance.py           # Attendance tracking model
β”‚   β”œβ”€β”€ course.py               # Course management model
β”‚   β”œβ”€β”€ location.py             # Location hierarchy model
β”‚   β”œβ”€β”€ student.py              # Student information model
β”‚   └── user.py                 # User authentication model
β”œβ”€β”€ routes/                     # Application routes
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ admin_routes.py         # Admin dashboard and management
β”‚   β”œβ”€β”€ graph_routes.py         # Chart and analytics endpoints
β”‚   └── student_routes.py       # Student check-in functionality
β”œβ”€β”€ templates/                  # HTML templates
β”‚   β”œβ”€β”€ base.html               # Base template
β”‚   β”œβ”€β”€ login.html              # Student login page
β”‚   β”œβ”€β”€ _flash_messages.html    # Flash message component
β”‚   └── admin_new/              # Modern admin interface
β”‚       β”œβ”€β”€ ae_base.html        # Admin base template
β”‚       β”œβ”€β”€ ae_dashboard.html   # Interactive dashboard
β”‚       β”œβ”€β”€ ae_login.html       # Admin login
β”‚       β”œβ”€β”€ ae_manage.html      # Student management
β”‚       β”œβ”€β”€ ae_user.html        # Admin profile management
β”‚       β”œβ”€β”€ ae_forgot_password.html  # Password recovery
β”‚       β”œβ”€β”€ ae_reset_password.html   # Password reset
β”‚       β”œβ”€β”€ ae_verify_code.html      # Email verification
β”‚       └── ae_download.html    # Export interface
β”œβ”€β”€ utils/                      # Utility functions
β”‚   β”œβ”€β”€ backup.py               # Record backup system
β”‚   β”œβ”€β”€ email_verification.py   # Email verification utilities
β”‚   β”œβ”€β”€ ensure_dirs.py          # Directory management
β”‚   β”œβ”€β”€ export.py               # Data export functionality
β”‚   └── graph_export.py         # Chart generation and export
└── static/                     # Static assets
    β”œβ”€β”€ assets/                 # UI framework assets
    β”œβ”€β”€ uploads/                # User uploaded files
    └── js/                     # Custom JavaScript

Installation

Prerequisites

  • Python 3.8 or higher
  • Git
  • (Optional) Docker for containerized deployment

Local Installation

  1. Clone the Repository:

    git clone https://github.com/kents00/Library-Attendance.git
    cd Library-Attendance-Management
  2. Set Up Virtual Environment:

    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Environment Configuration: Create a .env file in the root directory:

    SECRET_KEY=your-secret-key-here
    DEBUG=True
    DATABASE_URL=sqlite:///instance/attendance.db
    UPLOAD_FOLDER=static/uploads
    
    # Email Configuration (Optional - for password reset)
    MAIL_SERVER=smtp.gmail.com
    MAIL_PORT=587
    MAIL_USE_TLS=True
    MAIL_USERNAME=your-email@gmail.com
    MAIL_PASSWORD=your-app-password
  5. Initialize Database:

    python init_db.py
  6. Run the Application:

    python app.py

    Access the application at http://localhost:5000

Docker Deployment

Quick Start with Docker Hub

# Pull and run the latest image
docker pull kents00/library-access-monitor:latest
docker run -d -p 5000:5000 --name library-access-monitor kents00/library-access-monitor:latest

# Access the application
# Navigate to http://localhost:5000

Local Docker Build

# Build and start with docker-compose
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the application
docker-compose down

Docker Management Commands

# Stop the container
docker stop library-access-monitor

# Remove the container
docker rm library-access-monitor

# View container logs
docker logs library-access-monitor

# Access container shell
docker exec -it library-access-monitor /bin/bash

Usage Guide

For Students

  1. Check-In Process:
    • Navigate to the main page
    • Enter your student ID
    • View your profile information and confirm attendance
    • Receive confirmation of successful check-in

For Administrators

Initial Setup

  1. First-Time Login:
    • Default admin credentials are created during database initialization
    • Access admin panel at /admin/login
    • Update admin profile and change default password

Dashboard Features

  1. Analytics Dashboard:

    • View real-time visitor statistics with interactive charts
    • Filter data by time periods (weekly, monthly, yearly, custom)
    • Monitor attendance trends by course and location
    • Track recently logged-in students
  2. Student Management:

    • Add new students with complete profile information
    • Edit existing student records
    • Upload student profile images
    • Manage student-course assignments
    • Bulk operations and search functionality
  3. Course Management:

    • Create and manage academic courses
    • View enrollment statistics
    • Track course-specific attendance patterns
  4. Data Export & Reports:

    • Export attendance data in CSV or PDF formats
    • Generate custom reports with date range filtering
    • Download visual charts and analytics
    • Access historical attendance data
  5. System Administration:

    • Manage admin profiles and permissions
    • Configure system settings
    • Access backup and recovery tools
    • Monitor system health and performance

Password Recovery

  1. Forgot Password:
    • Use the "Forgot Password" link on admin login
    • Enter email address associated with admin account
    • Check email for 6-digit verification code
    • Enter verification code and set new password

πŸ”§ Configuration

Email Setup (Optional)

For password reset functionality, configure email settings in your .env file:

MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password  # Use app-specific password for Gmail

File Upload Configuration

UPLOAD_FOLDER=static/uploads
MAX_CONTENT_LENGTH=16777216  # 16MB max file size

Database Configuration

# SQLite (default)
DATABASE_URL=sqlite:///instance/attendance.db

# PostgreSQL (for production)
DATABASE_URL=postgresql://username:password@localhost/dbname

# MySQL
DATABASE_URL=mysql://username:password@localhost/dbname

Backup & Recovery

Automatic Backup Features

  • Deletion Backups: Automatic backup creation when records are deleted
  • Multiple Formats: CSV and SQLite backup formats
  • Timestamped Files: Unique backup files with creation timestamps
  • Organized Storage: Backups stored in utils/backups/ directory

Manual Backup

# Create manual database backup
python -c "from utils.backup import create_manual_backup; create_manual_backup()"

# Export all data
python -c "from utils.export import export_all_data; export_all_data()"

πŸ› οΈ Development

Adding New Features

  1. Create Feature Branch:

    git checkout -b feature/new-feature-name
  2. Database Changes:

    • Update model files in models/
    • Run database migrations
    • Test changes thoroughly
  3. Frontend Updates:

    • Modify templates in templates/
    • Update static assets in static/
    • Ensure responsive design
  4. Backend Logic:

    • Add routes in appropriate routes/ files
    • Create utility functions in utils/
    • Implement proper error handling

Testing

# Run application in debug mode
export FLASK_ENV=development
export FLASK_DEBUG=1
python app.py

# Test database operations
python -c "from models import db; db.create_all()"

Recent Updates

Version 2.1.0 Features

  • βœ… Modern Admin Interface: Complete UI overhaul with responsive design
  • βœ… Interactive Dashboard: Real-time charts and analytics
  • βœ… Flash Message System: Consistent notifications across all pages
  • βœ… Password Recovery: Email-based password reset functionality
  • βœ… Course Management: Complete course CRUD operations
  • βœ… Enhanced Security: Improved authentication and session management
  • βœ… Location Management: Hierarchical location system
  • βœ… Advanced Filtering: Custom date ranges and multi-criteria filtering
  • βœ… Export Improvements: Enhanced PDF and CSV export capabilities
  • βœ… Backup System: Comprehensive data backup and recovery

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the Repository
  2. Create Feature Branch: git checkout -b feature/amazing-feature
  3. Commit Changes: git commit -m 'Add amazing feature'
  4. Push to Branch: git push origin feature/amazing-feature
  5. Open Pull Request

Contribution Guidelines

  • Follow PEP 8 style guidelines
  • Write comprehensive tests
  • Update documentation
  • Ensure backward compatibility
  • Test across different browsers and devices

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

About

designed to streamline student attendance management in libraries

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •