BACR Website Documentation

Comprehensive documentation for website content based on the BACR application

// Getting Started

Overview

BACR (Bot Assistant with Contextual Retrieval) is a sophisticated AI chat assistant that combines advanced document processing, intelligent query routing, and persistent memory. Built with Python, Flet, LangGraph, and FAISS, BACR provides a powerful desktop AI assistant experience with local document understanding capabilities.

Key Highlights:

  • 🤖 Multi-model AI routing with automatic query classification
  • 📚 Hybrid RAG system with vector search and AI reranking
  • 💾 Cross-session memory that learns from your conversations
  • 🎨 Modern desktop GUI with theme support
  • 🔐 Secure Google OAuth authentication
  • 📊 Real-time token usage and cost tracking

Why BACR?

For Developers:

  • Local document processing without sending files to external APIs
  • Intelligent code-aware routing for programming questions
  • Multi-format support (PDF, DOCX, TXT, MD, and more)
  • Persistent conversation history across sessions

For Researchers:

  • Advanced RAG with Jina AI reranking for accurate document retrieval
  • Citation tracking - only cited sources are shown
  • Cross-session memory for building knowledge over time
  • Export conversations to PDF for documentation

For Teams:

  • User-isolated databases for privacy
  • Server-managed API keys for easy deployment
  • Zero Data Retention (ZDR) mode for privacy-conscious users
  • Cost tracking per query for budget management

Features

AI & Intelligence

  • Two-Stage Smart Routing: Queries are automatically classified and routed to the optimal model
    • Stage 1: File management → RAG (document search) → Direct LLM
    • Stage 2: Coding → Reasoning → Chat → Research
  • Models Integration: Access to 200+ AI models including GPT-4, Claude, Gemini, DeepSeek, and more
  • Real-time Streaming: Token-by-token responses with live status updates
  • Cost Tracking: Monitor token usage and costs per query with detailed breakdowns
  • Model Modes: Switch between ZDR and Non-ZDR

Document Processing (RAG)

  • Hybrid Search: Combines vector similarity with Jina AI reranking
  • Local Embeddings: Uses a local embedding GGUF model - no API calls for embeddings
  • Smart Filtering: Relevance threshold automatically removes irrelevant chunks
  • Intelligent Citations: LLM cites sources as (Doc 1), (Doc 2); only cited sources are displayed
  • Persistent Storage: User-specific FAISS indexes saved to ~/.bacr/user_databases/
  • Multi-Format Support: PDF, TXT, MD, DOCX, XLSX, PPTX, RTF, CSV, JSON, YAML, and more

Memory & Context

  • Cross-Session Memory: LangMem semantic memory that persists across all conversations
  • User-Specific Databases: Isolated SQLite databases per user for privacy
  • Persistent History: All conversations saved and searchable
  • Context-Aware: Each session maintains independent context with file tracking

User Interface

  • Modern Flet GUI: Clean, responsive desktop interface built with Flutter
  • Theme Support: Light, dark, and system themes (persists across restarts)
  • Tabbed Sessions: Multiple independent conversations with easy switching
  • Font Size Control: Adjustable text size with visual controls
  • Status Bar: Real-time file count, token usage, and credit balance
  • Export Mode: Select and export specific messages to PDF

Authentication & Security

  • Google OAuth: Secure login with auto-login support using refresh tokens
  • Profile Pictures: Fetched fresh from Google on each login
  • User Isolation: All data separated by user account
  • Privacy Protection: User data is isolated

Architecture

BACR is built with a modular architecture that separates concerns and enables easy maintenance:

Frontend Layer:

  • Flet-based GUI with reactive components
  • Google OAuth integration for authentication
  • Real-time status updates and streaming responses
  • Theme and preference management

Core Layer:

  • LangGraph-based conversation management
  • Two-stage intelligent routing system
  • Hybrid RAG with vector search and reranking
  • Cross-session memory with LangMem

Backend Layer:

  • Server API client for authentication and API key management
  • Model manager with ZDR/Non-ZDR mode switching
  • Multi-model access
  • Token usage tracking and cost calculation

Storage Layer:

  • User-specific SQLite databases
  • FAISS vector indexes for document embeddings
  • Local file system for document caching
03

Installation

Requirements

System Requirements:

  • Operating System: Windows 10/11, Linux (Ubuntu 20.04+, Fedora, Arch), macOS 11+
  • Python: 3.9 or higher
  • RAM: 4GB minimum, 8GB recommended
  • Disk Space: 2GB for application and dependencies
  • Internet: Required for authentication and API access

Windows

Linux

MacOS

Not available

04

CLI Reference

Commands

BACR provides a comprehensive set of slash commands for managing files, sessions, and conversations.

File Management

/add <filepath>

  • Add a document to the RAG system for context
  • Supports: PDF, TXT, MD, DOCX, XLSX, PPTX, RTF, CSV, JSON, YAML
  • Example: /add C:\Documents\report.pdf
  • Creates embeddings and indexes document for search

/remove <filename>

  • Remove a specific file from the RAG system
  • Example: /remove report.pdf
  • Removes embeddings and frees memory

/files

  • List all files currently in the RAG system
  • Shows file names and chunk counts
  • Displays total context size

/clear

  • Remove all files from the RAG system
  • Clears all document embeddings
  • Does not clear chat history

Session Management

/new-chat or Ctrl+N

  • Start a new conversation in a new tab
  • Creates independent context
  • Previous sessions remain accessible

/close-tab or Ctrl+W

  • Close the current conversation tab
  • Saves conversation to database
  • Cannot close last tab

/list-chats

  • Show all saved conversations
  • Displays session names and timestamps
  • Shows message counts

/load-chat <name_or_id>

  • Load a conversation into the current tab
  • Replaces current conversation
  • Example: /load-chat Project Discussion

/open-chat <name_or_id>

  • Open a conversation in a new tab
  • Keeps current conversation
  • Example: /open-chat Meeting Notes

/rename-chat <new_name>

  • Rename the current conversation
  • Example: /rename-chat Q1 Planning
  • Cannot rename temporary sessions

/delete-chat <name_or_id>

  • Delete a saved conversation permanently
  • Example: /delete-chat Old Notes
  • Cannot be undone

Chat History

/clear-chat or /clear

  • Clear the chat history for current conversation
  • Removes all messages from display and state
  • Does not delete saved conversation
  • Files remain in context

/export-chat

  • Export current conversation to a file
  • Saves as timestamped text file
  • Includes all messages and metadata
  • Location: ~/.bacr/exports/

/import-chat <filepath>

  • Import a conversation from a file
  • Supports TXT and PDF formats
  • Adds to current conversation
  • Example: /import-chat notes.txt

Utilities

/tokens

  • Show token usage for current conversation
  • Displays input, output, and total tokens
  • Shows estimated costs
  • Aggregates across all sessions

/find <query>

  • Search across all conversation history
  • Opens search interface
  • Highlights matching messages
  • Example: /find API documentation

/help

  • Opens help page in browser
  • Shows all available commands
  • Includes examples and descriptions

/quit

  • Close the application
  • Saves all conversations
  • Clears API keys from memory

Configuration

Theme Toggle

  • Click theme icon in top bar
  • Switches between light/dark
  • Preference persists across restarts

Font Size

  • Click font size buttons in top bar
  • Adjusts text size for all messages
  • Range: 12px to 20px

ZDR Mode Toggle

  • Click ZDR toggle in settings
  • Switches between free and premium models
  • Clears model cache on switch

Shell Commands

BACR supports common shell commands for file system navigation:

cd <directory>

  • Change current working directory
  • Example: cd Documents
  • Affects file operations

ls or dir

  • List files in current directory
  • Shows file names and sizes

pwd

  • Print working directory
  • Shows current path

cat <file>

  • Display file contents
  • Example: cat notes.txt

mkdir <directory>

  • Create new directory
  • Example: mkdir projects

rm <file>

  • Remove file (use with caution)
  • Example: rm temp.txt

cp <source> <dest>

  • Copy file
  • Example: cp file.txt backup.txt

mv <source> <dest>

  • Move or rename file
  • Example: mv old.txt new.txt

etc

Usage Examples

Basic Chat:

User: What is machine learning?
BACR: [Streams response with real-time status]

Document Processing:

User: /add C:\Reports\Q4_Analysis.pdf
BACR: ✔︎ Successfully added Q4_Analysis.pdf (45 chunks)

User: What were the key findings in Q4?
BACR: According to the Q4 Analysis (Doc 1), the key findings were...

Sources:
• Q4_Analysis.pdf

Multi-Session Workflow:

User: /new-chat
User: /add project_spec.md
User: Explain the authentication flow
BACR: [Provides detailed explanation with citations]

User: /rename-chat Auth Documentation
User: /export-chat
BACR: ✔︎ Exported to ~/.bacr/exports/Auth_Documentation_2026-03-07.txt

Search History:

User: /find API endpoints
BACR: [Opens search interface with 12 matches across 3 conversations]
05

API Reference

Authentication

BACR uses Google OAuth 2.0 for user authentication and server-based API key management.

RAG System

The RAG (Retrieval-Augmented Generation) system combines vector search, keyword search, and reranking.

Security

Data Storage:

  • Refresh tokens: Windows Registry (encrypted)
  • Conversations: Local SQLite (user-specific)
  • Documents: Local FAISS indexes (user-specific)
  • Preferences: Windows Registry (encrypted)

Data Transmission:

  • All API calls use HTTPS
  • Google OAuth uses PKCE flow
  • JWT tokens expire after 24 hours
  • Refresh tokens expire after 30 days

Privacy:

  • User data isolated by hash
  • No document content sent to server
  • Only embeddings stored locally
  • Token usage logged for billing only

Best Practices:

  • Logout when done to clear API keys
  • Don't share refresh tokens
  • Use ZDR mode for sensitive data
  • Regularly export important conversations
06

Additional Resources

Support

Version: 1.0.0
Last Updated: March 7, 2026 Documentation: https://bacr.app/documentation

Maintained with care by The BACR Team