Skip to content

RobGilto/elixir_bear

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ElixirBear 🐻✨

A production-ready AI chat platform built with Phoenix LiveView, featuring intelligent solution management, multi-modal conversations, and real-time streaming.

Elixir Phoenix LiveView License

ElixirBear is a sophisticated AI chat application that goes beyond simple conversations. It intelligently extracts, organizes, and retrieves code solutions from your chat history, making it a powerful tool for developers who want to build a personal knowledge base while interacting with AI models.


Main Chat Interface

✨ Key Features

πŸ’¬ Intelligent Chat Interface

Transform your AI conversations into a powerful development tool:

  • πŸ€– Dual AI Provider Support: Seamlessly switch between OpenAI's GPT models and local Ollama models
  • πŸ–ΌοΈ Multi-Modal Conversations: Attach images, audio files, and code files directly to your messages
  • ⚑ Real-Time Streaming: Experience instant, token-by-token response streaming powered by Phoenix LiveView
  • πŸ“ Smart Conversation Management: Organize multiple conversation threads with easy navigation and search
  • 🎨 Customizable Interface: Personalize your workspace with custom background images and themes
  • πŸŽ“ Learning Mode: Built-in copy blocker that prevents copying conversation text to encourage active learning
  • 🧠 Prompt Orchestrator: Automatically selects specialized system prompts based on conversation context

Multi-modal Chat

🧠 AI-Powered Solution Management

The standout feature that sets ElixirBear apart:

  • πŸ” Automatic Solution Extraction: Let AI identify and extract valuable code solutions from your conversations automatically
  • 🏷️ Smart Tagging System: Organize solutions with custom tags for lightning-fast retrieval
  • 🎯 Intelligent Solution Router: AI-powered matching system that suggests relevant solutions as you chat
  • πŸ“š Code Block Support: Store multiple code blocks per solution with full syntax highlighting
  • πŸ”„ Reusability at Scale: Build your personal library of battle-tested solutions

Solutions Library

πŸŽ“ Enhanced Learning Features

Powerful tools designed to improve your learning experience:

  • πŸ“ Copy Blocker (Learning Mode): Force active learning by preventing text copying

    • Hides all copy buttons from code blocks
    • Blocks text selection across conversation messages
    • Encourages manual typing for better retention
    • Toggleable on/off in Settings (enabled by default)
  • 🎯 Prompt Orchestrator: Context-aware system prompt selection

    • Automatically analyzes your questions to detect programming languages and frameworks
    • Selects specialized system prompts based on detected context
    • Supports hierarchical categories (e.g., python/django β†’ python β†’ default)
    • Define custom prompts using simple JSON configuration
    • Uses local or cloud LLM for intelligent routing

    Example orchestrator configuration:

    {
      "python": "You are a Python expert...",
      "python/django": "You are a Django framework specialist...",
      "elixir": "You are an Elixir expert...",
      "elixir/phoenix": "You are a Phoenix framework expert...",
      "default": "You are a helpful programming assistant..."
    }

πŸ“Ž Comprehensive File Support

Work with virtually any file type in your conversations:

Category Supported Formats
Images .jpg, .jpeg, .png, .gif, .webp
Audio .mp3, .mpga, .m4a, .wav
Elixir .ex, .exs, .heex, .eex, .leex
Web .js, .jsx, .ts, .tsx, .css, .scss, .html
Config .json, .xml, .yaml, .yml, .toml
Languages .py, .rb, .java, .go, .rs, .c, .cpp, .sh and more
Documentation .txt, .md

🎯 Technical Highlights

Real-time Architecture

  • Built on Phoenix PubSub for instant message delivery
  • LiveView integration eliminates the need for separate frontend framework
  • WebSocket-based streaming for token-by-token AI responses

Smart Background Processing

  • Asynchronous conversation processing with dedicated workers
  • Non-blocking solution extraction and routing
  • Efficient handling of file uploads and processing

Developer-Friendly Design

  • Clean separation of concerns with domain-driven design
  • Comprehensive test coverage
  • Pre-commit hooks for code quality
  • SQLite for simple deployment and portability

Technology Stack

  • Backend: Elixir 1.15+ with Phoenix Framework 1.8
  • Frontend: Phoenix LiveView 1.1 with TailwindCSS
  • Database: SQLite (via Ecto SQLite3)
  • AI Integration: OpenAI API & Ollama support
  • Real-time: Phoenix PubSub for live updates
  • Assets: esbuild & Tailwind CSS

Prerequisites

  • Elixir 1.15 or later
  • Erlang/OTP 24 or later
  • Node.js (for asset compilation)
  • SQLite3

Installation

  1. Clone the repository:
git clone https://github.com/RobGilto/elixir_bear.git
cd elixir_bear
  1. Install dependencies and set up the database:
mix setup

This will:

  • Install Elixir dependencies
  • Create and migrate the database
  • Install and build assets
  1. Configure your AI provider settings:
    • For OpenAI: Set your API key in the Settings page after starting the server
    • For Ollama: Ensure Ollama is running locally and configure the endpoint in Settings

πŸš€ Quick Start

Start the Phoenix server:

mix phx.server

Or start it inside IEx for interactive debugging:

iex -S mix phx.server

Visit localhost:4000 in your browser.

βš™οΈ First-time Setup

  1. Configure AI Provider - Navigate to Settings (/settings):

    • Add your OpenAI API key for GPT models, or
    • Configure Ollama endpoint for local models (e.g., http://localhost:11434)
  2. Configure Learning Features (Optional):

    • Copy Blocker: Enabled by default. Toggle off if you prefer to copy code freely
    • Prompt Orchestrator: Define specialized system prompts for different programming contexts
  3. Enable Smart Features (Optional):

    • Enable automatic solution extraction
    • Configure the solution router for AI-powered suggestions
    • Set solution router threshold for match confidence
  4. Start Chatting - Create a new conversation and start building your knowledge base!

🎬 Demo

  1. Starting a new conversation
  2. Asking a coding question
  3. Getting a solution with code blocks
  4. Solution being automatically extracted and tagged
  5. Later query showing the solution being suggested by the router

Development

Running Tests

mix test

Code Formatting

mix format

Pre-commit Checks

Before committing your changes, run:

mix precommit

This will:

  • Compile with warnings as errors
  • Remove unused dependencies
  • Format code
  • Run the test suite

Database Operations

Reset the database:

mix ecto.reset

Run migrations:

mix ecto.migrate

πŸ“ Project Structure

The codebase follows Phoenix conventions with domain-driven design:

lib/
β”œβ”€β”€ elixir_bear/               # 🧠 Core business logic
β”‚   β”œβ”€β”€ chat/                  # πŸ’¬ Chat domain
β”‚   β”‚   β”œβ”€β”€ conversation.ex   # Conversation schema and queries
β”‚   β”‚   β”œβ”€β”€ message.ex        # Message schema
β”‚   β”‚   └── settings.ex       # Application settings
β”‚   β”œβ”€β”€ solutions/             # πŸ” Solutions domain
β”‚   β”‚   β”œβ”€β”€ solution.ex       # Solution schema and queries
β”‚   β”‚   β”œβ”€β”€ tag.ex            # Tag system
β”‚   β”‚   β”œβ”€β”€ extractor.ex      # AI-powered solution extraction
β”‚   β”‚   └── router.ex         # Smart solution matching
β”‚   β”œβ”€β”€ ollama.ex             # πŸ¦™ Ollama API client
β”‚   β”œβ”€β”€ openai.ex             # πŸ€– OpenAI API client
β”‚   └── conversation_worker.ex # βš™οΈ Background processing
β”‚
β”œβ”€β”€ elixir_bear_web/          # 🌐 Web interface
β”‚   β”œβ”€β”€ live/                 # ⚑ LiveView modules
β”‚   β”‚   β”œβ”€β”€ chat_live.ex     # Main chat interface
β”‚   β”‚   β”œβ”€β”€ solutions_live.ex # Solutions library
β”‚   β”‚   └── settings_live.ex  # Settings management
β”‚   β”œβ”€β”€ components/           # 🧩 Reusable UI components
β”‚   └── router.ex            # πŸ›£οΈ Application routes
β”‚
β”œβ”€β”€ test/                     # πŸ§ͺ Comprehensive test suite
└── priv/                     # πŸ“¦ Static assets & migrations

πŸ—οΈ Architecture Decisions

Why Phoenix LiveView?

  • Real-time updates without complex JavaScript frameworks
  • Server-side rendering with minimal client-side code
  • Built-in WebSocket handling and connection management
  • Simplified state management

Why SQLite?

  • Zero-configuration database setup
  • Perfect for single-user or small-team deployments
  • Easy backup and portability
  • Excellent performance for this use case

Why Background Workers?

  • Non-blocking AI API calls
  • Smooth user experience during solution extraction
  • Scalable processing for multiple concurrent conversations

Configuration

Key configuration files:

  • config/config.exs - Application configuration
  • config/dev.exs - Development environment settings
  • config/prod.exs - Production environment settings
  • AGENTS.md - Development guidelines and coding standards

🎯 Use Cases

For Developers

  • Build a personal library of coding solutions and patterns
  • Quickly reference solutions from past AI conversations
  • Get context-aware responses with the Prompt Orchestrator
  • Learn by reviewing and organizing code snippets

For Teams

  • Share and reuse common solutions across projects
  • Document tribal knowledge in an accessible format
  • Onboard new team members with curated solutions
  • Configure team-wide system prompts for consistent AI responses

For Learners

  • Study AI-generated solutions with syntax highlighting
  • Use Learning Mode (copy blocker) to reinforce learning through manual typing
  • Organize learning materials by topic using tags
  • Track your coding journey through conversation history
  • Benefit from specialized AI tutoring via the Prompt Orchestrator

🀝 Contributing

Contributions are welcome! Please follow the guidelines in AGENTS.md for:

  • Phoenix LiveView best practices
  • Elixir coding standards
  • UI/UX design principles
  • Testing strategies

πŸ“„ License

This project is available for personal and educational use.

πŸ™ Acknowledgments

Built with these amazing technologies:


Built using Elixir and Phoenix LiveView

Resources

About

my coding chatbot bear

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors