Skip to content

shknth/lumina

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lumina 🌟

A CLaRa-Inspired RAG Chat Application Powered by Mistral AI

License Python Next.js

FeaturesQuick StartArchitectureUsageDeployment


Overview

Lumina is a RAG chat application like notebooklm that implements the CLaRa (Classification and Retrieval Augmented) approach for enhanced information retrieval (https://arxiv.org/abs/2511.18659). Built with Mistral AI's state-of-the-art language models, Lumina transforms your documents into an intelligent knowledge base that powers contextual conversations.

What Makes Lumina Different?

Unlike traditional RAG systems that embed raw text chunks, Lumina uses CLaRa-style evidence generation:

  • Compressed Summaries: Each chunk is distilled into factual summaries
  • QA Pairs: Automatically generated question-answer pairs for better retrieval
  • Precise Retrieval: Search optimized evidence instead of raw text
  • Source Citations: Every response includes traceable sources

Features

Core Capabilities

  • Intelligent Chat Interface

    • Real-time streaming responses from Mistral AI
    • Toggle between standard and RAG-enhanced modes
    • Clean, modern UI with dark mode support
  • Smart Document Processing

    • Support for PDF and TXT files
    • Intelligent text chunking with sentence boundary detection
    • Automatic evidence generation (summaries + QA pairs)
    • Progress tracking for document ingestion
  • Advanced RAG System

    • FAISS vector database for fast similarity search
    • Mistral embeddings (1024 dimensions)
    • Top-k retrieval with relevance scoring
    • Citation tracking with source document references
  • Knowledge Management

    • Upload and process multiple documents
    • View processing status in real-time
    • Delete documents with automatic cleanup
    • Persistent storage with SQLite

Tech Stack

Backend

  • Framework: FastAPI (high-performance async API)
  • Database: SQLAlchemy + SQLite (easily migrates to PostgreSQL)
  • Vector Store: FAISS (Facebook AI Similarity Search)
  • Embeddings: Mistral Embed (mistral-embed)
  • LLM: Mistral Small (mistral-small-latest)
  • Package Manager: uv (ultra-fast Python package installer)

Frontend

  • Framework: Next.js 14 (React 18, App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: Custom components with dark mode
  • HTTP Client: Fetch API with SSE (Server-Sent Events)

Quick Start

Prerequisites

  • Python 3.11 or higher
  • Node.js 18 or higher
  • Mistral AI API key (Get one here)
  • uv package manager (Install uv)

Installation

1. Clone the Repository

git clone https://github.com/yourusername/lumina.git
cd lumina

2. Backend Setup

cd backend

# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e .

# Configure environment
cp .env.example .env
# Edit .env and add your MISTRAL_API_KEY

3. Frontend Setup

cd frontend

# Install dependencies
npm install

# Optional: Configure API URL (defaults to http://localhost:8000)
echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local

4. Run the Application

Terminal 1 - Backend:

cd backend
uv run fastapi dev app/main.py
# Backend runs on http://localhost:8000

Terminal 2 - Frontend:

cd frontend
npm run dev
# Frontend runs on http://localhost:3000

Visit http://localhost:3000 to start chatting!


Usage

1. Upload Documents

  1. Navigate to Manage Knowledge from the homepage
  2. Click Choose File and select a PDF or TXT file (max 1MB for now)
  3. Click Upload Document
  4. Wait for processing to complete (status will show "completed")

2. Chat with Your Knowledge Base

  1. Return to the chat interface
  2. Toggle Use Knowledge Base ON
  3. Ask questions about your uploaded documents
  4. View citations below each response showing source documents and relevance scores

3. Standard Chat

  • Toggle Use Knowledge Base OFF for standard Mistral AI chat
  • Great for general questions not requiring your documents

Architecture

System Design

┌─────────────────┐         ┌──────────────────┐
│   Next.js       │ HTTP/SSE│   FastAPI        │
│   Frontend      │◄────────┤   Backend        │
│   (Port 3000)   │         │   (Port 8000)    │
└─────────────────┘         └──────────────────┘
                                     │
                    ┌────────────────┼────────────────┐
                    ▼                ▼                ▼
              ┌──────────┐    ┌──────────┐    ┌──────────┐
              │ SQLite   │    │  FAISS   │    │ Mistral  │
              │ Database │    │  Vectors │    │   API    │
              └──────────┘    └──────────┘    └──────────┘

Data Flow

Document Ingestion:

Upload → Parse (PDF/TXT) → Chunk (512 chars) → Generate Evidence →
Create Embeddings → Store in FAISS + SQLite

RAG Chat:

User Query → Embed Query → Search FAISS (top-5) → Retrieve Evidence →
Inject Context → Mistral Chat → Stream Response + Citations

Database Schema

  • Documents: Uploaded files with metadata and processing status
  • Chunks: Text segments from documents with position tracking
  • Evidence: Generated summaries and QA pairs for each chunk
  • EmbeddingMetadata: FAISS index mapping and embedding details

Configuration

Backend Environment Variables

Create backend/.env:

# Required
MISTRAL_API_KEY=your_mistral_api_key_here

# Optional - Models
MISTRAL_CHAT_MODEL=mistral-small-latest
MISTRAL_EMBEDDING_MODEL=mistral-embed

# Optional - Processing
CHUNK_SIZE=512
CHUNK_OVERLAP=128
EVIDENCE_QA_PAIRS=3

# Optional - Storage
DATABASE_URL=sqlite:///./lumina.db
VECTOR_STORE_PATH=./vector_store
VECTOR_DIMENSION=1024

Frontend Environment Variables

Create frontend/.env.local:

NEXT_PUBLIC_API_URL=http://localhost:8000

Deployment

Docker Deployment

# Build and run with docker-compose
export MISTRAL_API_KEY=your_key_here
docker-compose up --build

# Access at http://localhost:3000

Production Considerations

Backend:

  • Migrate to PostgreSQL + pgvector for production scale
  • Use Redis for caching
  • Deploy on Cloud Run, Fly.io, or Railway
  • Enable CORS for your frontend domain

Frontend:

  • Deploy to Vercel or Netlify
  • Set NEXT_PUBLIC_API_URL to your backend URL
  • Enable production optimizations

API Documentation

Once the backend is running, visit:

Key Endpoints

  • POST /api/chat/stream - Streaming chat with optional RAG
  • POST /api/knowledge/upload - Upload document
  • GET /api/knowledge/documents - List documents
  • DELETE /api/knowledge/documents/{id} - Delete document

Development

Project Structure

lumina/
├── backend/
│   ├── app/
│   │   ├── api/          # API routes
│   │   ├── clients/      # External API clients (Mistral)
│   │   ├── core/         # Config, logging
│   │   ├── db/           # Database models, vector store
│   │   ├── schemas/      # Pydantic models
│   │   ├── services/     # Business logic
│   │   └── utils/        # Utilities (chunking, parsing)
│   ├── pyproject.toml    # Python dependencies
│   └── .env.example
│
├── frontend/
│   ├── src/
│   │   ├── app/          # Next.js pages
│   │   ├── components/   # React components
│   │   └── lib/          # API client, utilities
│   ├── package.json      # Node dependencies
│   └── tailwind.config.ts
│
├── docker-compose.yml    # Docker orchestration
├── LICENSE               # Apache 2.0
└── README.md

Code Style

  • Backend: Follow PEP 8
  • Frontend: ESLint + Prettier
  • Commits: Conventional Commits

Troubleshooting

Common Issues

Backend won't start:

  • Verify Python 3.11+ is installed
  • Check .env has valid MISTRAL_API_KEY
  • Ensure port 8000 is not in use

Frontend won't connect:

  • Verify backend is running on port 8000
  • Check NEXT_PUBLIC_API_URL in .env.local
  • Clear browser cache

Document processing stuck:

  • Check backend logs for errors
  • Verify Mistral API key has sufficient quota
  • Try with smaller documents first

No citations appearing:

  • Ensure documents are fully processed (status: "completed")
  • Verify "Use Knowledge Base" toggle is ON
  • Check that your query relates to uploaded documents

Roadmap

  • Multi-file upload with batch processing
  • Support for additional file formats (DOCX, HTML, Markdown)
  • Advanced filtering (search specific documents)
  • Chat history persistence
  • User authentication
  • PostgreSQL + pgvector migration
  • Conversation memory and context management

Contributing

Contributions are welcome! This is a portfolio project, but feel free to:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Copyright 2026 Lumina Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Acknowledgments

  • Mistral AI for providing powerful open-weight models and APIs
  • CLaRa Paper for the evidence generation approach from apple research.
  • FAISS by Facebook AI Research for efficient vector search
  • FastAPI and Next.js communities for excellent frameworks

Contact

Built by Shashikanth Bokka.


⭐ Star this repo if you find it useful! ⭐

Made with ❤️ using Mistral AI

Releases

No releases published

Packages

 
 
 

Contributors