{ "database": { "schema": "attendance_system", "source": "src-backup/attendance_system.sql", "engine": "MariaDB 10.4.32", "tables": [ { "name": "activities", "purpose": "Defines school activities/events that require attendance tracking and can be scoped to all students, specific courses, or departments.", "primary_key": "id", "important_fields": [ "name", "date", "time_in", "time_out", "required_students", "course_id", "department_id", "status" ], "relationships": [ { "column": "created_by", "references": "users.id", "on_delete": "RESTRICT" }, { "column": "course_id", "references": "courses.id", "on_delete": "SET NULL" }, { "column": "department_id", "references": "departments.id", "on_delete": "SET NULL" } ] }, { "name": "attendance", "purpose": "Records per-student participation in a given activity, capturing time-in/out, status, and notes.", "primary_key": "id", "important_fields": [ "student_id", "activity_id", "time_in", "time_out", "status" ], "relationships": [ { "column": "student_id", "references": "students.id", "on_delete": "CASCADE" }, { "column": "activity_id", "references": "activities.id", "on_delete": "CASCADE" } ] }, { "name": "attendance_logs", "purpose": "Audit trail for changes to attendance entries (time in/out, manual overrides, status changes).", "primary_key": "id", "important_fields": [ "attendance_id", "action", "old_value", "new_value", "changed_by", "changed_at" ], "relationships": [ { "column": "attendance_id", "references": "attendance.id", "on_delete": "CASCADE" }, { "column": "changed_by", "references": "users.id", "on_delete": "RESTRICT" } ] }, { "name": "attendance_records", "purpose": "Aggregated attendance summary per student/course combination when manual recording (outside activities) is needed.", "primary_key": "id", "important_fields": [ "student_id", "course_id", "status", "date_recorded", "created_by" ], "relationships": [ { "column": "student_id", "references": "students.id", "on_delete": "RESTRICT" }, { "column": "course_id", "references": "courses.id", "on_delete": "RESTRICT" }, { "column": "created_by", "references": "users.id", "on_delete": "RESTRICT" } ] }, { "name": "courses", "purpose": "Catalog of academic programs, linked to departments and used to scope activities and students.", "primary_key": "id", "important_fields": [ "code", "name", "department_id", "duration_years", "status" ], "relationships": [ { "column": "department_id", "references": "departments.id", "on_delete": "RESTRICT" } ] }, { "name": "departments", "purpose": "Defines school departments under which courses and students are organized.", "primary_key": "id", "important_fields": [ "code", "name", "school_id", "status" ], "relationships": [ { "column": "school_id", "references": "schools.id", "on_delete": "RESTRICT" } ] }, { "name": "genders", "purpose": "Lookup table for student gender classifications.", "primary_key": "id", "important_fields": [ "code", "name" ] }, { "name": "schools", "purpose": "Stores root institution profile information (name, address, contacts).", "primary_key": "id", "important_fields": [ "code", "name", "address", "contact_number", "status" ] }, { "name": "students", "purpose": "Master list of students with QR credentials, demographic data, and enrollment metadata.", "primary_key": "id", "important_fields": [ "student_id", "qr_code", "full_name", "gender_id", "year_level", "course_id", "department_id", "school_id", "status" ], "relationships": [ { "column": "gender_id", "references": "genders.id", "on_delete": "RESTRICT" }, { "column": "course_id", "references": "courses.id", "on_delete": "RESTRICT" }, { "column": "department_id", "references": "departments.id", "on_delete": "RESTRICT" }, { "column": "school_id", "references": "schools.id", "on_delete": "RESTRICT" } ] }, { "name": "system_settings", "purpose": "Key-value configuration store for system-wide toggles (branding, cutoff times, etc.).", "primary_key": "id", "important_fields": [ "setting_key", "setting_value", "description", "updated_by", "updated_at" ], "relationships": [ { "column": "updated_by", "references": "users.id", "on_delete": "SET NULL" } ] }, { "name": "users", "purpose": "System user accounts (admins/teachers) with authentication credentials and contact info.", "primary_key": "id", "important_fields": [ "username", "password", "role", "full_name", "email", "status" ] } ] }, "systems": [ { "name": "Admin Panel", "path": "src-backup/admin", "purpose": "Web dashboard for managing students, activities, users, and attendance reports.", "entry_points": [ "dashboard.php", "manage_students.php", "manage_activities.php", "attendance.php", "users.php", "reports.php" ], "primary_tables": [ "students", "activities", "attendance", "users" ], "dependencies": [ "auth/login.php", "includes/database.php", "includes/auth.php" ] }, { "name": "Public Portal", "path": "src-backup/index.php", "purpose": "Front-facing landing/entry page that ties into assets/ for styling and qr/ for QR workflows.", "primary_tables": [ "students", "attendance", "activities" ], "dependencies": [ "assets/css|js", "auth/login.php", "api/*" ] }, { "name": "API Endpoints", "path": "src-backup/api", "purpose": "AJAX-style endpoints for scanning QR codes, manual attendance entry, and fetching reference data.", "key_scripts": [ "scan_qr.php", "manual_entry.php", "get_courses.php", "get_departments.php", "export_activities.php", "export_reports.php" ], "primary_tables": [ "students", "attendance", "activities", "courses", "departments" ], "dependencies": [ "includes/database.php", "includes/config.php" ] }, { "name": "Authentication", "path": "src-backup/auth", "purpose": "Session handling (login/logout) that protects admin and API surfaces.", "key_scripts": [ "login.php", "logout.php" ], "primary_tables": [ "users" ], "dependencies": [ "includes/auth.php", "includes/database.php" ] }, { "name": "Shared Includes", "path": "src-backup/includes", "purpose": "Reusable bootstrap/config files (database connector, auth helper, headers/footers, QR library).", "key_scripts": [ "database.php", "config.php", "auth.php", "header.php", "footer.php" ], "primary_tables": [ "users", "students", "activities" ] }, { "name": "QR Utilities", "path": "src-backup/qr", "purpose": "Handles QR code generation, printing, and cleanup jobs tied to student credentials.", "key_scripts": [ "generate.php", "print.php", "cleanup_qrcodes.php", "simple_cleanup.php" ], "primary_tables": [ "students" ], "dependencies": [ "includes/phpqrcode", "assets/image" ] }, { "name": "Reporting", "path": "src-backup/reports", "purpose": "Generates printable reports for attendance summaries and student listings.", "key_scripts": [ "print_report.php", "students_report.php" ], "primary_tables": [ "attendance", "students", "activities", "courses" ] }, { "name": "Assets", "path": "src-backup/assets", "purpose": "Static resources (CSS/JS/images) shared by public and admin interfaces.", "subdirectories": [ "css", "js", "image" ] }, { "name": "Setup & Diagnostics", "path": "src-backup/setup.php | src-backup/test_connection.php | src-backup/test_db.php", "purpose": "Environment bootstrap scripts used to verify database connectivity and initial configuration.", "primary_tables": [ "system_settings", "users" ] }, { "name": "Exports", "path": "src-backup/exports", "purpose": "Designated output directory (currently empty) where generated CSV/PDF exports are saved by API/export scripts." } ] }