Skip to content

abhijeet-Bh/hatio-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Hatio Assignment - Todo App

Spring Boot Badge Spring Security Badge Spring Badge OpenJDK Badge PostgreSQL Badge Docker Badge

Overview

This project is a backend service built using Spring Boot and Java. It exposes RESTful API endpoints for managing resources in a PostgreSQL database. The application is containerized using Docker, enabling easy deployment and scaling.

For Security of endpoints and app, This project implements spring-security. All endpoints (if required) are secured to be accessed by only authentic users.

Documentation

Postman

Project Dependencies

  • Java: opne jdk: v22.0.
  • Spring Boot: v3.3.3.
  • PostgreSQL: v16.0.
  • Docker: with docker-compose v3.0.
  • Maven: v4.0.0.

Features

  • RESTful API endpoints for CRUD operations.
  • User authentication and authorization.
  • Integration with PostgreSQL for persistent storage.
  • Dockerized application for easy deployment.

Getting Started

1. Clone this repository

https://github.com/abhijeet-Bh/hatio-assignment.git

2. Build the application

./mvnn clean install

3. Running the Application

You can run the application using Maven or Docker.

A. Running with Maven:

  1. Download & Install PostgreSQL database

  2. Connect to the PostgreSQL database:

    Ensure PostgreSQL is running and configured as per application.properties.

    spring.application.name=app
    spring.datasource.url=jdbc:postgresql://localhost:5432/<your-database-name>
    spring.datasource.username=<your-db-usename>
    spring.datasource.password=<your-password>
    spring.datasource.driver-class-name=org.postgresql.Driver
    
    ## Hibernate (JPA) Properties
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
  3. Run the Spring Boot application:

    ./mvnw spring-boot:run

    The application will start on http://localhost:8080.


B. Running with Docker:

  1. Build and run the Docker containers:

    To run with docker-compose, you just need to setup .env file in the root directory as given below

    # PostgreSQL database configuration for Docker
    POSTGRES_DB=<your-db-name>
    POSTGRES_USER=<your-db-user>
    POSTGRES_PASSWORD=<your-db-password>
    SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/<your-db>
    SPRING_DATASOURCE_USERNAME=<your-db-name>
    SPRING_DATASOURCE_PASSWORD=<your-db-user>
    SPRING_JPA_HIBERNATE_DDL_AUTO=update

    Now, you can run below command to run Todo app :)

    docker-compose up --build

This command will start the Spring Boot application and PostgreSQL database in Docker containers.

API Documentation

Endpoints

Here’s a list of all API endpoints for the Todo App Backend. These endpoints cover the main functionalities for managing projects, todos, exporting project-summary as gist or downloading it.

1. Public Endpoints

These endpoints handle public-related operations such as health-check and login.

HTTP Method Endpoint Description Access Role
GET /api/v1/healthz Check running status of the backend OPEN
POST /api/v1/auth/signup Create New User Account OPEN
POST /api/v1/auth/login CLogin User with username & password OPEN

2. Projects Endpoints

These endpoints handle project-related operations for managing the project.

HTTP Method Endpoint Description Access Role
GET /api/v1/projects Get All Projects Authenticated
POST /api/v1/projects Create New Project Authenticated
PUT /api/v1/projects Update New Project Authenticated
GET /api/v1/projects/{id} Get Project by Id Authenticated
DELETE /api/v1/projects/{id} Delete Project by Id Authenticated

3. Todo Endpoints

These endpoints handle Todo-related operations for managing the project.

HTTP Method Endpoint Description Access Role
GET /api/v1/projects/{project-Id}/todos Get All Todos of the particular project Authenticated
POST /api/v1/projects/{project-Id}/todos Create New todo for the particular project Authenticated
PATCH /api/v1/projects/{project-Id}/todos/{todo-Id}/complete Mark a todo complete Authenticated
PATCH /api/v1/projects/{project-Id}/todos/{todo-Id}/pending Mark a todo pending Authenticated
PUT /api/v1/projects/{project-Id}/todos/{todo-Id} Update Todo Authenticated
DELETE /api/v1/projects/{project-Id}/todos/{todo-Id} Delete Todo by Id Authenticated

4. Gists Endpoints

These endpoints handle gist-related operations for downloading and exporting the the project-summary.

HTTP Method Endpoint Description Access Role
GET /api/v1/projects/{project-Id}/download-summary Download project-summary Authenticated
POST /api/v1/projects/{project-Id}/export-gist?githubToken=your-token Export Project Summary to giHub gist Authenticated

Gist that i created while developing this project is here

Thanks :)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published