AttendTrack β Attendance Management System
A full-stack PHP attendance management app with GPS check-in, selfie capture, overtime tracking, and admin reporting. Deployed on Vercel with Vercel Postgres (Neon).
https://absencsm.vercel.app
ποΈ Project Structure
vercel-app/
βββ vercel.json β Vercel routing config
βββ api/ β All PHP files (serverless functions)
β βββ config.php β DB connection, sessions, auth helpers
β βββ functions.php β All app functions
β βββ index.php β Login page
β βββ dashboard.php β User attendance panel
β βββ register.php β New account registration
β βββ logout.php β Session destroy + redirect
β βββ profile.php β Edit username / password / photo
β βββ forgot-password.php β Token-based password reset
β βββ install.php β One-click DB table installer
β βββ attendance-action.php β JSON API for check-in/out
β βββ admin/
β β βββ index.php β Admin dashboard (Chart.js)
β β βββ users.php β User CRUD + work schedule
β β βββ reports.php β Reports + CSV / Excel export
β βββ includes/
β βββ nav.php β Shared sidebar + topbar
βββ public/
βββ assets/
βββ css/style.css β Full stylesheet (responsive)
βββ logo.svg β App logo
Layer
Technology
Backend
PHP 8.2 (Vercel serverless via vercel-php@0.7.2)
Database
PostgreSQL (Vercel Postgres / Neon)
Frontend
Vanilla JS + Chart.js
Hosting
Vercel
Auth
PHP sessions stored in Postgres
Styling
Custom CSS (DM Sans + DM Mono)
Table
Description
users
Employees and admins
attendance
Check-in/out records per day
password_resets
Password reset tokens
php_sessions
Server-side session storage (required for Vercel)
Column
Type
Notes
id
SERIAL
Primary key
username
VARCHAR(30)
Unique
email
VARCHAR(100)
Unique
password
VARCHAR(255)
bcrypt hashed
role
VARCHAR(10)
user or admin
work_start
TIME
Scheduled start time
work_end
TIME
Scheduled end time
is_active
SMALLINT
1 = active, 0 = disabled
Key columns β attendance
Column
Type
Notes
user_id
INT
FK β users.id
work_date
DATE
Unique per user per day
checkin_time
TIME
Regular check-in
checkin_lat/lng
DECIMAL
GPS coordinates
checkin_photo
VARCHAR
Saved filename
ot_checkin_time
TIME
Overtime check-in
status
VARCHAR
present, absent, leave, holiday
1. Clone and push to GitHub
git init
git add .
git commit -m " initial commit"
git remote add origin https://github.com/yourname/attendtrack.git
git push -u origin main
Go to vercel.com β Add New Project
Import your GitHub repo
Vercel auto-detects vercel.json β click Deploy
Vercel Dashboard β Storage β Create Database β Postgres
Connect it to your project
Environment variables (PGHOST, PGDATABASE, etc.) are injected automatically
4. Run the database schema
Vercel Dashboard β Storage β your DB β Query tab
Paste and run schema_postgres.sql
Role
Username
Password
Admin
admin
Admin@123
User
john_doe
User@123
User
jane_smith
User@123
User
ali_rahman
User@123
User
siti_nurhaliza
User@123
User
budi_santoso
User@123
β οΈ Change all passwords after first login.
π Login / Register / Forgot Password
π GPS-verified Check-In & Check-Out
πΈ Selfie photo at every check-in
β±οΈ Overtime Check-In & Check-Out
π Live clock display
π€ Edit profile, change password, upload photo
π Dashboard with Chart.js weekly trend
π₯ User Management (create, edit, delete, set work schedule)
π Attendance Reports with filters
π₯ Export to CSV and Excel
π Role-based access control
URL
Page
/
Login
/dashboard
User dashboard
/register
Register
/profile
My profile
/forgot-password
Password reset
/logout
Logout
/admin/index
Admin dashboard
/admin/users
User management
/admin/reports
Reports & export
/api/attendance-action
Check-in/out API (POST)
All settings are in api/config.php:
define ('APP_NAME ' , 'AttendTrack ' );
define ('SESSION_TIMEOUT ' , 3600 ); // 1 hour
define ('TIMEZONE ' , 'Asia/Jakarta ' );
Database credentials are read from Vercel environment variables automatically:
$ host = $ _ENV ['PGHOST ' ];
$ dbname = $ _ENV ['PGDATABASE ' ];
$ user = $ _ENV ['PGUSER ' ];
$ password = $ _ENV ['PGPASSWORD ' ];
Issue
Reason
Workaround
Photo uploads are temporary
Vercel filesystem is read-only (uses /tmp)
Integrate Cloudinary or AWS S3
Cold starts
Vercel spins up containers on demand
Normal for serverless β first load may be slow
Sessions stored in DB
Vercel containers don't share /tmp
Already implemented via php_sessions table
# Requires PHP 8.x + PostgreSQL
php -S localhost:8000 -t api/
# Or use Laravel Valet / XAMPP with a local Postgres DB
# Update config.php with local DB credentials
MIT β free to use and modify.