Skip to main content

Overview

The Olis API Server is a FastAPI-based backend service that provides the core intelligence behind Olis. It includes a sophisticated RAG (Retrieval-Augmented Generation) pipeline for document understanding and intelligent responses.

Technology Stack

FastAPI

Modern, fast Python web framework

Uvicorn

Lightning-fast ASGI server

RAG Pipeline

Document retrieval and generation system

Vector Database

Semantic search capabilities

Project Structure

Development Setup

Prerequisites

  • Python 3.9+
  • pip or poetry
  • Redis (optional, for caching)
  • Vector database (optional, for RAG)

Installation

1

Navigate to the API server directory

2

Create a virtual environment (recommended)

3

Install dependencies

4

Set up environment variables

Create a .env file:
5

Run the server

The API will be available at http://localhost:8000.

API Endpoints

Core Endpoints

Health check endpointResponse:
Send a chat message and receive AI responseRequest:
Response:
Search documents semanticallyRequest:
Response:
Ingest documents into the RAG systemRequest: Multipart form data with file uploadsResponse:

Interactive API Documentation

FastAPI automatically generates interactive API documentation:
  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

RAG Pipeline

Architecture

Components

Process:
  1. Document upload via API
  2. Text extraction (PDF, DOCX, etc.)
  3. Chunking into manageable pieces
  4. Embedding generation
  5. Storage in vector database
Supported Formats:
  • PDF
  • DOCX
  • TXT
  • MD (Markdown)
  • JSON
  • CSV

RAG Preflight Testing

Before deploying, run the RAG preflight check to catch issues early:

Environment Overrides

What It Tests

  • All Python modules import successfully
  • No missing dependencies
  • Correct Python version
  • API server starts without errors
  • Database connections work
  • Redis cache is accessible
  • Vector database is reachable
  • Document ingestion pipeline
  • Query retrieval
  • Reranking functionality
  • End-to-end RAG flow

Docker Deployment

Local Development

Use Docker Compose for local development:
Start services:

Production Build

Build and run:

Testing

Running Tests

Test Structure

Configuration

Environment Variables

Performance Optimization

Caching

  • Redis for query results
  • Embedding cache
  • Response caching
  • Connection pooling

Async Operations

  • Async/await throughout
  • Non-blocking I/O
  • Background tasks
  • Parallel processing

Database Optimization

  • Connection pooling
  • Query optimization
  • Index management
  • Batch operations

Monitoring

  • Prometheus metrics
  • Request logging
  • Error tracking
  • Performance profiling

Troubleshooting

Problem: uvicorn fails to startSolution:
Problem: Module import failuresSolution:
Problem: Cannot connect to databaseSolution:
Problem: Document ingestion or retrieval failsSolution:
  1. Run preflight check: ./scripts/preflight_rag.sh
  2. Check vector database is running
  3. Verify embedding model is downloaded
  4. Check logs for specific errors
  5. Test with simple document first

Next Steps

API Reference

Explore detailed API documentation

Electron Client

Learn about the desktop client