commit 4d5652a5a44a254e251834587ebc69621fb9ca08 Author: David Folch Agulles Date: Tue Nov 25 10:09:42 2025 +0100 Initial project setup with MIT license - Add MIT License (Copyright 2025 David Folch Agulles) - Add README with project description - Add .gitignore for Go project - Add .env.example for configuration - Initialize Go module diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cc03d84 --- /dev/null +++ b/.env.example @@ -0,0 +1,13 @@ +DB_TYPE=sqlite +DB_PATH=./data/habits.db + +PORT=8080 +HOST=0.0.0.0 + +JWT_SECRET=change-me-in-production +JWT_EXPIRY=24h +REFRESH_TOKEN_EXPIRY=168h + +CORS_ORIGINS=http://localhost:3000 + +DEFAULT_TIMEZONE=UTC diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..072efa4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.env +data/ +*.db +*.db-shm +*.db-wal +habit-tracker-api +dist/ +bin/ +.internal-notes/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2343030 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 David Folch Agulles + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..27edab0 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# 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 + +1. Download the latest release +2. Copy `.env.example` to `.env` and configure +3. Run: `./habit-tracker-api` + +The API will be available at `http://localhost:8080` + +## Development + +### Prerequisites + +- Go 1.23+ +- SQLite (or PostgreSQL) + +### Running locally + +```bash +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 entities +- `application/`: Use cases (commands & queries) +- `infrastructure/`: External adapters (database, HTTP, etc.) +- `shared/`: Common utilities and errors + +## License + +MIT diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..af99ff4 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module habit-tracker-api + +go 1.23.4