REST API untuk aplikasi E-Presensi siswa SMK dengan Go, Fiber Framework dan MongoDB Atlas
Sebuah REST API untuk sistem presensi siswa SMK yang menggunakan teknologi GPS untuk validasi lokasi. Project ini mengimplementasikan sistem absensi modern dengan fitur keamanan mobile dan validasi lokasi berbasis GPS.
REST API untuk sistem E-Presensi siswa SMK yang menyediakan:
- Sistem Autentikasi Siswa - Registrasi dan login dengan data siswa (NIS, Kelas, Jurusan)
- Absensi Berbasis GPS - Check-in/out dengan validasi lokasi
- Validasi Lokasi Real-time - Hanya bisa absen dalam radius sekolah
- Keamanan Mobile - Security untuk aplikasi mobile
- Riwayat Kehadiran - History dan statistik kehadiran siswa
Teknologi yang dipelajari:
- Go (Golang) - Bahasa pemrograman utama
- Fiber Framework - Web framework yang cepat dan minimalis
- MongoDB Atlas - Database NoSQL cloud
- JWT Authentication - Sistem autentikasi berbasis token
- GPS Navigation - Validasi lokasi dengan Haversine formula
- Mobile Security - Implementasi keamanan perangkat mobile
- Docker - Containerization dan deployment
- Health Check - Status kesehatan API
- User Registration - Pendaftaran siswa baru (NIS, Kelas, Jurusan)
- User Login - Masuk dengan email dan password
- API Documentation - Dokumentasi endpoint yang tersedia
- User Profile - Melihat dan mengubah profil siswa
- Change Password - Mengganti password
- Account Deactivation - Menonaktifkan akun
- Logout & Token Refresh - Manajemen sesi
- Check-in - Absen masuk dengan validasi GPS
- Check-out - Absen keluar dengan validasi GPS
- Today's Attendance - Lihat absensi hari ini
- Attendance History - Riwayat kehadiran dengan pagination
- Attendance Stats - Statistik kehadiran (hadir, terlambat, tidak hadir)
- GPS Location Validation - Validasi lokasi dalam radius sekolah
- Mobile Device Security - Keamanan untuk aplikasi mobile
- Haversine Distance Calculation - Perhitungan jarak GPS yang akurat
- Indonesia Territory Validation - Validasi lokasi dalam wilayah Indonesia
- Get All Users - Endpoint untuk testing (opsional auth)
| Teknologi | Versi | Kegunaan |
|---|---|---|
| Go | 1.23.3 | Backend Language |
| Fiber | v2.52.8 | Web Framework |
| MongoDB | Atlas | Database |
| JWT | v5.2.2 | Authentication |
| Docker | Latest | Containerization |
| Validator | v10.26.0 | Input Validation |
| Bcrypt | Latest | Password Hashing |
go-fiber-auth-api/
βββ cmd/
β βββ main.go # Entry point aplikasi
βββ internal/
β βββ config/
β β βββ config.go # Konfigurasi aplikasi & GPS
β βββ controllers/
β β βββ auth.go # Controller autentikasi
β β βββ attendance.go # Controller absensi GPS
β β βββ health.go # Controller health check
β β βββ user.go # Controller user management
β βββ middleware/
β β βββ auth.go # Middleware JWT
β β βββ location.go # Middleware validasi GPS
β βββ models/
β β βββ attendance.go # Model absensi dan lokasi
β β βββ user.go # Model dan struct user
β βββ routes/
β β βββ routes.go # Definisi routing
β βββ services/
β β βββ attendance.go # Service absensi GPS
β β βββ auth.go # Service autentikasi
β β βββ user.go # Service user management
β βββ utils/
β βββ hash.go # Utility hashing
β βββ jwt.go # Utility JWT
β βββ mobile.go # Utility GPS & mobile
β βββ response.go # Utility response
β βββ sanitize.go # Utility sanitization
β βββ validation.go # Utility validation
βββ pkg/
β βββ database/
β βββ mongodb.go # Koneksi MongoDB
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Docker Compose setup
βββ .env # Environment variables
βββ go.mod # Go modules
βββ go.sum # Go dependencies
git clone https://github.com/SideeID/go-fiber-auth-api
cd go-fiber-auth-api# Copy dan edit environment variables
cp .env.example .envgo mod downloadgo run cmd/main.goAPI akan berjalan di http://localhost:8080
# Build dan jalankan dengan Docker Compose
docker-compose up -d# Build image
docker build -t ujikom-api .
# Run container
docker run -d --name ujikom-backend -p 3006:8080 ujikom-api- Development:
http://localhost:8080
| Method | Endpoint | Deskripsi |
|---|---|---|
GET |
/api/v1/health |
Health check API |
GET |
/api/v1/docs |
Dokumentasi API |
GET |
/api/v1/auth/test |
Test endpoint auth |
POST |
/api/v1/auth/register |
Registrasi user baru |
POST |
/api/v1/auth/login |
Login user |
| Method | Endpoint | Deskripsi |
|---|---|---|
GET |
/api/v1/user/profile |
Lihat profil user |
PUT |
/api/v1/user/profile |
Update profil user |
POST |
/api/v1/user/change-password |
Ganti password |
POST |
/api/v1/user/deactivate |
Nonaktifkan akun |
POST |
/api/v1/user/logout |
Logout user |
POST |
/api/v1/user/refresh-token |
Refresh JWT token |
| Method | Endpoint | Deskripsi |
|---|---|---|
POST |
/api/v1/attendance/checkin |
Check-in dengan GPS |
POST |
/api/v1/attendance/checkout |
Check-out dengan GPS |
GET |
/api/v1/attendance/today |
Lihat absensi hari ini |
GET |
/api/v1/attendance/history |
Riwayat kehadiran |
GET |
/api/v1/attendance/stats |
Statistik kehadiran |
| Method | Endpoint | Deskripsi |
|---|---|---|
GET |
/api/v1/testing/users |
Lihat semua user (opsional auth) |
- Password Hashing - Menggunakan bcrypt
- JWT Authentication - Token-based auth
- GPS Location Validation - Validasi lokasi dalam radius sekolah
- Mobile Device Security - Keamanan untuk aplikasi mobile
- Haversine Distance Calculation - Perhitungan jarak GPS yang akurat
- Indonesia Territory Validation - Validasi lokasi dalam wilayah Indonesia
- Input Validation - Validasi input user
- CORS Enabled - Cross-origin resource sharing
- Rate Limiting - Pembatasan request
- SQL Injection Protection - MongoDB native protection
- Environment Variables - Sensitive data protection
Ini adalah project pembelajaran, jadi kontribusi dan saran sangat diterima!
- Fork repository
- Buat feature branch (
git checkout -b feature/amazing-feature) - Commit perubahan (
git commit -m 'Add amazing feature') - Push ke branch (
git push origin feature/amazing-feature) - Buat Pull Request
Project ini dibuat untuk mempelajari:
- Go Fundamentals - Sintaks dasar, goroutines, channels
- Web Development - HTTP handling, middleware, routing
- Database Integration - MongoDB operations, ODM
- Authentication - JWT, password hashing, security
- GPS & Location Services - Geolocation, distance calculation, navigation
- Mobile API Development - Mobile-first API design, device security
- API Design - RESTful principles, response format
- DevOps - Docker, deployment, monitoring
- Best Practices - Code structure, error handling, validation
Project ini dibuat untuk keperluan pembelajaran dan bersifat open source.
SideeID
- GitHub: [https://github.com/SideeID]
- Website: [https://side.my.id]
Dibuat dengan β€οΈ untuk belajar Go dan teknologi backend modern
Happy Coding! π
Security Infrastructure-based Wireless Network Cellular Network Security: Validasi koneksi melalui jaringan hp Deteksi jenis koneksi (4G/5G) Enkripsi data saat transmisi via hp WLAN Security: Validasi WiFi sekolah Deteksi SSID sekolah yang authorized WPA/WPA2 encryption support Blocking akses dari WiFi publik/tidak dikenal Virtual Private Networks (VPN): Deteksi penggunaan VPN Blocking atau warning jika ada VPN aktif Secure tunnel untuk data transmission Mobile IP: Tracking IP address perangkat Validasi IP range sekolah Geofencing berdasarkan IP location
Mobile Sensors GPS - untuk location tracking (paling cuma ini yang kepakek) Accelerometer - deteksi gerakan/shake Gyroscope - orientasi perangkat Fingerprint/Face ID - biometric authentication (sama ini kalo mau) Proximity sensor - deteksi jarak Ambient light sensor - deteksi kondisi pencahayaan
Navigasi GPS Real-time location tracking Geofencing untuk area sekolah Distance calculation dari lokasi sekolah Maps integration untuk menampilkan lokasi Route tracking (perjalanan ke sekolah)
Keamanan Perangkat Device Security: Device fingerprinting (IMEI, device ID) Root/Jailbreak detection Screen recording/screenshot prevention App tampering detection Certificate pinning untuk API calls Authentication Security: Multi-factor authentication Biometric authentication Token-based authentication (JWT) Session management Auto-logout setelah idle