A productivity timer application built with Go, Gin, HTMX, Alpine.js, Templ, and MongoDB with OAuth authentication.
🚀 Live Demo: timer.neilsmahajan.com
- Start/stop/reset timer sessions with custom tags
- Track time spent on various tasks
- View statistics and summaries by time period
- OAuth authentication (Google, GitHub, etc.)
- Backend: Go with Gin framework
- Frontend: HTMX + Alpine.js + Templ templates
- Database: MongoDB
- Authentication: OAuth via Goth
productivity-timer/
├── cmd/api/ # Application entrypoint
├── docs/ # Generated Swagger/OpenAPI documentation
├── internal/
│ ├── auth/ # Authentication logic
│ ├── database/ # Database operations
│ ├── models/ # Data models
│ └── server/ # HTTP handlers and routing
└── web/templates/ # Templ templates
Once the server is running, access the Swagger UI at:
http://localhost:8080/swagger/index.html
Timer and Stats API endpoints are versioned under /api/v1. Auth routes remain at root level for OAuth provider compatibility.
| Method | Endpoint | Description |
|---|---|---|
| GET | /auth/:provider |
Initiate OAuth |
| GET | /auth/:provider/callback |
OAuth callback |
| GET | /logout/:provider |
Logout |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| POST | /api/v1/timer/start |
Start timer |
| POST | /api/v1/timer/stop |
Stop timer |
| POST | /api/v1/timer/reset |
Reset/complete timer |
| GET | /api/v1/stats/summary |
Get stats summary |
| GET | /api/v1/stats/tag/:tag/sessions |
Get tag sessions |
| DELETE | /api/v1/stats/tag/:tag |
Delete tag and sessions |
- Go 1.21+
- MongoDB
- swag for Swagger generation
- Clone the repository
- Copy
.env.exampleto.envand configure environment variables - Install dependencies:
go mod download - Install swag:
make swagger-install
# Build and run
make run
# Development with hot reload
make watch
# Generate Swagger docs
make swaggermake build- Build the application (includes swagger generation)make run- Build and runmake watch- Hot reload developmentmake swagger- Generate Swagger documentationmake swagger-install- Install swag CLI toolmake clean- Clean build artifacts
This application is deployed on Railway with continuous deployment from the main branch.
- Live URL: timer.neilsmahajan.com
- CI/CD: GitHub Actions (lint, test, build, security scan)
Neil Mahajan
- Website: neilsmahajan.com
- Links: links.neilsmahajan.com
- GitHub: @neilsmahajan
MIT