Skip to content

Tibiritabara/simple-rag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG Application with Python Backend and Next.js Frontend

This is a Retrieval-Augmented Generation (RAG) application that allows users to upload documents and query them using natural language. The application uses Azure OpenAI for embeddings and language model capabilities, with a vector database for efficient document retrieval.

Architecture

Backend (Python)

  • FastAPI for the REST API
  • LangChain and LlamaIndex for RAG capabilities
  • Azure OpenAI for embeddings and LLM
  • Weaviate as the vector database
  • Unstructured.io for document parsing
  • Temporal.io for workflow orchestration
  • MinIO for object storage
  • PostgreSQL for Temporal.io persistence

Frontend (Next.js)

  • Next.js 15.1 with TypeScript
  • TailwindCSS for styling
  • Dark/Light mode support
  • File upload and chat interface

Prerequisites

  • Docker and Docker Compose
  • Python 3.12+
  • Node.js 18+
  • Azure OpenAI API access

Getting Started

  1. First, start the required infrastructure using Docker Compose:
cd build
docker compose up -d

This will start:

  • Weaviate (Vector Database) - Port 8081
  • Unstructured API (Document Processing) - Port 8800
  • PostgreSQL (Database) - Port 5432
  • Temporal (Workflow Engine) - Port 7233
  • Temporal UI - Port 8233
  • MinIO (Object Storage) - Ports 9000, 9001
  1. Set up the backend:
cd backend

Create and activate a virtual environment

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate

Install dependencies

uv sync

Copy environment file and configure it

cp .env.dist .env

Edit .env with your Azure OpenAI and other credentials

Start the backend server

python -m uvicorn src.main:app --reload
  1. Set up the frontend:
cd frontend

Install dependencies

npm install

Copy environment file and configure it

cp .env.dist .env

Set NEXT_PUBLIC_BACKEND_URL to your backend URL (default: http://localhost:8000)

Start the development server

npm run dev
  1. Access the application:

Features

  • Document Upload: Upload and process various document types
  • Two Query Modes:
    • Simple: Direct RAG with Azure OpenAI
    • Agentic: Advanced RAG with multi-step reasoning
  • Source Attribution: See which documents were used to answer queries
  • Dark/Light Theme Support
  • Real-time Chat Interface

Environment Variables

The application requires several environment variables to be set. Check the following files for required variables:

  • Backend: backend/.env.dist
  • Frontend: frontend/.env.dist

Development

The project uses modern development tools and practices:

  • Ruff for Python linting and formatting
  • TypeScript for type-safe JavaScript
  • TailwindCSS for styling
  • Next.js App Router for frontend routing

License

This project is private and confidential. All rights reserved.

About

Simple RAG solution based on Weaviate, Unstructured, Temporal, FastAPI backend and NextJS frontend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors