How thejuanjo1/bethlemitas works
1. This is a Laravel 11-style monolith for school/student support management, centered on academic administration, teacher workflows, psychoorientation, and PIAR case tracking. The app is server-rendered with Blade views, Eloquent models, and standard Laravel routing/controllers.
2. The repository is organized around role-based access rather than feature microservices. Middleware such as RoleMiddleware, RoleDocenteMiddleware, RolePsicoorientadorMiddleware, and the combined role middleware gate access to different areas of the system. This is the main architectural boundary between user types.
3. The core domain is educational structure management: degrees, periods, areas, groups, institution, and the assignment of teachers/students to those structures. The corresponding controllers in app/Http/Controllers and models like Degree, Group, Area, Period, Institution, and the Users_load_* / Teachers_areas_groups tables define the academic organizational layer.
4. User management is a separate subsystem from the academic structure. AcademicUserService and the StoreUserRequest / UpdateUserRequest classes suggest a dedicated workflow for creating and editing academic users, likely with validation and role assignment. The presence of config/permission.php and the permission_tables migration indicates role/permission management via a package such as Spatie Permission.
5. The student support workflow is driven by referrals and psychoorientation records. Referral, Psychoorientation, and related controllers (CreateReferralController, PsicoController) indicate a process where teachers or staff report a student, psychoorientation staff review it, and the case is tracked through status/state changes. Models like State, Users_student, and Student_characteristics support that lifecycle.
6. PIAR is the most specialized subsystem in the repo. It has its own models, migrations, controllers, and views: Piar, PiarMinute, PiarCharacteristic, PiarAdjustment, PiarReport/Annual_Report, Agreement, Recommendation, Strategies, and Dua. This suggests a formal multi-step intervention plan with meetings, observations, adjustments, recommendations, and periodic evaluations.
7. The PIAR workflow is period-based and document-heavy. There are dedicated Blade templates for periodo1, periodo2, periodo3, evaluation, editing adjustments, and PDFs, implying the app generates structured outputs for each review cycle. The public/piars directory and resources/views/pdf/* templates show that generated documents are stored and served as downloadable files.
8. Communication is integrated through email and notifications. AcceptStudentMail, CreatedReferralMail, and StudentInPiarNotification show asynchronous user-facing events tied to the support workflow. A notifications table migration exists, so the app persists notification history rather than relying only on transient mail delivery.
9. The presentation layer is split by audience: resources/views/academic, teacher, psycho, piar, profile, and auth. This mirrors the role boundaries and keeps each user journey isolated in the UI, with shared layout shells in resources/views/layout* and reusable email/PDF templates.
10. Client-side behavior is lightweight and targeted. The project uses resources/js plus a set of page-specific scripts in public/scripts for form interactions like user creation, area/degree/group management, and student acceptance. Styling is handled with Vite/Tailwind and custom CSS assets.
11. Persistence is centered on a relational database with many domain tables and join tables. The migrations show a normalized schema with reference data, user-to-structure assignments, referral/psychoorientation records, and PIAR-specific artifacts. This is the main data backbone of the system.
12. File storage is part of the architecture, not just an implementation detail. Profile images and PIAR-related PDFs are stored under public/Imagenes_Perfil and public/piars, while Laravel’s storage directories handle generated and internal files. This means documents are both produced and served by the application.
13. The routing entry point is conventional Laravel: web routes dispatch to controllers, which orchestrate validation, persistence, email/notification side effects, and view rendering. There is no sign of a separate API-first architecture; the system is primarily server-rendered with form submissions and document generation.
14. In diagram terms, the main containers are: authentication/authorization, academic administration, teacher referral handling, psychoorientation case management, PIAR case lifecycle, and document/notification output. The central database connects all of them, with email and file storage as the main external dependencies.
Main entry points: PiarController.php PIAR ctrl · web.php Web routes · CreateReferralController.php Referral ctrl · RoleMiddleware.php Role middleware
Components 19
Access & roles
Authentication, authorization, and role gates for the app
- Auth · Login and password flows
app/Http/Controllers/auth/AuthController.php - Role middleware · Role-based access gates for docent, psychoorientador, and combined access
app/Http/Middleware/RoleMiddleware.php
Academic admin
School structure and user administration
- User service · Creates and updates academic users with role-aware workflow
app/Services/AcademicUserService.php - Academic controllers · Area, degree, group, and user administration controllers
app/Http/Controllers/CreateAreaController.php - User requests · Validation for creating and editing academic users
app/Http/Requests/Academic/StoreUserRequest.php - Academic models · Institution, degrees, areas, groups, and assignment tables
app/Models/Degree.php
Support workflows
Referral, psychoorientation, and teacher-facing case handling
- Referral ctrl · Creates and routes student referrals into support workflows
app/Http/Controllers/CreateReferralController.php - Psycho ctrl · Psychoorientation case review and student history handling
app/Http/Controllers/PsicoController.php - Support models · Referral, psychoorientation, state, and student support records
app/Models/Referral.php - Teacher UI · Teacher-facing referral, minutes, and student list screens
resources/views/teacher/studentReferral.blade.php
PIAR lifecycle
PIAR case management, periods, minutes, adjustments, and reports
- PIAR ctrl · Orchestrates PIAR case creation, editing, and reporting
app/Http/Controllers/PiarController.php - PIAR models · PIAR, minutes, characteristics, adjustments, agreements, and reports
app/Models/Piar.php - PIAR views · Period-based PIAR screens and PDF templates
resources/views/piar/create.blade.php
Documents & delivery
Email, notifications, PDFs, and stored artifacts
- PDF templates · Printable PIAR and history documents
resources/views/pdf/piar.blade.php - Mail templates · Referral and student acceptance email content
resources/views/emails/createdReferral.blade.php - Notifications · Persistent notification events for support workflows
app/Notifications/StudentInPiarNotification.php - File storage · Public PIAR PDFs and profile image storage
public/piars
Other components
- Web routes · Laravel web entrypoint that dispatches requests to controllers
routes/web.php - Database · Shared relational persistence for users, structure, referrals, and PIAR data
database/migrations/2024_10_01_155113_create_degrees_table.php
Connections 31
- Web routes → Auth: auth routes · Routes hand login and password flows to the auth controller
- Web routes → Role middleware: protected routes · Web routes are filtered through role middleware
- Web routes → Academic controllers: admin routes · Academic administration screens are routed to controllers
- Web routes → Referral ctrl: teacher routes · Teacher referral actions are routed here
- Web routes → Psycho ctrl: psycho routes · Psychoorientation screens are routed here
- Web routes → PIAR ctrl: piar routes · PIAR screens and actions are routed here
- Role middleware → Academic controllers: gate · Role checks protect administration areas
- Role middleware → Referral ctrl: gate · Teachers and staff must pass role checks
- Role middleware → Psycho ctrl: gate · Psychoorientation areas are role-restricted
- Role middleware → PIAR ctrl: gate · PIAR operations are role-restricted
- Academic controllers → User service: uses · Controllers delegate user workflows to the service
- Academic controllers → User requests: validates · User creation and update requests are validated here
- Academic controllers → Academic models: persists · Academic structure controllers operate on domain models
- User service → Database: stores · User and role updates are persisted in the database
- User requests → Database: reads rules · Validation is informed by existing records and constraints
- Referral ctrl → Support models: creates · Referrals and related records are written to support models
- Referral ctrl → Mail templates: sends · New referrals trigger email notifications
- Referral ctrl → Notifications: notifies · Referral events are persisted as notifications
- Referral ctrl → Teacher UI: renders · Teacher screens are rendered from referral actions
- Psycho ctrl → Support models: updates · Psychoorientation reviews update case and state records
- Psycho ctrl → Notifications: notifies · Support case status changes create notifications
- Psycho ctrl → Teacher UI: shares · Teacher-facing history and case views overlap with psycho workflows
- PIAR ctrl → PIAR models: manages · PIAR controller coordinates the PIAR domain objects
- PIAR ctrl → PIAR views: renders · PIAR pages are served through dedicated Blade views
- PIAR ctrl → PDF templates: exports · PIAR outputs are generated as printable PDFs
- PIAR ctrl → File storage: stores files · Generated PIAR documents are saved under public storage
- PIAR ctrl → Notifications: notifies · PIAR milestones can trigger student notifications
- PIAR models → Database: persisted in · PIAR entities are backed by relational tables
- Support models → Database: persisted in · Referral and psychoorientation data are stored in relational tables
- Academic models → Database: persisted in · Academic structure and assignment tables live in the database
- Mail templates → File storage: attachments · Documents and generated assets are served from file storage