Skip to content

raffeekk/backend-codex-task

Repository files navigation

This is my project for codex

Overview

The Codex Document Management System is a RESTful API built with Java and Spring Boot. It allows users to create, update, search, and manage documents in a PostgreSQL database, while also indexing and searching through them using Elasticsearch.

Features

  • Save Documents: Create and store documents with titles and content.
  • Update Documents: Patch existing documents to modify their titles and content.
  • Search Documents: Perform full-text search across documents, prioritizing titles over content.
  • Integration with Elasticsearch: Search functionality leverages Elasticsearch for efficient querying.

Technologies Used

  • Java 17
  • Spring Boot
  • PostgreSQL
  • Elasticsearch
  • Gradle

Getting Started

Prerequisites

  • Java 17
  • PostgreSQL
  • Elasticsearch

Installation

  1. Clone the repository:

    cd your-repo
    git clone https://github.com/raffeekk/backend-codex-task.git
  2. Configure your PostgreSQL database:

    • Create a database (e.g., codex_db).
    • Update the database connection settings in src/main/resources/application.properties.
  3. Run Elasticsearch locally.

  4. Build the project:

    ./gradlew build
  5. Start the application:

    ./gradlew bootRun

API Endpoints

Save Document

  • Endpoint: POST /document
  • Request Body:
    {
      "title": "Document Title",
      "content": "Document content goes here."
    }
  • Response:
    {
      "id": 1,
      "title": "Document Title",
      "content": "Document content goes here."
    }

Update Document

  • Endpoint: PATCH /document
  • Request Body:
    {
      "documentId": 1,
      "document": {
        "title": "Updated Title",
        "content": "Updated content goes here."
      }
    }
  • Response:
    {
      "id": 1,
      "title": "Updated Title",
      "content": "Updated content goes here."
    }

Search Documents

  • Endpoint: POST /document/search
  • Request Body:
    {
      "querystring": "search term"
    }
  • Response:
    [
      {
        "id": 1,
        "title": "Document Title",
        "content": "Document content goes here."
      }
    ]

Running Tests

To run tests, use:

./gradlew test

Acknowledgments

About

ElasticSearch + PostgreSQL + Spring Boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published