A comprehensive full-stack attendance management system built with Laravel 12 and Vue 3, featuring real-time statistics, automated reporting, and Redis caching for optimal performance.
- Features
- Tech Stack
- Prerequisites
- Installation
- Database Setup
- Running the Project
- Test Credentials
- Docker Setup
- Testing
- API Documentation
- Project Structure
- Contributing
- β Student Management - Complete CRUD operations with photo upload
- β Bulk Attendance Recording - Mark attendance for entire class at once
- β Real-time Statistics - Live attendance percentage calculations
- β Comprehensive Reports - Daily, Weekly, and Monthly reports
- β Class Comparison - Compare attendance across different classes
- β Low Attendance Alerts - Automatic notifications for students below threshold
- β Export Functionality - Export reports to CSV, JSON, and PDF
- β Redis Caching - 10-20x performance improvement on reports
- β Event-Driven Architecture - Automated notifications and logging
- β Service Layer - Clean separation of business logic
- β Chart.js Integration - Visual attendance analytics
- β Sanctum Authentication - Secure token-based API authentication
- β Docker Support - One-command deployment
- β Artisan Commands - CLI tools for report generation and cache management
- Framework: Laravel 12.38.1
- PHP: 8.2+
- Database: SQLite (dev) / MySQL 8.0 (production)
- Cache: Redis 7.0
- Authentication: Laravel Sanctum
- Testing: PHPUnit 11.5
- Framework: Vue 3.5.24 (Composition API)
- Build Tool: Vite 6.0
- HTTP Client: Axios
- Charts: Chart.js 4.5
- Routing: Vue Router 4.5
- Containerization: Docker & Docker Compose
- Web Server: PHP Built-in / Nginx (production)
- Process Manager: PM2 (optional)
Before you begin, ensure you have the following installed:
- PHP >= 8.2
- Composer >= 2.0
- Node.js >= 18.0
- npm >= 9.0
- Redis >= 7.0 (optional but recommended)
- MySQL >= 8.0 (for production) or SQLite (for development)
- Docker & Docker Compose (optional)
php --version # Should be 8.2 or higher
composer --version # Should be 2.0 or higher
node --version # Should be 18.0 or higher
npm --version # Should be 9.0 or higher
redis-cli --version # Should be 7.0 or higher (optional)git clone <repository-url>
cd school-attendance-system# Navigate to backend directory
cd backend
# Install PHP dependencies
composer install
# Copy environment file
cp .env.example .env
# Generate application key
php artisan key:generate
# Create SQLite database file (for development)
touch database/database.sqlite
# Or configure MySQL in .env (for production)
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=school_attendance
# DB_USERNAME=root
# DB_PASSWORD=your_password# Navigate to frontend directory
cd ../frontend
# Install Node dependencies
npm install
# Copy environment file
cp .env.example .env
# Update API URL in .env if needed
# VITE_API_URL=http://localhost:8000macOS:
brew install redis
brew services start redisUbuntu/Debian:
sudo apt update
sudo apt install redis-server
sudo systemctl start redis-server
sudo systemctl enable redis-serverWindows: Download from Redis Windows
Verify Redis:
redis-cli ping
# Should return: PONGConfigure Laravel to use Redis:
# In backend/.env
CACHE_STORE=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379cd backend
# Create database file
touch database/database.sqlite
# Run migrations
php artisan migrate
# Seed database with sample data
php artisan db:seed
# Or run migrations and seed together
php artisan migrate:fresh --seedcd backend
# Update .env with MySQL credentials
# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=school_attendance
# DB_USERNAME=your_username
# DB_PASSWORD=your_password
# Create database
mysql -u root -p
CREATE DATABASE school_attendance;
EXIT;
# Run migrations
php artisan migrate
# Seed database
php artisan db:seed# Fresh migration (drops all tables and recreates)
php artisan migrate:fresh
# Fresh migration with seeding
php artisan migrate:fresh --seed
# Rollback last migration
php artisan migrate:rollback
# Check migration status
php artisan migrate:status
# Seed specific seeder
php artisan db:seed --class=StudentSeedercd backend
# Start Laravel development server
php artisan serve
# Server will start at http://localhost:8000cd frontend
# Start Vite development server
npm run dev
# Server will start at http://localhost:5173# Redis should already be running as a service
# Check status
redis-cli ping
# Or start manually
redis-server- Frontend: http://localhost:5173
- Backend API: http://localhost:8000/api
- API Documentation: http://localhost:8000/api/documentation (if configured)
After running php artisan db:seed, you can use these credentials:
Email: admin@example.com
Password: password
Email: teacher1@school.com
Password: password
Email: teacher2@school.com
Password: password
- Users: 3 (1 admin, 2 teachers)
- Classes: 10 (Class 1 to Class 10)
- Sections: 3 per class (A, B, C)
- Students: 300 (10 per section)
- Attendance Records: Last 30 days for all students
- Holidays: Common holidays for current year
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downThe Docker setup includes:
- app - Laravel backend (PHP 8.2-FPM)
- db - MySQL 8.0 database
- redis - Redis 7 cache server
- frontend - Vue.js frontend (Node 18)
# Build and start
docker-compose up -d --build
# Run migrations in container
docker-compose exec app php artisan migrate
# Seed database in container
docker-compose exec app php artisan db:seed
# Access backend container
docker-compose exec app bash
# Access database
docker-compose exec db mysql -u root -p
# View logs
docker-compose logs -f app
docker-compose logs -f frontend
# Stop all services
docker-compose down
# Remove volumes (clean slate)
docker-compose down -v- Frontend: http://localhost:3000
- Backend: http://localhost:8000
- MySQL: localhost:3306
- Redis: localhost:6379
cd backend
# Run all tests
php artisan test
# Run with coverage
php artisan test --coverage
# Run specific test file
php artisan test tests/Feature/AttendanceTest.php
# Run specific test method
php artisan test --filter test_can_record_bulk_attendance# List all tests
php artisan test --list-tests
# Tests included:
# - AttendanceTest (3 tests)
# - AttendanceServiceTest (3 tests)
# - StudentTest (5 tests)
# Total: 13 testsTests use an in-memory SQLite database and are automatically cleaned up after each test using the RefreshDatabase trait.
POST /api/login
POST /api/logout
POST /api/registerGET /api/students # List all students (paginated)
POST /api/students # Create student
GET /api/students/{id} # Get student details
PUT /api/students/{id} # Update student
DELETE /api/students/{id} # Delete student
GET /api/students/{id}/attendance-history # Student attendance historyPOST /api/attendances/bulk # Record bulk attendance
GET /api/attendances/statistics # Get attendance statistics
GET /api/attendance/dashboard # Dashboard overviewGET /api/reports/daily # Daily report
GET /api/reports/weekly # Weekly report
GET /api/reports/monthly # Monthly report
GET /api/reports/class-comparison # Class comparison
GET /api/reports/low-attendance # Low attendance students# Login
curl -X POST http://localhost:8000/api/login \
-H "Content-Type: application/json" \
-d '{"email":"admin@example.com","password":"password"}'
# Get students (with token)
curl -X GET http://localhost:8000/api/students \
-H "Authorization: Bearer YOUR_TOKEN_HERE"
# Record bulk attendance
curl -X POST http://localhost:8000/api/attendances/bulk \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"date": "2024-11-17",
"students": [
{"student_id": 1, "status": "present"},
{"student_id": 2, "status": "absent", "note": "Sick"}
]
}'school-attendance-system/
βββ backend/ # Laravel backend
β βββ app/
β β βββ Console/
β β β βββ Commands/ # Artisan commands
β β βββ Events/ # Event classes
β β βββ Listeners/ # Event listeners
β β βββ Http/
β β β βββ Controllers/ # API controllers
β β β βββ Resources/ # API resources
β β βββ Models/ # Eloquent models
β β βββ Services/ # Business logic services
β βββ database/
β β βββ migrations/ # Database migrations
β β βββ seeders/ # Database seeders
β β βββ factories/ # Model factories
β βββ routes/
β β βββ api.php # API routes
β βββ tests/ # PHPUnit tests
β βββ storage/ # File storage
β
βββ frontend/ # Vue.js frontend
β βββ src/
β β βββ components/ # Vue components
β β βββ views/ # Page components
β β βββ composables/ # Composition API composables
β β βββ services/ # API services
β β βββ router/ # Vue Router
β βββ public/ # Static assets
β
βββ docker-compose.yml # Docker configuration
βββ README.md # This file
# Clear all caches
php artisan optimize:clear
# Cache configuration
php artisan config:cache
# Generate IDE helper files
php artisan ide-helper:generate
# List all routes
php artisan route:list
# List all Artisan commands
php artisan list
# Generate attendance report
php artisan attendance:generate-report 2024-11 "10"
# Manage Redis cache
php artisan attendance:cache stats
php artisan attendance:cache clear
php artisan attendance:cache warm# Development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint
# Format code
npm run format# Check Redis connection
redis-cli ping
# View all keys
redis-cli KEYS "*"
# View attendance cache keys
redis-cli -n 1 KEYS "*attendance*"
# Flush all cache
redis-cli FLUSHALL
# Monitor Redis in real-time
redis-cli MONITOR# 1. Clone and navigate
git clone <repository-url>
cd school-attendance-system
# 2. Backend setup
cd backend
composer install
cp .env.example .env
php artisan key:generate
touch database/database.sqlite
php artisan migrate:fresh --seed
# 3. Frontend setup
cd ../frontend
npm install
cp .env.example .env
# 4. Start Redis (optional)
brew services start redis # macOS
# or
sudo systemctl start redis-server # Linux
# 5. Start servers (in separate terminals)
cd backend && php artisan serve
cd frontend && npm run dev
# 6. Access application
# Frontend: http://localhost:5173
# Login: admin@example.com / password# 1. Clone and navigate
git clone <repository-url>
cd school-attendance-system
# 2. Start all services
docker-compose up -d
# 3. Run migrations and seed
docker-compose exec app php artisan migrate:fresh --seed
# 4. Access application
# Frontend: http://localhost:3000
# Backend: http://localhost:8000
# Login: admin@example.com / password# Backend (port 8000)
php artisan serve --port=8001
# Frontend (port 5173)
npm run dev -- --port=5174# Check .env configuration
cat backend/.env | grep DB_
# For SQLite, ensure file exists
touch backend/database/database.sqlite
# For MySQL, test connection
mysql -u root -p -e "SHOW DATABASES;"# Check if Redis is running
redis-cli ping
# Start Redis
brew services start redis # macOS
sudo systemctl start redis-server # Linux
# Check Redis configuration in .env
cat backend/.env | grep REDIS_# Fix storage permissions
cd backend
chmod -R 775 storage bootstrap/cache
chown -R $USER:www-data storage bootstrap/cache# Clear Composer cache
composer clear-cache
composer install
# Clear NPM cache
npm cache clean --force
rm -rf node_modules package-lock.json
npm install- API Documentation - Complete API reference
- Redis Setup - Redis configuration guide
- Artisan Commands - Custom command reference
- Events Documentation - Event system guide
- AI Workflow - AI development process
- Requirements Verification - Feature checklist
- Technical Requirements - Tech stack verification
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PSR-12 for PHP code
- Use ESLint configuration for JavaScript/Vue
- Write tests for new features
- Update documentation as needed
- Neamotullah Naim - Initial work - Your GitHub
- Laravel Framework
- Vue.js Team
- Chart.js Contributors
- Redis Team
- All open-source contributors
Made with β€οΈ using Laravel and Vue.js by Neamotullah Naim