zola

repository·main·Indexed 23 days ago

https://github.com/ibelick/zola

An AI-powered application supporting multiple AI providers including OpenAI, Mistral, and local models via Ollama. It utilizes Supabase for backend services such as authentication and storage, and features Bring Your Own Key (BYOK) encryption for secure API key management.

Tokens
9.8K
Snippets
17
Records
67
Agent score
81%

What's inside zola

  1. Set up Google OAuth Authentication with Supabase

    main

    To enable Google login, follow these steps:

    1. Google Cloud Console:

      • Create a project and enable the Google+ API.
      • Create an OAuth Client ID (Web application type).
      • Add authorized redirect URIs:
        • https://[YOUR_PROJECT_REF].supabase.co/auth/v1/callback
        • http://localhost:3000/auth/callback (for local development)
      • Copy the Client ID and Client Secret.
    2. Supabase Dashboard:

      • Navigate to Authentication > Providers.
      • Enable Google.
      • Paste the Client ID and Client Secret from Google.
      • Save changes.
  2. Set up Supabase for Authentication and Storage

    main

    Zola requires Supabase for authentication and storage. To set it up:

    1. Create a project at Supabase.
    2. Apply the database schema using the provided SQL script.
    3. Create storage buckets for chat attachments.
    4. Configure authentication providers (e.g., Google OAuth).
    5. Add your API keys to .env.local.
  3. Install Zola Prerequisites

    main

    To run Zola, ensure your environment meets the following requirements:

    • Node.js: 18.x or later
    • Package Manager: npm or yarn
    • Version Control: Git
    • Backend/Auth: A Supabase account (for authentication and storage)
    • AI Models: API keys for supported providers (OpenAI, Mistral, etc.) or Ollama for running models locally.
  4. Install and Setup Ollama for Local AI

    main

    Ollama allows you to run AI models locally. Zola has built-in support for Ollama with automatic model detection, intelligent categorization, and smart tagging. No additional configuration is required for local installations.

    ### macOS and Linux
    
    ```bash
    curl -fsSL https://ollama.ai/install.sh | sh

    Windows

    Download and install from ollama.ai

    Docker

    docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
  5. Configure BYOK (Bring Your Own Key) Encryption

    main

    To enable the BYOK feature, Zola requires an ENCRYPTION_KEY to securely store user API keys in the database.

    Requirements:

    • The key must be exactly 32 bytes when base64 decoded.
    • Warning: Losing this key will make all existing user API keys unrecoverable. Use the same key across all deployment environments.

    Generation Methods:

    Node.js

    node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

    OpenSSL

    openssl rand -base64 32

    Python

    python -c "import base64, secrets; print(base64.b64encode(secrets.token_bytes(32)).decode())
    # Required for BYOK functionality
    ENCRYPTION_KEY=your_generated_base64_encryption_key
  6. Install Zola Locally

    main

    To run Zola in a local development environment on macOS, Linux, or Windows:

    1. Clone the repository.
    2. Install dependencies using npm install.
    3. Start the development server with npm run dev.

    The application will be available at http://localhost:3000.

    # Clone the repository
    git clone https://github.com/ibelick/zola.git
    cd zola
    
    # Install dependencies
    npm install
    
    # Run the development server
    npm run dev
  7. Generate a CSRF Secret

    main

    The CSRF_SECRET protects the application against Cross-Site Request Forgery. Generate a secure random string using one of the following methods and add it to your .env.local file:

    Node.js

    node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

    OpenSSL

    openssl rand -hex 32

    Python

    python -c "import secrets; print(secrets.token_hex(32))"
  8. Configure Zola Environment Variables

    main

    Create a .env.local file in the project root by copying .env.example. You must populate it with your specific credentials.

    Key variable groups include:

    • Supabase: NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, and SUPABASE_SERVICE_ROLE.
    • AI Providers: OPENAI_API_KEY, MISTRAL_API_KEY, OPENROUTER_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, ANTHROPIC_API_KEY, and XAI_API_KEY.
    • Local AI: OLLAMA_BASE_URL (defaults to http://localhost:11434).
    • Security: CSRF_SECRET and ENCRYPTION_KEY (required for BYOK).
    # Supabase
    NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
    SUPABASE_SERVICE_ROLE=your_supabase_service_role_key
    
    # OpenAI
    OPENAI_API_KEY=your_openai_api_key
    
    # Mistral
    MISTRAL_API_KEY=your_mistral_api_key
    
    # OpenRouter
    OPENROUTER_API_KEY=your_openrouter_api_key
    
    # CSRF Protection
    CSRF_SECRET=your_csrf_secret_key
    
    # Exa
    EXA_API_KEY=your_exa_api_key
    
    # Gemini
    GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key
    
    # Anthropic
    ANTHROPIC_API_KEY=your_anthropic_api_key
    
    # Xai
    XAI_API_KEY=your_xai_api_key
    
    # Ollama (for local AI models)
    OLLAMA_BASE_URL=http://localhost:11434
  9. Deploy Zola to Production

    main

    Vercel Deployment

    1. Push code to a Git repository.
    2. Import the project into Vercel.
    3. Configure environment variables.
    4. Deploy using the Vercel CLI.

    Self-Hosted Production

    Build the application and start the production server manually.

    # Deploy via Vercel CLI
    npm install -g vercel
    vercel
    
    # Self-hosted production build
    npm run build
    npm start
  10. Run Zola and Ollama via Docker Compose

    main

    For a complete local setup including both Zola and Ollama with GPU support, health checks, and automatic model pulling, use the provided docker-compose.ollama.yml file.

    To customize which models are pulled automatically, modify the OLLAMA_MODELS environment variable in the compose file.

    ```bash
    # Start both Zola and Ollama services
    docker-compose -f docker-compose.ollama.yml up -d
    
    # View logs
    docker-compose -f docker-compose.ollama.yml logs -f
    
    # Stop the services
    docker-compose -f docker-compose.ollama.yml down

    Example customization in docker-compose.ollama.yml

    environment:

    • OLLAMA_MODELS=llama3.2:3b,gemma2:2b,qwen2.5:3b
  11. Configure Supabase Storage Buckets

    main

    Zola requires two specific storage buckets in your Supabase dashboard for handling files:

    1. chat-attachments: For user-uploaded files in chats.
    2. avatars: For user profile images.

    Setup Steps:

    1. Go to Storage in your Supabase dashboard.
    2. Click New bucket and create chat-attachments.
    3. Click New bucket and create avatars.
    4. Configure public access permissions for both buckets so they can be accessed by the application.
  12. Enable Guest (Anonymous) Users in Supabase

    main

    To allow users to try Zola with limited access before creating an account:

    1. Go to your Supabase project dashboard.
    2. Navigate to Authentication > Providers.
    3. Toggle on Allow anonymous sign-ins.