A simple web application for tracking time spent on different tasks, built with Go backend, HTML/CSS/JavaScript frontend, and SQLite database.
- ✅ Add time entries with task name, description, duration, and date
- ✅ View all time entries grouped by date
- ✅ Edit existing time entries
- ✅ Delete time entries
- ✅ Calculate total time spent per day
- ✅ Responsive web design
- ✅ SQLite database storage
- ✅ RESTful API
timesheet/
├── main.go # Go server with API endpoints
├── go.mod # Go module dependencies
├── static/ # Frontend assets
│ ├── index.html # Main HTML page
│ ├── styles.css # CSS styling
│ └── script.js # JavaScript functionality
├── timesheet.db # SQLite database (created automatically)
└── README.md # This file
- Go 1.21 or higher
- Git (for version control)
-
Navigate to the project directory:
cd c:\Users\peter\git\timesheet
-
Initialize Go modules and download dependencies:
go mod tidy
-
Run the application:
go run main.go
Or with custom parameters:
go run main.go -port 8081 -db ./custom.db
-
Open your web browser and navigate to:
http://localhost:8080(or the custom port you specified)
The application supports the following command-line parameters and environment variables:
-port- Port to run the server on (default: "8080")-db- Path to the SQLite database file (default: "./timesheet.db")-help- Show usage information
PORT- Port to run the server on (overridden by -port flag)DB_PATH- Path to the SQLite database file (overridden by -db flag)
Using Command-Line Flags:
# Use default settings
go run main.go
# Use custom port
go run main.go -port 8081
# Use custom database file
go run main.go -db ./my-timesheet.db
# Use custom port and database
go run main.go -port 8081 -db ./my-timesheet.db
# Show help
go run main.go -helpUsing Environment Variables:
# PowerShell syntax
$env:PORT="8081"; go run main.go
$env:DB_PATH="./my-timesheet.db"; go run main.go
$env:PORT="8081"; $env:DB_PATH="./my-timesheet.db"; go run main.go
# Command Prompt syntax
set PORT=8081 && go run main.go
set DB_PATH=./my-timesheet.db && go run main.goPrecedence: Command-line flags take priority over environment variables.
After building the application (go build .), you can use the same parameters:
# Default settings
.\timesheet.exe
# Custom port and database
.\timesheet.exe -port 8081 -db ./my-timesheet.dbThe application provides the following REST API endpoints:
GET /- Serve the main HTML pageGET /api/entries- Get all time entriesPOST /api/entries- Create a new time entryPUT /api/entries/{id}- Update an existing time entryDELETE /api/entries/{id}- Delete a time entry
Create a time entry (POST /api/entries):
{
"task": "Development",
"description": "Working on timesheet application",
"duration": 120,
"date": "2025-11-03"
}Response:
{
"id": 1,
"task": "Development",
"description": "Working on timesheet application",
"start_time": "2025-11-03T14:00:00Z",
"end_time": "2025-11-03T16:00:00Z",
"duration": 120,
"date": "2025-11-03"
}The application uses SQLite with the following table structure:
CREATE TABLE time_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT,
task TEXT NOT NULL,
description TEXT,
start_time DATETIME,
end_time DATETIME,
duration INTEGER NOT NULL,
date TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);-
Adding a Time Entry:
- Fill in the task name (required)
- Add an optional description
- Enter the duration in minutes
- Select the date
- Click "Add Entry"
-
Viewing Entries:
- All entries are displayed grouped by date
- Total time for each day is shown
- Current day's total is highlighted at the top
-
Editing Entries:
- Click the "Edit" button on any entry
- Modify the details in the modal dialog
- Click "Update Entry" to save changes
-
Deleting Entries:
- Click the "Delete" button on any entry
- Confirm the deletion in the dialog
To modify the application:
- Backend changes: Edit
main.goand restart the server - Frontend changes: Edit files in the
static/directory and refresh the browser - Database changes: The database is created automatically on first run
For a complete record of the project's development process, including all user requests and implementation decisions, see ai_chat.md.
The application can be built into a single, self-contained executable that includes all static files (HTML, CSS, JavaScript) embedded within the binary. This makes distribution extremely easy.
To build a standalone executable with all assets embedded:
go build -o timesheet.exe main.goThen run:
./timesheet.exeOr with custom parameters:
./timesheet.exe -port 8081 -db ./production.dbUse the automated build script to create binaries for all platforms:
.\build-cross-platform.ps1This script builds optimized binaries for:
- Windows (amd64) -
timesheet-windows-amd64.exe - Linux (amd64) -
timesheet-linux-amd64 - Linux (arm64) -
timesheet-linux-arm64(Raspberry Pi, ARM servers) - macOS (amd64) -
timesheet-macos-amd64(Intel Macs) - macOS (arm64) -
timesheet-macos-arm64(Apple Silicon Macs)
All binaries are placed in the distribution/ folder and include size optimization (-ldflags "-s -w").
- ✅ Single file distribution - No need to bundle static folder
- ✅ No external dependencies - All assets embedded in binary
- ✅ Cross-platform - Build for Windows, Linux, macOS
- ✅ Easy deployment - Just copy the executable
- ✅ No installation required - Run directly
The executable will create the SQLite database file (timesheet.db) in the same directory when first run.
The application uses Go 1.16+ embed package to bundle all static files directly into the binary:
//go:embed static/*
var staticFiles embed.FSThis means:
- All files in the
static/directory are compiled into the executable - No separate
static/folder needed for distribution - Files are served from memory, improving performance
- Works across all platforms without path issues
-
Port already in use: The application runs on port 8080. Make sure no other application is using this port.
-
Database permissions: Ensure the application has write permissions in the directory to create
timesheet.db. -
Go dependencies: If you encounter module errors, run
go mod tidyto resolve dependencies.
Potential improvements that could be added:
- User authentication and multiple users
- Time reporting and analytics
- Time goals and targets