Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

inja-online/chat.inja.online

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chat.inja.online πŸ€–

A modern AI chat application built with Next.js, featuring multiple authentication methods and support for 6+ AI providers. Users can either sign in with OAuth (GitHub/Google) or bring their own API keys from their preferred AI provider.

✨ Features

πŸ”‘ Dual Authentication System

  • OAuth Authentication: Quick sign-in with GitHub or Google
  • Bring Your Own API Key (BYOK): Use your own API keys from any supported provider
  • Secure Storage: API keys encrypted with AES-256-GCM encryption

πŸ€– AI Provider Support

  • OpenAI - GPT-3.5, GPT-4, and more
  • Anthropic - Claude 3 models
  • Google AI - Gemini Pro and variants
  • Mistral AI - Mistral models
  • Cohere - Command models
  • OpenRouter - Access to 200+ models from multiple providers

πŸ’¬ Chat Features

  • Real-time streaming responses
  • Multiple conversations with persistent history
  • Modern UI with dark/light theme support
  • Responsive design for desktop and mobile
  • Smart chat titles auto-generated from conversations

πŸ› οΈ Technical Stack

  • Framework: Next.js 15 with App Router
  • AI SDK: Vercel AI SDK for streaming responses
  • Authentication: NextAuth.js v4
  • Database: Drizzle ORM with SQLite (local) / Cloudflare D1 (production)
  • UI: Tailwind CSS + shadcn/ui components
  • Deployment: Cloudflare Pages compatible

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ or Bun
  • At least one AI provider API key (optional for OAuth users)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/chat.inja.online.git
    cd chat.inja.online
  2. Install dependencies

    bun install
  3. Set up environment variables

    cp env.example .env.local
  4. Configure environment (see Environment Configuration below)

  5. Set up the database

    # Generate database schema
    bun run db:generate
    
    # Apply migrations to local SQLite database
    bun run db:migrate:local
  6. Start the development server

    bun run dev
  7. Open your browser Navigate to http://localhost:3000

βš™οΈ Environment Configuration

🏠 Local Development (.env.local)

Create a .env.local file with the following configuration:

# Application URL
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Node Environment
NODE_ENV="development"

# Database (Local SQLite - automatically created)
DATABASE_URL="file:./local.db"

# NextAuth Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-development-secret-key-min-32-chars"

# OAuth Providers (Required for OAuth login)
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# Cloudflare D1 (Not used in development, but required by env validation)
CLOUDFLARE_DATABASE_ID="placeholder-for-dev"
CLOUDFLARE_ACCOUNT_ID="placeholder-for-dev"
CLOUDFLARE_API_TOKEN="placeholder-for-dev"

πŸš€ Production Deployment

Cloudflare Pages Environment Variables

Set these in your Cloudflare Pages dashboard:

# Application URL
NEXT_PUBLIC_APP_URL="https://your-domain.pages.dev"

# Node Environment
NODE_ENV="production"

# Database URL (same as Cloudflare D1 connection)
DATABASE_URL="https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/d1/database/DATABASE_ID"

# NextAuth Configuration
NEXTAUTH_URL="https://your-domain.pages.dev"
NEXTAUTH_SECRET="your-production-secret-key-min-32-chars"

# OAuth Providers
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# Cloudflare D1 Database
CLOUDFLARE_DATABASE_ID="your-d1-database-id"
CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
CLOUDFLARE_API_TOKEN="your-cloudflare-api-token"

Vercel Environment Variables

If deploying to Vercel, use these environment variables:

# Application URL
NEXT_PUBLIC_APP_URL="https://your-app.vercel.app"

# Node Environment
NODE_ENV="production"

# Database (Use your preferred database)
DATABASE_URL="your-production-database-url"

# NextAuth Configuration
NEXTAUTH_URL="https://your-app.vercel.app"
NEXTAUTH_SECRET="your-production-secret-key-min-32-chars"

# OAuth Providers
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# For Vercel, you might not need Cloudflare D1 variables
CLOUDFLARE_DATABASE_ID="not-used"
CLOUDFLARE_ACCOUNT_ID="not-used"
CLOUDFLARE_API_TOKEN="not-used"

πŸ”§ Database Setup

Local Development

The app uses a simple SQLite database (local.db) for local development:

# Generate migrations from schema
bun run db:generate

# Apply migrations to local database
bun run db:migrate:local

# Open database studio for local development
bun run db:studio:local

Production (Cloudflare D1)

For production deployment on Cloudflare Pages:

  1. Create a D1 database

    wrangler d1 create chat-inja-db
  2. Update wrangler.toml with your database ID

  3. Apply migrations to production

    bun run db:migrate
  4. Open production database studio

    bun run db:studio

πŸ”‘ OAuth Setup

GitHub OAuth

  1. Go to GitHub Settings β†’ Developer settings β†’ OAuth Apps
  2. Create a new OAuth App with:
    • Homepage URL: http://localhost:3000 (dev) or your production URL
    • Authorization callback URL: http://localhost:3000/api/auth/callback/github (dev) or https://your-domain.com/api/auth/callback/github (prod)
  3. Copy Client ID and Client Secret to your environment variables

Google OAuth

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable Google+ API
  4. Create OAuth 2.0 credentials with:
    • Authorized redirect URIs:
      • http://localhost:3000/api/auth/callback/google (development)
      • https://your-domain.com/api/auth/callback/google (production)
  5. Copy Client ID and Client Secret to your environment variables

🎯 Available Scripts

Development

bun run dev              # Start Next.js development server
bun run dev:wrangler     # Start with Wrangler for Cloudflare compatibility

Database Management

bun run db:generate      # Generate migrations from schema
bun run db:migrate:local # Apply migrations to local SQLite
bun run db:migrate       # Apply migrations to production D1
bun run db:studio:local  # Open local database studio
bun run db:studio        # Open production database studio

Build & Deploy

bun run build           # Build for production
bun run start           # Start production server
bun run deploy          # Deploy to Cloudflare Pages

Code Quality

bun run lint            # Check code with Biome
bun run lint:fix        # Fix code issues with Biome
bun run format          # Format code with Biome

πŸ’‘ AI Provider API Keys

Users can get API keys from:

πŸ“ Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication endpoints
β”‚   β”‚   └── chat/           # Chat API with AI providers
β”‚   β”œβ”€β”€ auth/signin/        # Sign-in page
β”‚   └── page.tsx           # Main chat interface
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/                # shadcn/ui components
β”‚   └── chat-app.tsx       # Main chat component
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ auth.ts            # NextAuth configuration
β”‚   └── api-auth.ts        # API key authentication utilities
β”œβ”€β”€ db/
β”‚   └── drizzle/           # Database schema and utilities
└── providers/             # React context providers

πŸ›‘οΈ Security

  • API Key Encryption: All API keys are encrypted using AES-256-GCM before storage
  • HTTP-Only Cookies: Session data stored in secure, HTTP-only cookies
  • CSRF Protection: NextAuth.js provides built-in CSRF protection
  • API Key Validation: Real-time validation against provider APIs
  • Secure Defaults: Production-ready security settings

πŸš€ Deployment Options

Cloudflare Pages (Recommended)

  1. Build the application

    bun run build
  2. Deploy to Cloudflare Pages

    bun run deploy
  3. Configure environment variables in Cloudflare Pages dashboard

Vercel

  1. Connect your repository to Vercel
  2. Configure environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Docker

FROM node:18-alpine
WORKDIR /app
COPY package.json bun.lock ./
RUN npm install -g bun && bun install
COPY . .
RUN bun run build
EXPOSE 3000
CMD ["bun", "start"]

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Add feature'
  4. Push to the branch: git push origin feature-name
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


Made with ❀️ using Next.js and the Vercel AI SDK

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors