4c8f3022f02cf67965b98c14b1cb66013db5905a
- Create PasswordHasher interface in domain layer - Implement BcryptHasher in infrastructure layer - Update RegisterUserHandler and LoginUserHandler to use interface - Remove bcrypt dependency from application layer - Update main.go and integration tests with dependency injection - Enhance CI/CD workflow with test and lint jobs - Add code coverage check (minimum 50%) - Add go vet and gofmt validation - Configure build job to depend on test and lint passing - Update GitHub Actions to latest versions (v4→v5) This achieves 100% SOLID compliance (DIP) and ensures Clean Architecture by removing external library dependencies from application/domain layers.
Apocapoc
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
- Statistics: Track streaks, completion rates, and progress
- Self-hosted first: Easy deployment with SQLite
- Security: JWT authentication, rate limiting on auth endpoints
- API Documentation: Interactive Swagger UI
Quick Start
Using Docker Compose (Recommended)
- Create a
docker-compose.ymlfile:
services:
api:
image: ghcr.io/davidfolch/apocapoc-api:latest
ports:
- "8080:8080"
environment:
- DB_PATH=/data/apocapoc.db
- JWT_SECRET=YOUR_SECRET_HERE
- JWT_EXPIRY=24h
- REFRESH_TOKEN_EXPIRY=168h
- CORS_ORIGINS=http://localhost:3000
- DEFAULT_TIMEZONE=UTC
volumes:
- habit-data:/data
restart: unless-stopped
volumes:
habit-data:
-
Important: Replace
YOUR_SECRET_HEREwith a secure random string forJWT_SECRET -
Start the service:
docker-compose up -d
The API will be available at http://localhost:8080
Configuration options:
JWT_SECRET: Required. Use a long random stringJWT_EXPIRY: Token expiration (e.g.,24h,48h)REFRESH_TOKEN_EXPIRY: Refresh token expiration (e.g.,168h= 7 days)CORS_ORIGINS: Comma-separated list of allowed originsDEFAULT_TIMEZONE: Timezone for date calculations (e.g.,UTC,Europe/Madrid)
Using the binary
- Download the latest release
- Copy
.env.exampleto.envand configure - Run:
./apocapoc-api
The API will be available at http://localhost:8080
Development
Prerequisites
- Go 1.23+
- SQLite
- Docker (optional)
Running locally with Docker (Recommended)
cp docker-compose.example.yml docker-compose.yml
docker-compose up --build
The API will be available at http://localhost:8080
Running locally with Go
cp .env.example .env
go run cmd/api/main.go
API Documentation
Once running, visit http://localhost:8080/api/v1/docs for interactive Swagger 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%