Skip to content

oneWritesCode/Godgpt-2

Repository files navigation

🧠 GodGPT - God of All GPTs

A powerful, feature-rich chat application providing seamless access to 18+ Large Language Models through a single, elegant interface.

image

image

image

image

cursorful-video-1750502865778.online-video-cutter.com.mp4

image

image

image

image

image

πŸš€ Project Overview

GodGPT is a modern, production-ready chat application that unifies access to the world's most powerful AI models. Built with cutting-edge web technologies and designed for both developers and end-users, it offers a comprehensive solution for AI-powered conversations with advanced features like real-time sync, offline capabilities, and intelligent model fallbacks.

✨ What Makes GodGPT Special

  • 18+ AI Models: Access to the latest models from OpenAI, Anthropic, Google, Meta, DeepSeek, and more
  • Multi MOdels Response Proccessing Queue: Queue-based multi-model responses, so you don’t have to go full psycho opening the same prompt in 5 tabs
  • Pre Prompt Generation: Pre-prompt generator to fix your shitty prompts, make them actually usable
  • Smart Fallback System: Automatic fallback to OpenRouter when user API keys aren't available
  • Real-time Multi-tab Sync: Conversations sync instantly across all browser tabs
  • BYOK: Bring Your Own Keys Support
  • Production Ready: Built with enterprise-grade architecture and security

🎯 Core Features

πŸ€– Multi-LLM Support

  • 8 Free Models: Including DeepSeek R1, Gemini 2.5 Flash, GPT-4o Mini, Claude 3.5 Haiku
  • 5 Premium Text Models: GPT-4.1, Claude Sonnet 4, Gemini 2.5 Pro, and more
  • 3 Image Models: DALL-E 3/2, Stable Diffusion 3.5
  • 2 Vision Models: GPT-4o, GPT-4V for image analysis
  • Smart Model Selection: Detailed model capability icons

πŸ” Authentication & Security

  • Better Auth Integration: Modern, secure authentication system
  • Multiple Providers: Google OAuth, GitHub OAuth
  • Session Management: Secure session handling with automatic expiration
  • API Key Management: Secure storage of user API keys with encryption

πŸ’Ύ Data Management

  • Dual Storage System: PostgreSQL for server data, Dexie.js for offline capabilities
  • Real-time Synchronization: Instant sync across devices and browser tabs
  • Persistent Chat History: Never lose your conversations
  • Usage Tracking: Monitor API usage and rate limits

🎨 Modern UI/UX

  • Responsive Design: Perfect experience on desktop, tablet, and mobile
  • Dark/Light Themes: System preference detection with manual override

πŸš€ Advanced Features

  • Streaming Responses: Real-time message streaming with typing indicators
  • Multi-tab Sync: Continue conversations seamlessly across browser tabs
  • Error Recovery: Automatic retry logic with graceful error handling
  • Syntax Highlighting: Beautiful code rendering with copy functionality

πŸ› οΈ Tech Stack

Core Framework

  • Next.js - React framework with App Router
  • TypeScript - Type-safe development

Database & Storage

  • Prisma - Next-generation ORM
  • PostgreSQL - Robust relational database (Neon)
  • Dexie.js - Client-side IndexedDB wrapper for offline support

Authentication & Security

  • Better Auth - Modern authentication solution
  • bcryptjs - Password hashing
  • OAuth Providers - Google, GitHub integration

AI & APIs

  • AI SDK 4.3.16 - Vercel's AI SDK for streaming
  • OpenRouter Provider - Access to multiple LLM providers
  • Google AI SDK - Direct Google Gemini integration
  • OpenAI SDK - Direct OpenAI API integration

UI & Styling

  • Tailwind CSS 4.1.8 - Utility-first CSS framework
  • Radix UI - Unstyled, accessible components
  • Lucide React - Beautiful icon library
  • Next Themes - Theme switching capabilities

State Management & Utils

  • Zustand 5.0.5 - Lightweight state management
  • React Hook Form - Performant form handling
  • Zod 3.25.56 - Schema validation
  • Lodash 4.17.21 - Utility library

πŸ—οΈ Architecture

Smart Model Fallback System

// Example: Premium models automatically fallback to OpenRouter
'GPT-4.1': {
  modelId: 'gpt-4.1',
  provider: 'openai',
  fallbackProvider: 'openrouter',
  fallbackModelId: 'openai/gpt-4.1',
}

Real-time Multi-tab Synchronization

  • Broadcast Channel API for cross-tab communication
  • Optimistic Updates for instant UI feedback
  • Conflict Resolution for simultaneous edits
  • Streaming State Sync across all active sessions

Offline-First Data Layer

  • Dexie.js for client-side persistence
  • Background Sync when connection restored
  • Conflict Resolution between local and server state
  • Optimistic UI Updates for responsive experience

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ or Bun (recommended)
  • PostgreSQL Database (or Neon for cloud)
  • Git for version control

Installation

  1. Clone the repository
git clone https://github.com/yourusername/godgpt.git
cd godgpt
  1. Install dependencies
# Using bun (recommended)
bun install

# Or using npm
npm install
  1. Configure your environment
# Database
DATABASE_URL="your-postgresql-connection-string"

# Better Auth
BETTER_AUTH_SECRET="your-secret-key-32-chars-minimum"
BETTER_AUTH_URL="http://localhost:3000"

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

# OpenRouter (required for free models)
OPENROUTER_API_KEY="sk-or-v1-your-api-key-here"

# Image Generation (optional)
IMAGEROUTER_API_KEY="your-imagerouter-key"
CLOUDINARY_CLOUD_NAME="your-cloudinary-name"
CLOUDINARY_API_KEY="your-cloudinary-key"
CLOUDINARY_API_SECRET="your-cloudinary-secret"
  1. Set up the database
npm run db:push
  1. Start the development server
npm run dev
  1. Open your browser Navigate to http://localhost:3000

πŸ”§ Environment Setup

Required Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string βœ…
BETTER_AUTH_SECRET Secret for authentication βœ…
BETTER_AUTH_URL Application URL βœ…
OPENROUTER_API_KEY OpenRouter API key for free models βœ…

Optional Environment Variables

Variable Description Required
GOOGLE_CLIENT_ID Google OAuth client ID ❌
GOOGLE_CLIENT_SECRET Google OAuth client secret ❌
GITHUB_CLIENT_ID GitHub OAuth client ID ❌
GITHUB_CLIENT_SECRET GitHub OAuth client secret ❌
IMAGEROUTER_API_KEY Image generation API key ❌
CLOUDINARY_* Cloudinary configuration ❌

Getting API Keys

  1. OpenRouter: Sign up at openrouter.ai - Required for free models
  2. Google OAuth: Create project at Google Cloud Console
  3. GitHub OAuth: Create app at GitHub Developer Settings
  4. Neon PostgreSQL: Create database at neon.tech

πŸ“± Usage

Starting Your First Chat

  1. Sign up with email, Google, or GitHub
  2. Select a model from the dropdown (18+ options available)
  3. Start chatting - responses stream in real-time
  4. Upload images for vision-capable models

Advanced Features

  • Can Select Multiple Models too (optional)
  • Multi-tab Sync: Open multiple tabs - conversations sync instantly
  • Offline Mode: Continue chatting even without internet
  • Model Switching: Change models mid-conversation
  • Chat History: Access all previous conversations
  • Code Highlighting: Beautiful syntax highlighting for code blocks

Model Categories

πŸ†“ Free Models (No API key required)

  • DeepSeek R1 0528 - Latest reasoning model
  • Gemini 2.5 Flash - Fast Google model with vision
  • GPT-4o Mini - OpenAI's efficient model with vision
  • Claude 3.5 Haiku - Anthropic's fast model
  • Meta-Llama 3.3 70B - Meta's open source model

πŸ’Ž Premium Models (User API key recommended)

  • Claude Sonnet 4 - Anthropic's latest flagship
  • GPT-4.1 - OpenAI's advanced model
  • Gemini 2.5 Pro - Google's most capable model
  • GPT-4o - OpenAI's multimodal model
  • GPT-4V - Enhanced vision capabilities

🎨 Image Generation

  • DALL-E 3 - OpenAI's latest image generator
  • DALL-E 2 - Reliable image generation
  • Stable Diffusion 3.5 - Open source image generation

πŸ—οΈ Project Structure

godgpt/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ chat/         # Chat completion endpoint
β”‚   β”‚   β”œβ”€β”€ image/        # Image generation endpoint
β”‚   β”‚   └── upload/       # File upload endpoint
β”‚   β”œβ”€β”€ globals.css       # Global styles
β”‚   └── layout.tsx        # Root layout
β”œβ”€β”€ frontend/              # Client-side code
β”‚   β”œβ”€β”€ components/       # React components
β”‚   β”‚   β”œβ”€β”€ ui/          # Reusable UI components
β”‚   β”‚   └── userdashboard/ # User dashboard components
β”‚   β”œβ”€β”€ dexie/           # Offline database layer
β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”œβ”€β”€ routes/          # Route components
β”‚   └── stores/          # Zustand state stores
β”œβ”€β”€ lib/                  # Shared utilities
β”œβ”€β”€ prisma/              # Database schema and migrations
└── public/              # Static assets

πŸš€ Deployment

Vercel (Recommended)

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

Cloudflare Workers (Edge)

bun run build
wrangler deploy

Docker

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

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“ˆ Future Implementation

  • Voice Chat - Speech-to-text and text-to-speech
  • Branch Chat - supports branching of chats
  • File Analysis - PDF, CSV, and document processing
  • Plugin System - Extensible plugin architecture
  • Team Workspaces - Collaborative chat environments like share chat
  • Advanced Analytics - Usage statistics and insights
  • Mobile Apps - Native iOS and Android applications

πŸ”’ Security

  • End-to-end Encryption for API keys
  • Rate Limiting to prevent abuse
  • Input Sanitization for XSS protection
  • CSRF Protection with secure tokens
  • Secure Headers with Next.js security headers

πŸ“ License

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

πŸ™ Acknowledgments

  • Next.js Team for the incredible framework
  • Vercel for the AI SDK and deployment platform
  • Better Auth for modern authentication
  • OpenRouter for unified LLM access
  • Neon for serverless PostgreSQL
  • Open Source Community for all the amazing tools

Built with ❀️ by Neeraj (me) and Deepak (https://github.com/oneWritesCode)

"We want to make our app as its name"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •