Habit Tracker API is a backend REST API designed for tracking personal habits. Built using Java and Spring Boot, it offers a robust solution for users to manage their habits effectively. The API supports various functionalities, including habit creation, recurring check-ins, streak calculations, and user authentication.
For the latest updates and releases, visit our Releases section.
This project utilizes the following technologies:
To get started with the Habit Tracker API, follow these steps:
Clone the repository to your local machine:
git clone https://github.com/GGD-github/habit-tracker-api.git
cd habit-tracker-api
Update the application properties file with your PostgreSQL database configuration. Modify src/main/resources/application.properties
:
spring.datasource.url=jdbc:postgresql://localhost:5432/habit_tracker
spring.datasource.username=your_username
spring.datasource.password=your_password
Use Gradle to build the project:
./gradlew build
You can run the application using the following command:
./gradlew bootRun
Alternatively, if you prefer Docker, you can build and run the Docker container:
docker-compose up --build
The Habit Tracker API provides several endpoints for interacting with habits and users. Below are the main endpoints:
POST /api/auth/register
POST /api/auth/login
POST /api/habits
GET /api/habits
PUT /api/habits/{id}
DELETE /api/habits/{id}
POST /api/habits/{id}/checkin
GET /api/habits/{id}/streak
This project uses Flyway for database migrations. Flyway helps manage schema changes and ensures that the database is always up to date.
To apply migrations, run:
./gradlew flywayMigrate
The API uses JWT for user authentication. Upon successful login, the user receives a token that must be included in the header of subsequent requests:
Authorization: Bearer your_jwt_token
To run the application, ensure that your PostgreSQL database is running and accessible. Use the commands provided in the βGetting Startedβ section to build and run the application.
You can also run the application in Docker for a more streamlined setup. The Docker configuration is included in the repository.
The project includes unit and integration tests. To run the tests, use the following command:
./gradlew test
For integration tests, Testcontainers will spin up a PostgreSQL instance to ensure a clean environment for testing.
We welcome contributions to improve the Habit Tracker API. To contribute, please follow these steps:
Please ensure that your code adheres to the projectβs coding standards and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.
For more information, check the Releases section.