A comprehensive employee monitoring application built with Ruby on Rails 8 that tracks work sessions, captures periodic screenshots, monitors task progress, and provides management dashboards.
- Work Session Tracking: Start, pause, resume, and end work shifts with automatic time tracking
- Screenshot Capture: Automatic screenshot capture with activity level detection (via desktop agent)
- Task Management: Create, assign, and track tasks with time entries
- Project Management: Organize tasks under projects with deadlines
- Role-Based Access Control: Employee, Manager, and Admin roles with appropriate permissions
- Real-time Dashboards: Live updates using Turbo Streams
- Reporting: Daily, weekly, and custom date range reports with CSV export
- API for Desktop Agent: RESTful API for the Electron-based desktop monitoring agent
- Ruby: 3.3.10
- Rails: 8.x
- Database: PostgreSQL
- Background Jobs: Sidekiq with Redis
- Frontend: Hotwire (Turbo + Stimulus), Tailwind CSS
- Authentication: Devise
- Authorization: Pundit
- File Storage: ActiveStorage (local/S3)
- Ruby 3.3.10
- PostgreSQL 16+
- Redis 7+
- Node.js 18+
- Yarn
- Clone the repository:
git clone <repository-url>
cd employee_monitor- Build and start services:
docker-compose up --build- In a new terminal, create and seed the database:
docker-compose exec web rails db:create db:migrate db:seed- Access the application at
http://localhost:3000
- Install dependencies:
bundle install
yarn install- Configure database:
# Update config/database.yml with your PostgreSQL credentials
rails db:create db:migrate db:seed- Start Redis:
redis-server- Start Sidekiq:
bundle exec sidekiq- Start Rails server:
bin/dev- Access the application at
http://localhost:3000
After running rails db:seed:
| Role | Password | |
|---|---|---|
| Admin | admin@example.com | password123 |
| Manager | manager1@example.com | password123 |
| Employee | alice.anderson@example.com | password123 |
The API is available at /api/v1/. Authentication is done via Bearer token.
Login (Get Token)
POST /api/v1/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123",
"device_name": "My Laptop"
}Response:
{
"message": "Authentication successful",
"data": {
"token": "abc123...",
"user": { ... },
"config": {
"screenshot_interval_seconds": 300,
"idle_threshold_seconds": 180
}
}
}All endpoints require Authorization: Bearer <token> header.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/session/current | Get current session status |
| POST | /api/v1/session/start | Start new work session |
| POST | /api/v1/session/end | End current session |
| POST | /api/v1/session/pause | Pause current session |
| POST | /api/v1/session/resume | Resume paused session |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/screenshots | Upload single screenshot |
| POST | /api/v1/screenshots/batch | Upload multiple screenshots |
Screenshot payload:
{
"image": "<base64-encoded-png>",
"captured_at": "2024-01-15T10:30:00Z",
"activity_level": "active",
"mouse_clicks": 42,
"keystrokes": 156,
"current_window_title": "VS Code",
"current_app_name": "Code"
}| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/tasks | List user's active tasks |
| POST | /api/v1/tasks/:id/start | Start tracking time on task |
| POST | /api/v1/tasks/:id/stop | Stop tracking time on task |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/activities | Log activity event |
| POST | /api/v1/activities/heartbeat | Agent heartbeat |
| Job | Schedule | Description |
|---|---|---|
| DailyReportJob | 1:00 AM | Generates daily summary reports |
| ScreenshotCleanupJob | 3:00 AM | Removes screenshots older than retention period |
| SessionAutoEndJob | Every hour | Auto-ends stale sessions (12+ hours with no activity) |
Access Sidekiq dashboard at /sidekiq (admin only).
app/
├── controllers/
│ ├── api/v1/ # API controllers
│ ├── users/ # Devise controllers
│ └── ... # Web controllers
├── models/ # ActiveRecord models
├── policies/ # Pundit authorization policies
├── jobs/ # Background jobs
├── views/
│ ├── layouts/ # Application layouts
│ ├── dashboard/ # Dashboard views
│ └── ... # Other views
└── javascript/
└── controllers/ # Stimulus controllers
# Run all tests
rails test
# Run specific test file
rails test test/models/user_test.rbThe application includes a production Dockerfile and is configured for deployment with Kamal.
- Update
config/deploy.ymlwith your server details - Run
kamal setupto prepare servers - Run
kamal deployto deploy
MIT License