Skip to content

Knowledge Base API

πŸ“š

A comprehensive knowledge management REST API built with Java, Spring Boot, and PostgreSQL. Manages articles, documentation, FAQs, categories, and full-text search capabilities.


Features

Feature Description Icon
Article Management Create, edit, organize, and archive knowledge articles πŸ“„
Category Organization Organize articles in hierarchical categories and tags 🏷️
Full-Text Search Powerful search with relevance scoring πŸ”
Version Control Track article revisions and change history πŸ“œ
User Permissions Control who can view, edit, and publish articles πŸ”
Comments & Feedback Gather user feedback on articles πŸ’¬
Multi-Tenant Support Isolate knowledge bases per tenant 🏒

Architecture Overview

flowchart TD
    A[Client] -->|REST API| B(KnowledgeController)
    B --> C[ArticleService]
    C --> D[SearchService]
    C --> E[CategoryService]
    D --> F[ArticleRepository]
    D --> G[SearchIndex]
    E --> H[CategoryRepository]
    F --> I[(PostgreSQL)]
    H --> I
    G --> J[Elasticsearch]
Hold "Alt" / "Option" to enable pan & zoom

API Endpoints

Note: Real API endpoints to be provided and included here.

Method Endpoint Description Notes/Parameters
POST /api/v1/articles Create article tenantId header, article content
GET /api/v1/articles/{id} Get article details
PUT /api/v1/articles/{id} Update article Updated content
POST /api/v1/articles/{id}/publish Publish article

Sequence: Publish Article

sequenceDiagram
    participant U as User
    participant API as KnowledgeController
    participant A as ArticleService
    participant S as SearchService
    participant Repo as ArticleRepository
    participant I as SearchIndex
    U->>API: POST /articles/{id}/publish
    API->>A: validate article
    A->>Repo: update status
    Repo-->>A: article published
    A->>S: index article
    S->>I: add to search index
    I-->>S: indexed
    S-->>A: index confirmed
    A-->>API: ArticleResponse
    API-->>U: 200 OK + published article
Hold "Alt" / "Option" to enable pan & zoom

Database Schema

erDiagram
    articles {
        UUID id PK
        UUID tenant_id
        VARCHAR title
        TEXT content
        UUID author_id
        UUID category_id FK
        VARCHAR status
        TIMESTAMP published_at
        TIMESTAMP created
        TIMESTAMP updated
    }

    categories {
        UUID id PK
        UUID tenant_id
        VARCHAR category_name
        UUID parent_id FK
        INTEGER display_order
        TIMESTAMP created
    }

    article_versions {
        UUID id PK
        UUID article_id FK
        TEXT content
        VARCHAR version_number
        VARCHAR changed_by
        TIMESTAMP created
    }

    article_comments {
        UUID id PK
        UUID article_id FK
        UUID user_id
        TEXT comment
        TIMESTAMP created
    }

    articles ||--o{ article_versions : "has"
    articles ||--o{ article_comments : "receives"
    categories ||--o{ articles : "contains"
Hold "Alt" / "Option" to enable pan & zoom

Getting Started

Prerequisites

  • Java 17+
  • PostgreSQL
  • Gradle

Setup

git clone https://github.com/Olanna-tech/knowledge-base-java.git
cd knowledge-base-java
./gradlew build

Database

  • Configure your PostgreSQL credentials in src/main/resources/application.yml.
  • Run Flyway migrations (auto on startup).

Run

./gradlew bootRun

Configuration

Set the following environment variables in application.yml:

knowledge-base:
  search-engine: elasticsearch
  elasticsearch-url: http://localhost:9200
  max-article-size-mb: 10
  enable-versioning: true
  comments-enabled: true


Contributing

Pull requests are welcome! For major changes, please open an issue first.


License

MIT


Contact