# hackclub/hackatime architecture

> Architecture diagram of the GitHub repository hackclub/hackatime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hackclub/hackatime
- Repository: https://github.com/hackclub/hackatime

## Overview

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: [`app/controllers/sessions_controller.rb`](https://github.com/hackclub/hackatime/blob/main/app/controllers/sessions_controller.rb) (Session authentication), [`app/services/heartbeat_ingest.rb`](https://github.com/hackclub/hackatime/blob/main/app/services/heartbeat_ingest.rb) (Heartbeat normalization), [`app/controllers/api/v1/authenticated/heartbeats_controller.rb`](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/v1/authenticated/heartbeats_controller.rb) (Heartbeat endpoints), [`app/controllers/api/hackatime/v1/hackatime_controller.rb`](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/hackatime/v1/hackatime_controller.rb) (WakaTime API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Activity capture"]
  node_heartbeat_api["Heartbeat endpoints"]
  node_compat_api["WakaTime API"]
  node_ingest["Heartbeat normalization"]
  node_heartbeat_store[("Heartbeat records<br/>[heartbeat.rb]")]
  node_import_flow["Heartbeat imports"]
end

subgraph group_insights["Activity insights"]
  node_dashboard["Dashboard summaries"]
  node_stats["Statistics API"]
  node_project_stats["Project statistics"]
  node_projects_ui["Project views"]
  node_leaderboards["Leaderboards"]
  node_profiles["Public profiles"]
end

subgraph group_accounts["Accounts and integrations"]
  node_auth_form["Sign-in choices<br/>[AuthForm.svelte]"]
  node_sessions["Session authentication"]
  node_hackclub_auth["Hack Club Auth"]
  node_slack["Slack"]
  node_github["GitHub"]
  node_oauth["OAuth applications"]
  node_users[("User records<br/>[user.rb]")]
end

subgraph group_platform["API and administration"]
  node_api_clients(("API clients"))
  node_admin_api["Admin API"]
  node_admin_ui["Admin console"]
end

node_developer(("Developer"))

node_developer -.->|"uploads activity"| node_heartbeat_api
node_developer -.->|"uploads activity"| node_compat_api
node_heartbeat_api -.->|"submits activity"| node_ingest
node_compat_api -.->|"submits activity"| node_ingest
node_ingest -->|"deduplicates records"| node_heartbeat_store
node_api_clients -.->|"manages resources"| node_admin_api
node_developer -.->|"starts sign-in"| node_auth_form
node_auth_form -->|"requests sign-in"| node_sessions
node_sessions -->|"redirects to"| node_hackclub_auth
node_sessions -.->|"authenticates with"| node_slack
node_sessions -.->|"links account"| node_github
node_sessions -.->|"authenticates user"| node_users
node_developer -.->|"views summaries"| node_dashboard
node_developer -.->|"requests statistics"| node_stats
node_developer -.->|"views projects"| node_projects_ui
node_developer -.->|"views rankings"| node_leaderboards
node_developer -.->|"views profile"| node_profiles
node_developer -.->|"imports activity"| node_import_flow
node_developer -.->|"manages OAuth apps"| node_oauth
node_developer -.->|"administers service"| node_admin_ui

click node_heartbeat_api "https://github.com/hackclub/hackatime/blob/main/app/controllers/api/v1/authenticated/heartbeats_controller.rb"
click node_compat_api "https://github.com/hackclub/hackatime/blob/main/app/controllers/api/hackatime/v1/hackatime_controller.rb"
click node_ingest "https://github.com/hackclub/hackatime/blob/main/app/services/heartbeat_ingest.rb"
click node_heartbeat_store "https://github.com/hackclub/hackatime/blob/main/app/models/heartbeat.rb"
click node_import_flow "https://github.com/hackclub/hackatime/blob/main/app/services/heartbeat_import_service.rb"
click node_dashboard "https://github.com/hackclub/hackatime/blob/main/app/controllers/api/summary_controller.rb"
click node_stats "https://github.com/hackclub/hackatime/blob/main/app/controllers/api/v1/stats_controller.rb"
click node_project_stats "https://github.com/hackclub/hackatime/blob/main/app/services/project_stats_service.rb"
click node_projects_ui "https://github.com/hackclub/hackatime/blob/main/app/controllers/my/project_repo_mappings_controller.rb"
click node_leaderboards "https://github.com/hackclub/hackatime/blob/main/app/services/leaderboard_service.rb"
click node_profiles "https://github.com/hackclub/hackatime/blob/main/app/controllers/profiles_controller.rb"
click node_auth_form "https://github.com/hackclub/hackatime/blob/main/app/javascript/pages/Home/signedOut/AuthForm.svelte"
click node_sessions "https://github.com/hackclub/hackatime/blob/main/app/controllers/sessions_controller.rb"
click node_oauth "https://github.com/hackclub/hackatime/blob/main/app/controllers/doorkeeper/applications_controller.rb"
click node_admin_api "https://github.com/hackclub/hackatime/blob/main/app/controllers/api/admin/v1/admin_controller.rb"
click node_admin_ui "https://github.com/hackclub/hackatime/blob/main/app/controllers/admin/timeline_controller.rb"
click node_users "https://github.com/hackclub/hackatime/blob/main/app/models/user.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_heartbeat_api,node_compat_api,node_ingest,node_heartbeat_store,node_import_flow toneBlue
class node_dashboard,node_stats,node_project_stats,node_projects_ui,node_leaderboards,node_profiles toneAmber
class node_auth_form,node_sessions,node_hackclub_auth,node_slack,node_github,node_oauth,node_users toneMint
class node_api_clients,node_admin_api,node_admin_ui toneRose
class node_developer toneIndigo
```

## Components

### Activity capture

- [Heartbeat endpoints](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/v1/authenticated/heartbeats_controller.rb): `app/controllers/api/v1/authenticated/heartbeats_controller.rb`
- [WakaTime API](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/hackatime/v1/hackatime_controller.rb): `app/controllers/api/hackatime/v1/hackatime_controller.rb`
- [Heartbeat normalization](https://github.com/hackclub/hackatime/blob/main/app/services/heartbeat_ingest.rb): `app/services/heartbeat_ingest.rb`
- [Heartbeat records](https://github.com/hackclub/hackatime/blob/main/app/models/heartbeat.rb): `app/models/heartbeat.rb`
- [Heartbeat imports](https://github.com/hackclub/hackatime/blob/main/app/services/heartbeat_import_service.rb): `app/services/heartbeat_import_service.rb`

### Activity insights

- [Dashboard summaries](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/summary_controller.rb): `app/controllers/api/summary_controller.rb`
- [Statistics API](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/v1/stats_controller.rb): `app/controllers/api/v1/stats_controller.rb`
- [Project statistics](https://github.com/hackclub/hackatime/blob/main/app/services/project_stats_service.rb): `app/services/project_stats_service.rb`
- [Project views](https://github.com/hackclub/hackatime/blob/main/app/controllers/my/project_repo_mappings_controller.rb): `app/controllers/my/project_repo_mappings_controller.rb`
- [Leaderboards](https://github.com/hackclub/hackatime/blob/main/app/services/leaderboard_service.rb): `app/services/leaderboard_service.rb`
- [Public profiles](https://github.com/hackclub/hackatime/blob/main/app/controllers/profiles_controller.rb): `app/controllers/profiles_controller.rb`

### Accounts and integrations

- [Sign-in choices](https://github.com/hackclub/hackatime/blob/main/app/javascript/pages/Home/signedOut/AuthForm.svelte): `app/javascript/pages/Home/signedOut/AuthForm.svelte`
- [Session authentication](https://github.com/hackclub/hackatime/blob/main/app/controllers/sessions_controller.rb): `app/controllers/sessions_controller.rb`
- **Hack Club Auth**
- **Slack**
- **GitHub**
- [OAuth applications](https://github.com/hackclub/hackatime/blob/main/app/controllers/doorkeeper/applications_controller.rb): `app/controllers/doorkeeper/applications_controller.rb`
- [User records](https://github.com/hackclub/hackatime/blob/main/app/models/user.rb): `app/models/user.rb`

### API and administration

- **API clients**
- [Admin API](https://github.com/hackclub/hackatime/blob/main/app/controllers/api/admin/v1/admin_controller.rb): `app/controllers/api/admin/v1/admin_controller.rb`
- [Admin console](https://github.com/hackclub/hackatime/blob/main/app/controllers/admin/timeline_controller.rb): `app/controllers/admin/timeline_controller.rb`

### Other components

- **Developer**

## Connections

- 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 (evidence: `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 (evidence: `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
