Skip to content

Elysium-Arc/Employee-Monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Employee Monitoring System

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.

Features

  • 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

Tech Stack

  • 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)

Prerequisites

  • Ruby 3.3.10
  • PostgreSQL 16+
  • Redis 7+
  • Node.js 18+
  • Yarn

Setup Instructions

Option 1: Using Docker (Recommended)

  1. Clone the repository:
git clone <repository-url>
cd employee_monitor
  1. Build and start services:
docker-compose up --build
  1. In a new terminal, create and seed the database:
docker-compose exec web rails db:create db:migrate db:seed
  1. Access the application at http://localhost:3000

Option 2: Local Development

  1. Install dependencies:
bundle install
yarn install
  1. Configure database:
# Update config/database.yml with your PostgreSQL credentials
rails db:create db:migrate db:seed
  1. Start Redis:
redis-server
  1. Start Sidekiq:
bundle exec sidekiq
  1. Start Rails server:
bin/dev
  1. Access the application at http://localhost:3000

Demo Accounts

After running rails db:seed:

Role Email Password
Admin admin@example.com password123
Manager manager1@example.com password123
Employee alice.anderson@example.com password123

API Documentation

The API is available at /api/v1/. Authentication is done via Bearer token.

Authentication

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
    }
  }
}

Session Management

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

Screenshots

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"
}

Tasks

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

Activities

Method Endpoint Description
POST /api/v1/activities Log activity event
POST /api/v1/activities/heartbeat Agent heartbeat

Background Jobs

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).

Project Structure

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

Testing

# Run all tests
rails test

# Run specific test file
rails test test/models/user_test.rb

Deployment

The application includes a production Dockerfile and is configured for deployment with Kamal.

  1. Update config/deploy.yml with your server details
  2. Run kamal setup to prepare servers
  3. Run kamal deploy to deploy

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors