A modern, feature-rich AI chat application built with Python and Reflex that provides seamless access to cutting-edge AI models through OpenRouter.
- OpenRouter Integration: Access to hundreds of premium AI models through a unified API
- Multi-modal Support: Chat with text, images (PNG, JPEG), and PDF documents
- Real-time Streaming: Token-by-token response streaming for immediate feedback
- Smart Search: Integrated web search with automatic citation extraction using Perplexity models
- File Upload: Drag & drop interface with cloud storage (Cloudflare R2)
- Persistent Conversations: Full chat history with PostgreSQL storage
- Theme Support: Light and dark mode interface
- Responsive Design: Optimized for desktop and mobile devices
- User Authentication: Secure login with Clerk integration
- Cloud File Storage: Efficient file handling with Cloudflare R2 integration
- Streaming Responses: Real-time AI responses with live UI updates
- Citation Support: Automatic source extraction from search-enabled models
- Python 3.8 or higher
- PostgreSQL database (Neon recommended)
- Cloudflare R2 account (for file uploads)
-
Clone the repository
git clone git@github.com:bm611/ark.git cd ark -
Create and activate virtual environment
# Create virtual environment python -m venv venv # Activate virtual environment # On macOS/Linux: source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Environment Configuration Create a
.envfile with the following variables:# Required API Keys OPENROUTER_API_KEY=your_openrouter_api_key CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key # Database NEON_DB_URL=your_postgresql_connection_string # File Storage (Cloudflare R2) R2_ACCESS_KEY_ID=your_r2_access_key R2_SECRET_ACCESS_KEY=your_r2_secret_key R2_BUCKET_NAME=your_r2_bucket_name R2_ENDPOINT_URL=https://your_account_id.r2.cloudflarestorage.com # Optional UMAMI_WEBSITE_ID=your_analytics_id
-
Database Setup
python ark/database/schema.py
-
Run the application
reflex run
- Visit https://openrouter.ai
- Sign up for an account
- Navigate to API Keys section
- Generate a new API key
- Add to your
.envfile asOPENROUTER_API_KEY
- Visit https://clerk.com
- Create a new application
- Copy the publishable and secret keys
- Add to your
.envfile
- Sign up for Cloudflare account
- Create an R2 bucket
- Generate API tokens with R2 permissions
- Add credentials to your
.envfile
- Launch the application with
reflex run - Sign in or create an account through Clerk
- Start typing your message in the chat input
- Upload images or PDFs using the paperclip icon
- Press Enter or click Send to get a response
- Chat Models: Defaults to Gemini 2.5 Flash
- Search Models: Perplexity Sonar Pro for web search with citations
- All models accessible through OpenRouter's unified API
- Images: Visual analysis and description (PNG, JPEG)
- PDFs: Document processing and content analysis
- Cloud Storage: Files stored securely in Cloudflare R2
- Smart Processing: Optimized handling for different AI providers
- Click the "Search" button to enable web search mode
- Automatic citation extraction from search results
- Sources displayed as expandable sections
- Powered by Perplexity's search models
- Frontend: Reflex-based reactive UI with real-time updates
- Backend: Python with async message processing
- Database: PostgreSQL with Neon hosting for chat persistence
- Storage: Cloudflare R2 for scalable file storage
- Authentication: Clerk for secure user management
- Unified Interface: Single provider (OpenRouter) for all AI models
- Streaming Support: Real-time token-by-token responses
- Model Flexibility: Easy switching between different AI models
- Citation Handling: Automatic source extraction for search models
ark/
βββ ark/ # Main application code
β βββ components/ # Reusable UI components
β β βββ chat/ # Chat-specific components
β β βββ common/ # Shared UI elements
β βββ pages/ # Application pages
β βββ providers/ # AI provider integrations
β βββ services/ # External service integrations
β βββ database/ # Database schema and utilities
β βββ handlers/ # Message processing logic
β βββ state.py # Application state management
βββ assets/ # Static assets
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (create this)
βββ README.md # Documentation
- users: User account information
- chats: Chat session metadata
- messages: Individual chat messages
- files: File metadata and references
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests to ensure functionality
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the documentation above
- Ensure all API keys are properly configured
- Verify database connection
- Check Cloudflare R2 configuration for file upload issues