# Smart School – Step-by-Step Build Sequence
## Each module follows: Migrations → Model → Controller → Routes → Views → Tests

Legend: **DB** = migration+model, **CRUD** = create/read/update/delete, **List** = index listing, **Delete** = destroy

---

## PHASE 1 – Setup, Auth & Core

### Step 1.1 Project Setup
- Create Laravel 11 project in current directory
- Configure `.env` (DB, app name)
- Install Laravel Breeze (Blade stack) for auth
- Install Bootstrap 5 + admin layout (sidebar with all module menus)
- Install Chart.js for dashboard

### Step 1.2 Roles & RBAC
- **DB**: `roles` table + seed (Super Admin, Admin, Accountant, Teacher, Receptionist, Librarian, Parent, Student)
- **DB**: add `role_id`, `photo`, `address`, `phone`, `gender` to `users`
- Create `RoleMiddleware`, `HasRoles` trait, `can:module.action` permission checks
- **DB**: `permissions` + `role_permissions` tables (optional granular RBAC)
- Seed: default Super Admin user + sample admin/teacher/parent/student accounts

### Step 1.3 Authentication
- Login (Breeze) with `role` column
- Register disabled (only admin creates users)
- **DB**: `password_reset_tokens`, sessions (Breeze default)
- Logout, remember me

### Step 1.4 Profile Module
- **CRUD**: Profile (update name, email, photo, phone, address, gender)
- Change password (old password verification)
- Profile photo upload (Storage)

### Step 1.5 General Settings
- **DB**: `settings` table (school_name, tagline, address, phone, email, logo, favicon, currency, currency_symbol, session/year, footer_text, timezone)
- **CRUD**: Settings page (admin) – read/write all keys
- Apply settings globally via a `Setting` helper / config cache

### Step 1.6 Dashboard
- Role-based dashboard
- Admin: charts (students, fees collected vs due, attendance %, recent notices, student distribution)
- Teacher: my classes, today's timetable, today's attendance
- Parent/Student: notices, fees due, results summary
- Accountant: today's collections, balance fees
- Librarian: books issued, overdue

### Step 1.7 Custom Fields
- **DB**: `custom_fields` (form_name, label, type, options, is_required, status)
- **CRUD**: Custom Fields (add to student form dynamically)
- Render dynamic fields in admission form + save into `custom_field_values`

### Step 1.8 Multi-User Management
- **CRUD**: Admin manages users (students, teachers, parents, staff accounts)
- **List**: all users with search/filter by role, status
- **Delete**: deactivate/delete user (soft-delete safer)
- User create assigns role + login credentials + email notification

---

## PHASE 2 – Academic Structure

### Step 2.1 Classes Module
- **DB**: `classes` (name, numeric_value, status)
- **CRUD**: Class list, create class, edit class, delete class
- **Delete**: prevent delete if students exist

### Step 2.2 Sections Module
- **DB**: `sections` (class_id, name, room_no, capacity)
- **CRUD**: Section list (filter by class), create, edit, delete

### Step 2.3 Subjects Module
- **DB**: `subjects` (name, code, type, status)
- **CRUD**: Subject list, create, edit, delete

### Step 2.4 Staff / Teachers Module
- **DB**: `staff` (user_id, staff_no, department, designation, qualification, dob, joining_date, contract_type, salary, documents)
- **CRUD**: Staff list, create staff, edit staff, delete staff
- **List**: filter by designation/department
- Staff creates linked `users` account (role=Teacher)

### Step 2.5 Assign Subjects
- **DB**: `assign_subjects` (class_id, section_id, subject_id, teacher_id, group)
- **CRUD**: Assign subject to class/section/teacher; list per class-section

### Step 2.6 Class Timetable
- **DB**: `class_timetable` (class_id, section_id, day, period_no, start_time, end_time, subject_id, teacher_id, room_no)
- **CRUD**: Build timetable per class-section (grid: days × periods)
- View: class-section timetable, teacher-wise timetable, student view

---

## PHASE 3 – Students

### Step 3.1 Student Admission
- **DB**: `students` (40+ fields):
  - Personal: first_name, last_name, gender, dob, blood_group, religion, caste, nationality, photo
  - Contact: email, mobile, phone, current_address, permanent_address
  - Admission: admission_no, roll_no, admission_date, class_id, section_id, category_id, session, RTE, parent info (father/mother/guardian name, occupation, income, phone, email)
  - Previous school: previous_school, previous_class, last_exam_result, transferred_from
  - IDs: aadhar_no, udise_no, birth_certificate_no, samagra_id
- **DB**: `student_documents` (student_id, title, doc_type, file)
- **DB**: `student_siblings` (student_id, sibling_student_id)
- **CRUD**: Admission form (large, tabbed), edit student, delete student
- **List**: Student list with filters (class, section, category, search)

### Step 3.2 Student Search
- Search by admission no, roll no, name, class, section, category, father name, phone, status
- **List**: results grid, click → profile

### Step 3.3 Student Profile (360°)
- Tabs: Overview, Personal, Contact, Admission, Fees, Exams, Attendance, Documents, Previous School, Siblings
- Upload/view documents per student

### Step 3.4 Promote Students
- **DB**: `student_promotions` (student_id, from_class, to_class, from_session, to_session, status, is_leaving)
- **CRUD**: Select class-section → list students → mark pass/fail/continue/leave → promote to next class & session
- Leaving: mark leaver, date of leaving, generate TC

### Step 3.5 Student Categories
- **DB**: `student_categories` (name, description, status)
- **CRUD**: Category list, create, edit, delete

### Step 3.6 Student CV
- Generate printable CV per student (profile summary + documents)

### Step 3.7 Student TC (Transfer Certificate)
- Generate TC with leaving details, generate PDF/print, issue record

---

## PHASE 4 – Attendance

### Step 4.1 Attendance Entry
- **DB**: `attendances` (student_id, class_id, section_id, date, status[P/A/L/H], remark)
- **CRUD**: Mark attendance: select class-section + date → grid of students → save
- Bulk mark present/absent/half/leave
- Prevent duplicate entry for same date (update instead)

### Step 4.2 Attendance Report
- Monthly class-section-wise report
- Per-student report (working days, present, absent, %)
- Export CSV/Print
- Parent/Student view own attendance

---

## PHASE 5 – Examinations

### Step 5.1 Exam Setup
- **DB**: `exams` (name, exam_type, session, from_date, to_date, description, status)
- **CRUD**: Exam list, create, edit, delete

### Step 5.2 Exam Schedule
- **DB**: `exam_schedules` (exam_id, class_id, section_id, subject_id, date, start_time, end_time, room_no, full_marks, pass_marks)
- **CRUD**: Schedule list, create (bulk per class), edit, delete
- **List**: exam-wise timetable view

### Step 5.3 Grades Config
- **DB**: `exam_grades` (grade, min_percent, max_percent, point, remarks)
- **CRUD**: Grade list, create, edit, delete

### Step 5.4 Marks Register / Entry
- **DB**: `exam_marks` (exam_schedule_id, student_id, marks_obtained, grade, remark)
- **CRUD**: Select exam + class-section + subject → marks grid per student → save
- Auto-grade from percentages

### Step 5.5 Progress Report
- Generate per-student progress report (subject-wise marks, % , grade, rank)
- Print/PDF
- Parent/Student view own results

---

## PHASE 6 – Fees & Finance

### Step 6.1 Fee Types
- **DB**: `fees_types` (name, description, status)
- **CRUD**: Fee type list, create, edit, delete

### Step 6.2 Fee Groups
- **DB**: `fees_groups` (name, description, status)
- **CRUD**: Fee group list, create, edit, delete

### Step 6.3 Fee Masters
- **DB**: `fees_masters` (fees_type_id, class_id, fees_group_id, amount, due_date, fine_amount, fine_type)
- **CRUD**: Fee master list (filter by class), create, edit, delete

### Step 6.4 Discounts
- **DB**: `discounts` (name, code, type[fixed/%], amount, description, status)
- **CRUD**: Discount list, create, edit, delete

### Step 6.5 Fee & Discount Allotment
- **DB**: `fees_assign` (student_id, fees_master_id, due_date, status)
- **DB**: `discount_assign` (student_id, discount_id)
- **CRUD**: Assign fees to students (by class, section, category, group, or single student – 5+ criteria)
- Assign discounts by same criteria

### Step 6.6 Free-hand Fees
- Add ad-hoc / free-hand fee entry for a student (amount, head, date, remark)

### Step 6.7 Fee Collection
- **DB**: `fees_payments` (student_id, fees_master_id, amount_paid, discount_applied, fine_applied, date, payment_method, transaction_id, received_by)
- **DB**: `fees_receipts` (receipt_no, student_id, total, date, status)
- **CRUD**: Collection page: search student → show dues → select fees to pay → apply fine/discount → generate receipt (printable)
- Payment methods: Cash, Card, Bank, Cheque, Online

### Step 6.8 Fee Reports
- Student fee statement (paid/due/fine/discount)
- Transaction report (date range, method)
- Balance fee report (who owes what)
- Collection summary (per day/month/class)
- **List + print/CSV export**

### Step 6.9 Income & Expense
- **DB**: `income_heads`, `expense_heads` (name, status)
- **DB**: `incomes` (head_id, amount, date, receipt_no, description, attachment)
- **DB**: `expenses` (head_id, amount, date, voucher_no, description, attachment)
- **CRUD**: Heads list; Income entry, expense entry; income/expense report (head-wise)

---

## PHASE 7 – Content & Communication

### Step 7.1 Download Center
- **DB**: `downloads` (title, description, file, class_id, session, type[syllabus/assignment/study-material])
- **DB**: `download_users` (download_id, user/role target)
- **CRUD**: Upload download, target class/roles, delete
- **List**: Teachers/Students/Parents see and download files

### Step 7.2 Library
- **DB**: `library_books` (title, author, isbn, publisher, quantity, available, shelf_no, status)
- **DB**: `library_members` (member type: student/staff, ref_id)
- **DB**: `book_issues` (book_id, member_id, issue_date, due_date, return_date, fine, status)
- **CRUD**: Book list, create, edit, delete; Members; Issue book, return book, overdue list, fine

### Step 7.3 Notice Board
- **DB**: `notices` (title, description, notice_date, file, status)
- **DB**: `notice_users` (notice_id, user_type/role or all)
- **CRUD**: Create notice, target students/parents/teachers/all, edit, delete, publish/unpublish
- **List**: Notice list per user role (dashboard + dedicated page)

---

## PHASE 8 – Infrastructure

### Step 8.1 Transport
- **DB**: `transport_vehicles` (vehicle_no, vehicle_type, capacity, driver_name, driver_phone, status)
- **DB**: `transport_routes` (route_name, vehicle_id, fare, description, status)
- **DB**: `transport_assign` (student_id, route_id, stop_name, pickup_time)
- **CRUD**: Vehicles, Routes; assign student to route
- **List**: Route-wise students, vehicle list, driver details

### Step 8.2 Hostel
- **DB**: `room_types` (name, description)
- **DB**: `hostel_rooms` (room_type_id, room_no, capacity, rent, description, status)
- **DB**: `hostel_assign` (student_id, room_id, check_in, check_out, status)
- **CRUD**: Room types, Rooms; assign/unassign students

---

## PHASE 9 – Reports & Docs

### Step 9.1 Reports Center
- Student list (class/section/category wise) – print/CSV
- Fee statement, transaction, balance fee, collection summary
- Attendance monthly report
- Exam result / progress report
- Income-Expense statement
- Library issue report
- Promote/leaving list

### Step 9.2 PDF / Print Generation
- Use `dompdf` (barryvdh) for TC, CV, receipts, progress reports, fee statements
- Print-friendly CSS views

---

## PHASE 10 – Data & Polish

### Step 10.1 Seeders
- Settings, roles, permissions, admin user
- Sample classes/sections/subjects/teachers
- Sample students/parents (with users)
- Sample fees structure, notices, books, vehicles, rooms, exams

### Step 10.2 Validation & Security
- Form Request validation on all modules
- CSRF, XSS escaping, mass-assignment protection
- File upload validation + mime checks
- Auth middleware on all routes + role checks

### Step 10.3 Testing
- Feature tests: auth, RBAC, student CRUD, fee collection, attendance, marks
- PHPUnit run green

### Step 10.4 Final Polish
- Notifications on role actions (optional Mail)
- Pagination everywhere, sorting, search filters
- Responsive admin UI
- `php artisan optimize`, README with setup steps

---

## Global Checklist – Every Module Must Have
- [ ] Migration + Model with relationships
- [ ] Index/List view with search, pagination, filters
- [ ] Create form with validation (Form Request)
- [ ] Edit form
- [ ] Delete (soft delete where needed) with confirmation
- [ ] Routes (web.php) with role middleware
- [ ] Sidebar menu entry (role visible only)
- [ ] Reports/PDF where applicable
- [ ] Seeder data (sample)
- [ ] Feature test
