Skip to content

A Spring Boot application with a PostgreSQL database and authentication (session), offering a digital phonebook for efficient contact management. Built with technologies like Kotlin, PostgreSQL, Flyway, Lombok, and Gradle.

Notifications You must be signed in to change notification settings

Bohdan100/phonebook-api

Repository files navigation

Phonebook Application

The Phonebook Application is a Spring Boot application written in Kotlin that provides RESTful API endpoints for managing contacts in a digital phonebook. The application features its own user authentication mechanism utilizing tokens and session identifiers. The AuthAPI includes endpoints for user registration, login, and logout. Users can create, edit, or delete contacts and search for them based on various criteria. All data is securely stored in a PostgreSQL database.

Features

  • Authentication API powered by Spring Security, featuring a custom JWT filter.
  • Secure, token-based authentication implemented using JWT (JSON Web Tokens).
  • Session management with session expiration checks, integrated via cookies.
  • CRUD operations for contacts (add, update, view, and delete) available through RESTful API endpoints.
  • Structured and organized data storage backed by PostgreSQL.
  • DEfficient database versioning and migrations with Flyway.
  • Reduced boilerplate code through the use of Lombok.
  • Streamlined setup and build processes using Gradle.
  • Ensure code quality and correctness with JUnit 5 tests.

Requirements

The application is built using the following technologies:

  • Spring Boot: 3.3.5
  • Kotlin: 1.9.25
  • Java Platform (JDK): 21
  • PostgreSQL: 16.6
  • Flyway: 11.0.1
  • Lombok: 1.18.36
  • JUnit: 5
  • Gradle: 8.8

Database Setup

Before running the application, follow these steps to set up the database:

  1. Create a PostgreSQL 16 Database
    Set up a PostgreSQL database to store the application’s data.

  2. Configure Database and User
    Perform the following steps in your PostgreSQL instance to create a user and database for the application:

    1. Create a new user with a password:

      CREATE USER IF NOT EXISTS admin WITH PASSWORD 'secret1234';
    2. Create a new database and assign ownership of the database to the new user:

      CREATE DATABASE phonebook ENCODING 'UTF8' OWNER admin;
  3. Connect to the Database
    To connect to the phonebook database as the admin user, use the following command in the terminal:

    psql -U admin -d phonebook
    

Getting Started

  1. Clone the repository:
    git clone https://github.com/Bohdan100/phonebook-api
    cd phonebook
    
  2. Build and run the application in terminal using Gradle:
    .\gradlew bootRun     (Windows)
    ./gradlew bootRun     (Linux)
    
  3. Build and run the application in terminal using JAR file:
    .\gradlew bootJar     (Windows)
    ./gradlew bootJar     (Linux)
    
    java -jar phonebook-api.jar
    
  4. Make your HTTPS requests using the following endpoints (e.g., via Postman):

About

A Spring Boot application with a PostgreSQL database and authentication (session), offering a digital phonebook for efficient contact management. Built with technologies like Kotlin, PostgreSQL, Flyway, Lombok, and Gradle.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published