Skip to main content

Get up and running

This guide will walk you through setting up Filebright and uploading your first document to chat with it using AI.
1

Clone the repository

Clone the Filebright repository to your local machine:
git clone https://github.com/your-org/filebright.git
cd filebright
2

Install dependencies

Install both backend and frontend dependencies:
cd backend
composer install
3

Configure environment

Copy the example environment file and configure your settings:
cd backend
cp .env.example .env
php artisan key:generate
Update your .env file with the required credentials:
.env
# Database Configuration
DB_CONNECTION=sqlite
# Or use PostgreSQL for production
# DB_CONNECTION=pgsql
# DB_HOST=127.0.0.1
# DB_PORT=5432
# DB_DATABASE=filebright

# MongoDB for Vector Storage
MONGODB_URI=mongodb://localhost:27017
MONGODB_DATABASE=filebright

# OpenRouter API Configuration
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_EMBEDDING_MODEL=text-embedding-3-small
OPENROUTER_CHAT_MODEL=openai/gpt-3.5-turbo

# Queue Configuration
QUEUE_CONNECTION=database
You must configure OPENROUTER_API_KEY to enable document vectorization and chat features. Get your API key from OpenRouter.
4

Set up the database

Run migrations to create the database schema:
php artisan migrate
This creates tables for users, documents metadata, sessions, and queue jobs.
5

Start the development servers

Filebright requires multiple services running simultaneously. Use the built-in development script:
composer run dev
The composer run dev script uses concurrently to run all services in one terminal with colored output for easy monitoring.

Your first document

Now that Filebright is running, let’s upload a document and chat with it.
1

Create an account

Navigate to http://localhost:80 and create a new account. Filebright uses Laravel Sanctum for authentication.The registration endpoint is:
POST /api/register
With body:
{
  "name": "Your Name",
  "email": "[email protected]",
  "password": "securepassword",
  "password_confirmation": "securepassword"
}
2

Upload a document

From the dashboard, drag and drop a PDF or TXT file onto the upload zone, or click to browse.Upload ZoneThe document is uploaded via the API:
DocumentController.php
public function upload(Request $request)
{
    $request->validate([
        'file' => 'required|file|mimes:pdf,txt|max:102400',
    ]);

    $file = $request->file('file');
    $path = $file->store('documents', 'private');

    $document = DocumentMetadata::create([
        'user_id' => $request->user()->id,
        'filename' => $file->getClientOriginalName(),
        'mime_type' => $file->getMimeType(),
        'path' => $path,
        'status' => 'pending',
    ]);

    ProcessDocument::dispatch($document);

    return response()->json([
        'message' => 'File uploaded successfully',
        'document' => $document
    ], 201);
}
Maximum file size is 100MB. Supported formats: PDF and TXT.
3

Watch the processing

After upload, the document goes through several processing stages:
  • Pending: Document is queued for processing
  • Parsing: Extracting text from PDF/TXT
  • Vectorizing: Generating embeddings for text chunks
  • Indexing: Storing vectors in MongoDB
  • Completed: Ready for chat!
The UI automatically polls for status updates every 3 seconds:
documentStore.js
async startPolling() {
  if (this.isPolling) return
  this.isPolling = true
  
  const poll = async () => {
    const activeStatuses = ['pending', 'processing', 'parsing', 'vectorizing', 'indexing']
    const hasProcessing = this.documents.some(d => activeStatuses.includes(d.status))
    if (!hasProcessing) {
      this.isPolling = false
      return
    }

    const data = await apiClient.get('/documents')
    if (data) this.documents = data
    
    if (this.isPolling) setTimeout(poll, 3000)
  }
  
  poll()
}
Processing time depends on document size. A typical 10-page PDF takes 5-15 seconds to complete.
4

Start chatting

Once the document status is “Completed”, navigate to the Chat tab and ask questions about your document.Try questions like:
  • “What is this document about?”
  • “Summarize the main points”
  • “What does it say about [specific topic]?”
Behind the scenes, Filebright:
  1. Embeds your query using the same embedding model
  2. Performs vector similarity search in MongoDB
  3. Retrieves the top 3 most relevant chunks
  4. Sends the chunks as context to the LLM
  5. Returns the AI-generated answer
RAGService.php
public function answer(string $query, int $userId): string
{
    $queryEmbedding = $this->embeddingService->getEmbedding($query);

    if (empty($queryEmbedding)) {
        return "I'm sorry, I couldn't process your request at the moment.";
    }

    $chunks = $this->retrieveContext($queryEmbedding, $userId);

    if ($chunks->isEmpty()) {
        return "I couldn't find any relevant information in your documents to answer that.";
    }

    $context = $chunks->pluck('content')->implode("\n\n---\n\n");

    return $this->getLLMResponse($query, $context);
}

Using the API

You can also interact with Filebright programmatically. Here’s how to upload a document and chat via API:
curl -X POST http://localhost:8000/api/upload \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@/path/to/document.pdf"

Next steps

Installation guide

Learn about production deployment and Docker setup

API reference

Explore all available endpoints and their parameters

Configuration

Customize AI models, vector search, and application behavior

Architecture

Deep dive into how Filebright processes and retrieves documents

Build docs developers (and LLMs) love