Timezone is now sent from the client on each request that needs it, instead of storing it in the database. This simplifies the model and allows timezone to be dynamic (useful for traveling users). Changes: - Remove timezone field from User entity - Remove timezone from user registration - GET /habits/today now requires ?timezone= query param - Add migration to drop timezone column from database - Update related tests
Apocapoc API - Self-Hosted Habit Tracker
REST API for habit tracking built with Go. Self-hosted alternative for developers who want control over their data.
Table of Contents
Features
- Multiple habit types: Boolean, Counter, Value
- Flexible scheduling: Daily, Weekly, Monthly
- Statistics: Streaks, completion rates, progress tracking
- JWT authentication, rate limiting, optional email verification
- Registration modes: Open or closed
- SQLite database (single file)
- Swagger UI at
/api/v1/docs
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
- PORT=8080
- APP_URL=http://localhost:8080
- JWT_SECRET=YOUR_SECRET_HERE
- JWT_EXPIRY=1h
- REFRESH_TOKEN_EXPIRY=7d
- DEFAULT_TIMEZONE=UTC
- REGISTRATION_MODE=open
# Email configuration (optional)
# - SMTP_HOST=smtp.example.com
# - SMTP_PORT=587
# - SMTP_USER=your-email@example.com
# - SMTP_PASSWORD=your-password
# - SMTP_FROM=noreply@example.com
# - SUPPORT_EMAIL=contact@apocapoc.app
# - SEND_WELCOME_EMAIL=false
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
API available at http://localhost:8080
Image tags:
latest: Stable release (recommended)1,1.0,1.0.0: Specific versionsedge: Development build (unstable)
Configuration:
Required:
JWT_SECRET: Long random string (required)DB_PATH: Database path (default:./data/apocapoc.db)
Application:
PORT: HTTP port (default:8080)APP_URL: Public URL for email linksDEFAULT_TIMEZONE: e.g.,UTC,Europe/Madrid
Authentication:
JWT_EXPIRY: e.g.,1h,24hREFRESH_TOKEN_EXPIRY: e.g.,7d,168hREGISTRATION_MODE:openorclosed
Email (optional):
SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASSWORD,SMTP_FROMSUPPORT_EMAIL: Defaultcontact@apocapoc.appSEND_WELCOME_EMAIL:true/false
Without SMTP config, users are auto-verified.
Using the binary
- Download from GitHub Releases
- Extract:
tar -xzf apocapoc-api_*_linux_amd64.tar.gz - Configure:
cp .env.example .env(edit as needed) - Run:
./apocapoc-api
API available at http://localhost:8080
Note: Linux only (amd64/arm64). Use Docker for other platforms.
Development
Prerequisites: Go 1.23+, SQLite, Docker (optional)
With Docker:
cp docker-compose.example.yml docker-compose.yml
docker-compose up --build
With Go:
cp .env.example .env
go run cmd/api/main.go
API runs on http://localhost:8080
Use Cases
- Build your own web or mobile frontend
- Create custom CLI tools or scripts
- Keep your habit data on your own infrastructure
- Experiment with a small REST API in Go
API Documentation
Access the interactive Swagger UI at http://localhost:8080/api/v1/docs
Includes endpoint reference, schemas, authentication examples, and live testing.
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
Support
- 📧 Email: contact@apocapoc.app
- 🐛 Issues: GitHub Issues
Keywords
habit-tracker habit-tracking rest-api self-hosted golang api habits productivity docker sqlite hexagonal-architecture clean-architecture habit-tracker-api self-hosted-api personal-analytics privacy open-source
License
MIT