docs: update backend readme

This commit is contained in:
mwpn
2026-03-05 14:45:01 +07:00
parent b4fda6b9c9
commit cea6b06638

143
README.md
View File

@@ -1,69 +1,120 @@
# CodeIgniter 4 Application Starter # SMAN 1 Garut Backend Presensi Siswa
## What is CodeIgniter? Backend presensi siswa berbasis **CodeIgniter 4** untuk:
CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. - Presensi masuk/pulang & permapel (QR).
More information can be found at the [official site](https://codeigniter.com). - Zona lokasi (geofence) & pengaturan jam masuk/pulang.
- Akun mobile siswa (NISN + PIN).
- Portal orang tua & poin pelanggaran.
- Integrasi foto formal + verifikasi wajah (via service AI eksternal).
This repository holds a composer-installable app starter. Backend ini biasanya dipakai bersama:
It has been built from the - Frontend mobile: folder `../mobile` (repo terpisah).
[development repository](https://github.com/codeigniter4/CodeIgniter4). - Face embedding service: folder `../face-service` (FastAPI + InsightFace).
More information about the plans for version 4 can be found in [CodeIgniter 4](https://forum.codeigniter.com/forumdisplay.php?fid=28) on the forums. ## 1. Kebutuhan Server
You can read the [user guide](https://codeigniter.com/user_guide/) - PHP **8.2+** dengan ekstensi:
corresponding to the latest version of the framework. - `intl`, `mbstring`, `json`, `curl`, `gd`, `mysqli`/`mysqlnd`.
- MySQL/MariaDB.
- Composer.
## Installation & updates ## 2. Setup Cepat (Development)
`composer create-project codeigniter4/appstarter` then `composer update` whenever Di folder `backend`:
there is a new release of the framework.
When updating, check the release notes to see if there are any changes you might need to apply ```bash
to your `app` folder. The affected files can be copied or merged from composer install
`vendor/codeigniter4/framework/app`. cp env .env # atau copy manual
```
## Setup Edit `.env`:
Copy `env` to `.env` and tailor for your app, specifically the baseURL ```ini
and any database settings. app.baseURL = 'http://localhost/sman1/backend/public/'
## Important Change with index.php database.default.hostname = localhost
database.default.database = absen_sman1
database.default.username = root
database.default.password = your_password
`index.php` is no longer in the root of the project! It has been moved inside the *public* folder, telegram.bot_token = your_telegram_bot_token
for better security and separation of components. telegram_bot_token = your_telegram_bot_token
This means that you should configure your web server to "point" to your project's *public* folder, and FACE_SERVICE_URL = 'http://localhost:5000'
not to the project root. A better practice would be to configure a virtual host to point there. A poor practice would be to point your web server to the project root and expect to enter *public/...*, as the rest of your logic and the FACE_EMBEDDING_DIM = 512
framework are exposed. FACE_SIM_THRESHOLD = 0.85
FACE_MIN_SIZE = 80
FACE_MIN_BLUR = 30
FACE_MIN_BRIGHTNESS = 0.2
```
**Please** read the user guide for a better explanation of how CI4 works! Jalankan migration & seeder yang diperlukan:
## Repository Management ```bash
php spark migrate --all
php spark db:seed DeviceSeeder
php spark db:seed StudentMobileAccountsSeeder # opsional untuk dummy data
```
We use GitHub issues, in our main repository, to track **BUGS** and to track approved **DEVELOPMENT** work packages. Jalankan server dev:
We use our [forum](http://forum.codeigniter.com) to provide SUPPORT and to discuss
FEATURE REQUESTS.
This repository is a "distribution" one, built by our release preparation script. ```bash
Problems with it can be raised on our forum, or as issues in the main repository. php spark serve
```
## Server Requirements Lalu akses:
PHP version 8.2 or higher is required, with the following extensions installed: - Dashboard: `http://localhost:8080` atau `http://localhost/sman1/backend/public` (sesuai web server).
- API mobile: `http://localhost/sman1/backend/public/api/mobile/...`.
- [intl](http://php.net/manual/en/intl.requirements.php) ## 3. Modul Utama
- [mbstring](http://php.net/manual/en/mbstring.installation.php)
> [!WARNING] - `Modules/Academic` kelas, mapel, guru, jadwal, siswa, Dapodik.
> - The end of life date for PHP 7.4 was November 28, 2022. - `Modules/Attendance` checkin device, checkin QR mapel, laporan, `student_faces` + verifikasi wajah.
> - The end of life date for PHP 8.0 was November 26, 2023. - `Modules/Mobile` API mobile (login NISN+PIN, registrasi PIN, checkinqr, checkinmasukpulang, status hari ini).
> - The end of life date for PHP 8.1 was December 31, 2025. - `Modules/Devices` device absen, autentikasi device (code + api_key).
> - If you are still using below PHP 8.2, you should upgrade immediately. - `Modules/Dashboard` halaman dashboard + pengaturan presensi (zona + jam masuk/pulang).
> - The end of life date for PHP 8.2 will be December 31, 2026. - `Modules/Parent` portal orang tua (riwayat presensi & pelanggaran).
- `Modules/Discipline` kategori pelanggaran, poin, rekap siswa.
- `Modules/Notification` integrasi Telegram.
- `Modules/Face` penyimpanan embedding wajah (`student_faces`) + endpoint import/enroll.
Additionally, make sure that the following extensions are enabled in your PHP: Struktur detail endpoint dan flow presensi dijelaskan di:
- json (enabled by default - don't turn it off) - `docs/SETUP_PRESENSI.md` (jika ada).
- [mysqlnd](http://php.net/manual/en/mysqlnd.install.php) if you plan to use MySQL - `docs/SYNC_FOTO_WAJAH.md` cara sync foto formal dari Google Drive + face hash.
- [libcurl](http://php.net/manual/en/curl.requirements.php) if you plan to use the HTTP\CURLRequest library
## 4. Integrasi Face Embedding Service
Backend **tidak menghitung embedding wajah sendiri**, tapi memanggil service eksternal (lihat folder `../face-service`):
- Service Python (`FACE_SERVICE_URL`) menyediakan endpoint:
- `POST /embed` → menerima file gambar, mengembalikan:
- `embedding` float[],
- `faces_count`, `face_size`, `blur`, `brightness`, `quality_score`.
- `App\Modules\Face\Services\FaceService`:
- `extractEmbeddingWithQuality()` → kirim gambar ke `/embed`, terapkan quality gate.
- `cosineSimilarity()` → untuk matching saat verifyface.
### Alur singkat
1. **Import foto formal** (admin):
`POST /api/face/import-formal` → ambil foto dari URL (Google Drive/hasil sync) → simpan embedding `source='formal'` ke `student_faces`.
2. **Enroll live** (siswa, 35 frame):
`POST /api/face/enroll-live` → simpan beberapa embedding `source='live'` + satu `live_avg`.
3. **Verifikasi saat presensi**:
`POST /api/attendance/verify-face` → bandingkan embedding probe dengan semua embedding siswa → kembalikan `similarity`, `matched_source`, `status (match/no_match)`.
## 5. Catatan Git & Deployment
- File yang **tidak** ikut repo (lihat `.gitignore`):
- `.env`, `writable/*`, `vendor/`, direktori IDE, dll.
- Untuk produksi:
- Pastikan PHP 8.2+, ekstensi lengkap, dan baseURL `.env` sudah sesuai domain sekolah.
- Jalankan `php spark migrate --all` di server.
- Jalankan faceservice Python di host/port yang sama dengan `FACE_SERVICE_URL` di `.env`.
---
Kalau develop bareng frontend mobile, lihat juga `../mobile/README.md` untuk cara run klien presensi di HP/device.