GGD-github

Habit Tracker API - Your Personal Habit Tracking Solution πŸš€

Habit Tracker API Java Spring Boot PostgreSQL Docker

Download Latest Release

Table of Contents

Overview

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.

Features

Technologies

This project utilizes the following technologies:

Getting Started

To get started with the Habit Tracker API, follow these steps:

Prerequisites

Clone the Repository

Clone the repository to your local machine:

git clone https://github.com/GGD-github/habit-tracker-api.git
cd habit-tracker-api

Configuration

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

Build the Project

Use Gradle to build the project:

./gradlew build

Run the Application

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

API Endpoints

The Habit Tracker API provides several endpoints for interacting with habits and users. Below are the main endpoints:

User Endpoints

Habit Endpoints

Check-In Endpoints

Streak Endpoints

Database Migration

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

Authentication

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

Running the Application

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.

Testing

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.

Contributing

We welcome contributions to improve the Habit Tracker API. To contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push your branch to your fork.
  5. Open a pull request.

Please ensure that your code adheres to the project’s coding standards and includes appropriate tests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

For more information, check the Releases section.