No description
- Java 64.2%
- HTML 35.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| database | ||
| gradle/wrapper | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| build.gradle | ||
| gradlew | ||
| gradlew.bat | ||
| README.md | ||
| settings.gradle | ||
Habit Tracker
A simple Spring Boot application for tracking daily habits and rewarding consistency.
Overview
The Habit Tracker helps users build and maintain positive habits by tracking daily activities and providing rewards for consistency. The application allows users to create habits, log their completion, and redeem rewards.
Features
- Create and manage habits with descriptions
- Log completion of daily habits
- View habit history and streaks
- Redeem rewards for consistent habit completion
- Simple and intuitive user interface
Tech Stack
- Java 23
- Spring Boot
- PostgreSQL database
- Gradle build system
- REST API architecture
Setup & Installation
Prerequisites
- Java 23 JDK/JRE
- PostgreSQL database
- Gradle 8.x+
Database Setup
- Create a PostgreSQL database
- Run the schema creation script:
psql -U postgres -d yourdb -f database/schema.sql - (Optional) Load sample data:
psql -U postgres -d yourdb -f database/sample-data.sql
Running Locally
./gradlew bootRun
Deployment Options
Deploy existing service
-
Build the JAR:
./gradlew bootJar -
Stop the service (via ssh)
ssh user@server sudo systemctl stop habittracker.service -
SCP jar to server
scp build/libs/habittracker-0.0.1-SNAPSHOT.jar user@server:/path/to/app -
Start the service (via ssh)
ssh user@server sudo systemctl start habittracker.service
As a Systemd Service
-
Build the JAR:
./gradlew bootJar -
Create a systemd service file:
[Unit] Description=Habit Tracker Service After=network.target [Service] User=youruser WorkingDirectory=/path/to/app ExecStart=/path/to/java -jar habittracker-0.0.1-SNAPSHOT.jar --server.address=0.0.0.0 SuccessExitStatus=143 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target -
Enable and start the service:
sudo systemctl enable habittracker sudo systemctl start habittracker
API Endpoints
GET /api/habits- List all habitsPOST /api/habits- Create a new habitGET /api/habits/{id}- Get a specific habitPUT /api/habits/{id}- Update a habitPOST /api/habits/{id}/log- Log completion of a habitGET /api/rewards- List all rewardsPOST /api/rewards/redeem- Redeem a reward
Configuration
Configure the application via application.properties:
server.port=8084
server.address=0.0.0.0
spring.datasource.url=jdbc:postgresql://localhost:5432/yourdb
spring.datasource.username=postgres
spring.datasource.password=yourpassword