Skip to content

AlexALX/AI-Knowledge-Base

Repository files navigation

AI Knowledge Base with RAG

An AI-powered knowledge base built with FastAPI that combines Retrieval-Augmented Generation (RAG), document processing, semantic search, OCR, and web search into a single application.

The project demonstrates how to build an end-to-end AI application that can ingest documents, retrieve relevant knowledge, search the web, and provide context-aware responses using local LLMs.

Development Note

AI-assisted development was used throughout this project to accelerate research and implementation. The system architecture, technical decisions, code review process, debugging, integration, and final validation were carried out by the author.

Screenshots

Chat

Chat Interface


Purpose

This project was created primarily as a portfolio project to demonstrate practical skills as both a Backend Developer and an AI Engineer.

It showcases:

  • Designing AI-powered backend architectures
  • Building Retrieval-Augmented Generation (RAG) pipelines
  • Working with vector embeddings
  • Processing multiple document formats
  • OCR fallback for scanned PDFs
  • Integrating local Large Language Models
  • Building modular AI tools
  • Creating production-ready REST APIs

Features

AI Features

  • Retrieval-Augmented Generation (RAG)
  • Semantic document search
  • Vector embeddings (pgvector)
  • Local LLM integration via Ollama
  • AI tool routing
  • Built-in web search
  • Context retrieval from indexed documents

Document Processing

Supports ingestion of:

  • PDF
  • DOCX
  • TXT
  • MD (MarkDown)

PDF OCR

If a PDF page contains no extractable text, the system automatically falls back to OCR using:

  • pdf2image
  • Tesseract OCR

This allows scanned PDFs to be indexed together with normal text-based documents.


Technology Stack

Backend

  • FastAPI
  • SQLAlchemy
  • Alembic
  • PostgreSQL
  • pgvector

Frontend

  • Chat-based UI
  • Streaming responses (SSE)
  • Tailwind CSS
  • Alpine.js
  • JavaScript
  • Jinja2 templates

AI

  • Ollama
  • Vector embeddings
  • RAG pipeline
  • Semantic search

Search

  • SearXNG
  • Trafilatura (web content extraction)

Infrastructure

  • Docker
  • Docker Compose

Installation

Requirements

  • Docker
  • Docker Compose
  • Git

Windows

git clone https://github.com/AlexALX/ai-knowledge-base

cd AI-Knowledge-Base

powershell .\setup.ps1

Linux

git clone https://github.com/AlexALX/ai-knowledge-base

cd AI-Knowledge-Base

chmod +x setup.sh
./setup.sh

The setup script automatically:

  • creates required .env files (if missing)
  • prepares the project configuration
  • installs Python dependencies (if required)
  • runs database migrations
  • starts Docker services
  • performs the initial project setup

After installation, open:

Note

The first AI response after starting the application may take significantly longer than subsequent requests. This is expected, as the LLM needs to initialize and load the model into memory. Once loaded, future responses will be much faster.


AI Workflow

  1. Upload documents
  2. Extract text
  3. OCR scanned PDF pages when necessary
  4. Split documents into chunks
  5. Generate embeddings
  6. Store vectors in PostgreSQL (pgvector)
  7. Retrieve relevant chunks
  8. Optionally search the web
  9. Generate the final answer with the LLM

Project Highlights

This project demonstrates practical experience with:

  • Designing scalable REST APIs with FastAPI
  • Modular and maintainable backend architecture
  • Retrieval-Augmented Generation (RAG)
  • Hybrid search (semantic + keyword retrieval)
  • Embedding generation and vector search
  • PostgreSQL with pgvector
  • AI tool routing
  • Local LLM integration with Ollama
  • Streaming AI responses
  • Web search integration
  • Document ingestion pipeline
  • Multi-format document processing (PDF, DOCX)
  • OCR fallback for scanned PDFs
  • Automatic text chunking
  • Semantic document retrieval
  • Docker-based development and deployment
  • Database schema migrations with Alembic
  • Clean service-oriented architecture

About

AI Knowledge Base with RAG for portofio

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors