3e8883d8781dac9e077667f84f84a6a82e2f28b6
- Create DTOs for HTTP requests and responses
- Implement habit handlers (create, get today's, mark)
- Register routes in router: POST /habits, GET /habits/today, POST /habits/{id}/mark
- Add missing repository methods (FindByID, FindByHabitID, FindPendingByHabitID, Delete)
- Wire up dependencies in main.go
- Tested with curl: create, list, mark habits work correctly
Habit Tracker API
Self-hosted habit tracking service with a clean, hexagonal architecture.
Features
- Multiple habit types: Boolean (check), Counter, Value
- Flexible scheduling: Daily, Weekly, Monthly with specific days
- Carry-over support: Choose if incomplete habits persist or expire
- Full history tracking: Complete audit trail of all interactions
- Charts & Analytics: Heatmaps, line charts, and statistics
- Self-hosted first: Easy deployment with SQLite or PostgreSQL
Quick Start
Using the binary
- Download the latest release
- Copy
.env.exampleto.envand configure - Run:
./habit-tracker-api
The API will be available at http://localhost:8080
Development
Prerequisites
- Go 1.23+
- SQLite (or PostgreSQL)
Running locally
cp .env.example .env
go run cmd/api/main.go
API Documentation
Once running, visit http://localhost:8080/api/v1/docs for interactive API documentation.
Architecture
This project follows hexagonal (ports & adapters) architecture:
domain/: Core business logic and entitiesapplication/: Use cases (commands & queries)infrastructure/: External adapters (database, HTTP, etc.)shared/: Common utilities and errors
License
MIT
Languages
Go
99.5%
HTML
0.4%