Goralys is a lightweight web app to manage "Grand Oral" topics for students and teachers at a high school.
- Student/teacher/admin roles with automatic role detection at registration (
AuthController::register). - Two-topic student workflow: draft, submit, and read-only once submitted (
useSubjects,SubjectsController). - Session-backed user data caching for fast frontend rendering (
AuthController::loginmanages session data). - CSRF protection using a short-lived session token:
CSRFService+fetchCsrfClient. - Toast notification system used by both PHP and Next.js (
ToastController::showToastandtoast-provider.tsx).
Prerequisites:
- PHP 8.1+ with mysqli
- Composer (for PHPMailer)
- pnpm package manager
To simulate a local PHP server with mysql on Windows, you can use XAMPP (also available on Linux and macOS)
(Optional):
- PHP_CodeSniffer
- PHP ruleset for PSR-12 convention
Steps:
- Run setup script:
Or if you use Linux:
.\setup.bat./setup.sh
- Configure environment:
- For development, modify the values inside .env (created using setup.bat)
- Database:
- Create the database and tables using the schema at backend/data_structure.sql.
- Run dev server:
- Run Next and PHP's built-in server for the API, by default the next rewrite port for the API is 80:
pnpm run dev php -S localhost:80
- Run Next and PHP's built-in server for the API, by default the next rewrite port for the API is 80:
- Access the app:
- Visit
http://localhost/goralys/(orhttp://localhost:8000if using built-in server).
- Visit
You can use phpunit to run the unit tests for the backend in backend/tests.
To run the tests, use the following command after installing the projects dependencies with composer:
.\backend\vendor\bin\phpunit --configuration backend\phpunit.xml- CSRF:
- Token validated by
CSRFService::validate.
- Token validated by
- Passwords:
- Passwords are hashed using PHP's
password_hash(RegisterService::register) and verified withpassword_verify(LoginService::login).
- Passwords are hashed using PHP's
- Sensitive config:
- You must use
.envto configure your project.
- You must use
Note: the develop branch serves as a pre-production playground, so some commits may include experimental or buggy code — I try to minimize this as much as possible.
- Main Kernel (Initialization & Routing):
GoralysKernel - Authentication & Sessions:
AuthController - Subjects Management:
SubjectsController - Database schema: backend/data_structure.sql
- Frontend Subject logic:
useSubjectshook - Toast notification:
ToastControllerandtoast-provider.tsx - CSRF Service:
CSRFService
app/: Contains the application pages and logic.app/subject/: Student, Teacher, and Admin dashboards.app/hooks/: React hooks for data fetching and state management.app/ui/: Reusable UI components.
backend/API/: API endpoints, acting as entry points for the kernel.backend/src/Kernel/: The core of the backend, handles initialization and request management.backend/src/App/: Controllers and application-level services.backend/src/Core/: Business logic and core domain services.backend/src/Platform/: Low-level platform services (DB, Logger, Loader).backend/tests/: Unit and integration tests.
This project is under an MIT license (see: LICENSE).
All contributions are welcome as long as they respect the terms inside Contributing.
Any pull request containing sensitive information inside .env will have no chance to be merged.