A simple and efficient time tracking system for employees to check in/out and view their attendance records.
Clock is a full-stack web application that provides:
- Employee login with JWT authentication
- Check-in/check-out functionality
- Monthly attendance record viewing
- Admin dashboard with comprehensive management capabilities
- Full audit trail for all administrative changes
Clock includes powerful administrative capabilities for managing employee attendance:
- Automatic redirect: Admins are automatically taken to the admin dashboard after login
- Employee time summary: View aggregated hours for all employees
- Detailed records management: View, edit, add, and delete attendance records
- Advanced filtering: Filter by date range and specific employees
- Pagination: Handle large datasets with efficient pagination
- âś… View all employee attendance records with full details
- âś… Edit existing records (check-in/out times, status, notes)
- âś… Add missing records for employees who forgot to check-in/out
- âś… Delete records with soft-delete for data integrity
- âś… View audit trail showing who edited what and when
- âś… Export and filter data by date range and employee
- Admin users are exempt from time tracking
- No check-in/out functionality available for admin role
- Clear messaging when admins navigate to attendance page
Every admin action is tracked with:
- Edited By: ID of the admin who made the change
- Edited At: Timestamp of the modification
- Edit Reason: Required explanation for all changes (minimum 3 characters)
- Role-based access control (RBAC) with middleware enforcement
- Admin endpoints require both authentication AND admin role
- Comprehensive validation on all admin operations
- Soft deletes preserve data for audit purposes
For detailed admin documentation, see docs/ADMIN_FEATURES.md
- Next.js 14 with React 18
- TypeScript
- Material-UI (MUI) v5
- Axios for API calls
- Formik + Yup for forms
- Go 1.23+
- Iris web framework
- PostgreSQL 16
- JWT authentication
- sqlx for database operations
- Docker & Docker Compose
- Nginx reverse proxy
- sql-migrate for database migrations
clock/
├── clock-backend/ # Go backend application
├── clock-frontend/ # Next.js React frontend
├── migrations/ # Database migrations
├── nginx/ # Nginx configuration
├── docker-compose.yml # Development environment
├── docker-compose.staging.yml # Staging environment
├── PROJECT_PLAN.md # Detailed project documentation
└── README.md # This file
- Docker and Docker Compose
- Git
- (Optional) Go 1.23+ for local backend development
- (Optional) Node.js 18+ for local frontend development
-
Clone the repository
git clone <repository-url> cd clock
-
Start the development environment
docker-compose up -d
This will start:
- PostgreSQL database on port 5433
- Backend API on port 8080
- Frontend app on port 3000
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080/api/v1
- Database: localhost:5433
-
Default login credentials
- Admin:
admin/admin123(redirects to/admin/dashboard) - Staff:
jane.smith/staff123(redirects to/attendance)
- Admin:
The database is automatically initialized with the schema and seed data when the containers start.
To manually run migrations:
docker-compose exec backend sql-migrate upTo check migration status:
docker-compose exec backend sql-migrate statusdocker-compose downTo remove volumes (reset database):
docker-compose down -vLogin with username and password.
Request:
{
"username": "john.doe",
"password": "staff123"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"employee": {
"id": 2,
"username": "john.doe",
"name": "John Doe",
"email": "john.doe@clock.local",
"role": "STAFF"
}
}All attendance endpoints require the Authorization: Bearer <token> header.
Check in to work.
Check out from work.
Get current check-in status.
Get attendance records with optional month filter.
Query Parameters:
year(optional): e.g., 2026month(optional): 1-12
See PROJECT_PLAN.md for complete API documentation.
-
Navigate to backend directory:
cd clock-backend -
Install dependencies:
go mod download
-
Run locally (requires PostgreSQL):
go run cmd/main.go
-
Run tests:
go test ./...
-
Navigate to frontend directory:
cd clock-frontend -
Install dependencies:
yarn install
-
Run development server:
yarn dev
-
Build for production:
yarn build
-
SSH to staging server:
ssh user@staging-server
-
Navigate to project directory:
cd /path/to/clock -
Pull latest changes:
git pull origin main
-
Deploy with Docker Compose:
docker-compose -f docker-compose.staging.yml up -d --build
-
Check logs:
docker-compose -f docker-compose.staging.yml logs -f
Similar to staging deployment but using production configuration files and environment variables.
Create .env file in clock-backend/ directory:
DB_HOST=localhost
DB_PORT=5433
DB_USER=clock_user
DB_PASSWORD=clock_pass
DB_NAME=clock
JWT_SECRET=your-secret-key-change-in-production
JWT_REFRESH_SECRET=your-refresh-secret-key
JWT_EXPIRATION=3600
JWT_REFRESH_EXPIRATION=604800
PORT=8080
ENV=development
LOG_LEVEL=debugCreate .env.local file in clock-frontend/ directory:
NEXT_PUBLIC_API_URL=http://localhost:8080/api/v1The database consists of two main tables:
- employees - User accounts with authentication
- attendance_records - Check-in/check-out events
Both tables support soft delete (via deleted_at column) for audit trails.
See migrations/20260105000001-initial-schema.sql for the complete schema.
- Passwords hashed with bcrypt (cost factor 10)
- JWT-based authentication with access and refresh tokens
- Rate limiting on API endpoints
- CORS configured for frontend origin only
- SQL injection prevention via parameterized queries
- HTTPS enforced in production
cd clock-backend
go test ./...cd clock-frontend
yarn test- Ensure PostgreSQL container is running:
docker-compose ps - Check database logs:
docker-compose logs postgres - Verify credentials in
.envfile
- Verify backend is running:
docker-compose ps - Check NEXT_PUBLIC_API_URL in frontend
.env.local - Check CORS configuration in backend
- Check backend logs:
docker-compose logs backend - Manually run migrations:
docker-compose exec backend sql-migrate up
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run tests
- Commit with descriptive message
- Push and create a pull request
[Add your license here]
For detailed documentation, see PROJECT_PLAN.md.
For issues and questions, [add contact information or issue tracker link].
Status: Phase 2 Complete (Admin Features Implemented)
Version: 0.2.0
Last Updated: 2026-01-10