Commit Graph

7 Commits

Author SHA1 Message Date
david b2894fca70 Add JWT authentication
- Create register and login use cases
- Implement JWT service for token generation and validation
- Add authentication middleware to protect habit endpoints
- Create auth HTTP handlers (register, login)
- Update habit handlers to extract userID from JWT token
- Register/login endpoints: POST /auth/register, POST /auth/login
- Habit endpoints now require Bearer token in Authorization header
- Tested: register -> create habit -> list habits works correctly
2025-11-26 01:05:08 +01:00
david 3e8883d878 Add habit HTTP endpoints
- 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
2025-11-26 00:41:05 +01:00
david 76893bd114 Add HTTP layer and server setup
- Add strict configuration management (no fallbacks)
- Create HTTP router with Chi and CORS middleware
- Implement health check endpoint
- Add main entry point with database initialization
- Server runs on configurable host and port
2025-11-26 00:21:07 +01:00
david 34ea1f718e Implement Application Layer with TDD
- Add date utilities for habit scheduling logic
- Implement CreateHabitHandler with full validation
- Implement GetTodaysHabitsHandler with carry-over support
- Implement MarkHabitHandler for completing habits
- All components developed following TDD methodology
- Complete test coverage for commands and queries
2025-11-25 23:54:49 +01:00
david 0977d3a58b Implement SQLite persistence layer (TDD)
- Add SQLite and UUID dependencies (go-sqlite3, google/uuid)
- Create database connection with automatic migrations
- Implement UserRepository with full CRUD operations
- Implement HabitRepository with JSON serialization for arrays
- Implement HabitEntryRepository with date range queries
- Add comprehensive test coverage for all repositories
- Fix User entity to default timezone to UTC when empty
- All tests passing with TDD approach (Red-Green-Refactor)
2025-11-25 14:29:51 +01:00
david 64bfe80806 Implement domain layer (TDD - Green phase)
Implementation to make all tests pass:

Value Objects:
- HabitType: BOOLEAN, COUNTER, VALUE with validation
- Frequency: DAILY, WEEKLY, MONTHLY with validation

Entities:
- User: email, password hash, timezone with defaults
- Habit: tracking habits with type, frequency, carry-over
- HabitEntry: recording habit completions with soft delete

Repositories (interfaces):
- UserRepository: CRUD operations for users
- HabitRepository: CRUD operations for habits
- HabitEntryRepository: CRUD operations for entries

Shared:
- Common error definitions for domain layer

All domain tests now pass.
2025-11-25 10:13:08 +01:00
david 664f7a0de0 Add domain layer tests (TDD - Red phase)
Following TDD principles, adding tests before implementation:

- Add HabitType value object tests (validation)
- Add Frequency value object tests (validation)
- Add User entity tests (creation, default timezone)
- Add Habit entity tests (creation, archive, active status)
- Add HabitEntry entity tests (creation, soft delete)

Tests cover core domain logic and business rules.
All tests will fail until implementation is added.
2025-11-25 10:12:04 +01:00