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.
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
- 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
Supports ingestion of:
- DOCX
- TXT
- MD (MarkDown)
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.
- FastAPI
- SQLAlchemy
- Alembic
- PostgreSQL
- pgvector
- Chat-based UI
- Streaming responses (SSE)
- Tailwind CSS
- Alpine.js
- JavaScript
- Jinja2 templates
- Ollama
- Vector embeddings
- RAG pipeline
- Semantic search
- SearXNG
- Trafilatura (web content extraction)
- Docker
- Docker Compose
- Docker
- Docker Compose
- Git
git clone https://github.com/AlexALX/ai-knowledge-base
cd AI-Knowledge-Base
powershell .\setup.ps1git clone https://github.com/AlexALX/ai-knowledge-base
cd AI-Knowledge-Base
chmod +x setup.sh
./setup.shThe setup script automatically:
- creates required
.envfiles (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:
- FastAPI — http://localhost:8000
- API Docs — http://localhost:8000/docs
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.
- Upload documents
- Extract text
- OCR scanned PDF pages when necessary
- Split documents into chunks
- Generate embeddings
- Store vectors in PostgreSQL (pgvector)
- Retrieve relevant chunks
- Optionally search the web
- Generate the final answer with the LLM
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
