How hackclub/hackatime works
Hackatime is a WakaTime-compatible coding-time tracker. Its central workflow is capturing editor heartbeats, normalizing and storing activity, then presenting users with time summaries and project views. The repository also contains authentication, imports, GitHub/Slack features, public statistics and leaderboards, OAuth, and administration. The available excerpts document ingestion internals and selected web routes, but not most controller-to-service wiring; unverified links are therefore dashed and uncited.
Main entry points: sessions_controller.rb Session authentication · heartbeat_ingest.rb Heartbeat normalization · heartbeats_controller.rb Heartbeat endpoints · hackatime_controller.rb WakaTime API
Components 22
Activity capture
- Heartbeat endpoints
app/controllers/api/v1/authenticated/heartbeats_controller.rb - WakaTime API
app/controllers/api/hackatime/v1/hackatime_controller.rb - Heartbeat normalization
app/services/heartbeat_ingest.rb - Heartbeat records
app/models/heartbeat.rb - Heartbeat imports
app/services/heartbeat_import_service.rb
Activity insights
- Dashboard summaries
app/controllers/api/summary_controller.rb - Statistics API
app/controllers/api/v1/stats_controller.rb - Project statistics
app/services/project_stats_service.rb - Project views
app/controllers/my/project_repo_mappings_controller.rb - Leaderboards
app/services/leaderboard_service.rb - Public profiles
app/controllers/profiles_controller.rb
Accounts and integrations
- Sign-in choices
app/javascript/pages/Home/signedOut/AuthForm.svelte - Session authentication
app/controllers/sessions_controller.rb - Hack Club Auth
- Slack
- GitHub
- OAuth applications
app/controllers/doorkeeper/applications_controller.rb - User records
app/models/user.rb
API and administration
- API clients
- Admin API
app/controllers/api/admin/v1/admin_controller.rb - Admin console
app/controllers/admin/timeline_controller.rb
Other components
- Developer
Connections 20
- Developer → Heartbeat endpoints: uploads activity
- Developer → WakaTime API: uploads activity
- Heartbeat endpoints → Heartbeat normalization: submits activity
- WakaTime API → Heartbeat normalization: submits activity
- Heartbeat normalization → Heartbeat records: deduplicates records
app/services/heartbeat_ingest.rb - API clients → Admin API: manages resources
- Developer → Sign-in choices: starts sign-in
- Sign-in choices → Session authentication: requests sign-in
- Session authentication → Hack Club Auth: redirects to
app/controllers/sessions_controller.rb - Session authentication → Slack: authenticates with
- Session authentication → GitHub: links account
- Session authentication → User records: authenticates user
- Developer → Dashboard summaries: views summaries
- Developer → Statistics API: requests statistics
- Developer → Project views: views projects
- Developer → Leaderboards: views rankings
- Developer → Public profiles: views profile
- Developer → Heartbeat imports: imports activity
- Developer → OAuth applications: manages OAuth apps
- Developer → Admin console: administers service