Skip to content

A simple web application that allows you to edit the chat history while talking to ChatGPT. This often yields fascinating and sometimes amusing results.

License

Notifications You must be signed in to change notification settings

Hanker5/GaslightGPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GaslightGPT

A modern, type-safe AI chat web client powered by Groq with advanced message editing and chat history management. Built with React 18, TypeScript, Vite, Tailwind CSS, and Shadcn/ui components for a premium user experience.

✨ Features

  • βš›οΈ Built with React 18 + TypeScript for type safety and reliability
  • 🎨 Tailwind CSS + Shadcn/ui + Radix UI for a polished, accessible UI
  • πŸŒ™ Beautiful light/dark theme toggle with clean, modern design
  • πŸ’¬ Real-time chat with smooth typing indicators
  • πŸ“š Chat history with localStorage persistence
  • πŸ”„ Multiple conversations with sidebar navigation
  • ✏️ Edit both user and assistant messages inline
  • πŸ”₯ "Gaslit!" badges on edited messages (toggle on/off)
  • πŸ“‹ One-click copy for any message
  • πŸ—‘οΈ Delete individual chats or clear all history
  • 🎯 Keyboard shortcuts (Cmd/Ctrl+K for new chat, Escape to close dialogs)
  • πŸ”” Toast notifications for user actions
  • ☁️ Vercel-ready serverless deployment
  • πŸ”’ Secure API key handling (server-side only)
  • πŸ“± Fully responsive design

πŸ—οΈ Tech Stack

  • Frontend: React 18, TypeScript, Vite
  • Styling: Tailwind CSS, Shadcn/ui components, Radix UI primitives
  • UI Components: Badge, Button, Card, Dialog, Input, Label, ScrollArea, Separator, Switch, Textarea
  • Notifications: Sonner (toast library)
  • Markdown: React Markdown with GitHub Flavored Markdown
  • Backend: Vercel Serverless Functions / Express (local dev)
  • AI: Groq API (Llama 3.3 70B by default)
  • Storage: localStorage for chat history and preferences

πŸ“ Project Structure

GaslightGPT/
β”œβ”€β”€ api/                          # Vercel serverless functions
β”‚   └── chat.js                   # Groq API endpoint (production)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/               # React components
β”‚   β”‚   β”œβ”€β”€ ui/                   # Shadcn/ui components
β”‚   β”‚   β”‚   β”œβ”€β”€ badge.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ dialog.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ input.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ label.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ scroll-area.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ separator.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ switch.tsx
β”‚   β”‚   β”‚   └── textarea.tsx
β”‚   β”‚   β”œβ”€β”€ Chat.tsx              # Main chat component
β”‚   β”‚   β”œβ”€β”€ ChatMessage.tsx       # Message display with copy/edit
β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx     # Error boundary wrapper
β”‚   β”‚   β”œβ”€β”€ Header.tsx            # Top navigation bar
β”‚   β”‚   β”œβ”€β”€ Logo.tsx              # Logo wrapper component
β”‚   β”‚   β”œβ”€β”€ LogoIcon.tsx          # SVG logo icon
β”‚   β”‚   β”œβ”€β”€ SettingsDialog.tsx    # Settings modal
β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx           # Chat history sidebar
β”‚   β”‚   └── TypingIndicator.tsx   # Loading animation
β”‚   β”œβ”€β”€ hooks/                    # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ index.ts
β”‚   β”‚   β”œβ”€β”€ useAutoResize.ts      # Textarea auto-resize
β”‚   β”‚   β”œβ”€β”€ useAutoScroll.ts      # Chat auto-scroll
β”‚   β”‚   └── useLocalStorage.ts    # Generic localStorage hook
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ chatStorage.ts        # Chat history management
β”‚   β”‚   └── utils.ts              # Utility functions (cn)
β”‚   β”œβ”€β”€ types/                    # TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ api.ts                # API request/response types
β”‚   β”‚   β”œβ”€β”€ chat.ts               # Chat and message types
β”‚   β”‚   └── index.ts              # Type exports
β”‚   β”œβ”€β”€ App.tsx                   # Root component with state
β”‚   β”œβ”€β”€ main.tsx                  # Entry point
β”‚   └── index.css                 # Global styles & Tailwind
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ favicon.ico               # Favicon (32x32)
β”‚   β”œβ”€β”€ favicon-16.png            # 16x16 favicon
β”‚   β”œβ”€β”€ favicon-32.png            # 32x32 favicon
β”‚   β”œβ”€β”€ favicon-48.png            # 48x48 favicon
β”‚   β”œβ”€β”€ favicon-192.png           # 192x192 PWA icon
β”‚   β”œβ”€β”€ favicon-512.png           # 512x512 PWA icon
β”‚   β”œβ”€β”€ apple-touch-icon.png      # iOS home screen icon (180x180)
β”‚   β”œβ”€β”€ logo.svg                  # Merged SVG logo
β”‚   └── manifest.json             # PWA manifest
β”œβ”€β”€ index.html                    # HTML entry point
β”œβ”€β”€ server-dev.js                 # Local development API server
β”œβ”€β”€ vite.config.js                # Vite configuration
β”œβ”€β”€ tsconfig.json                 # TypeScript configuration
β”œβ”€β”€ tailwind.config.js            # Tailwind configuration
β”œβ”€β”€ vercel.json                   # Vercel deployment config
└── package.json                  # Dependencies

Quick Start - Vercel Deployment (Recommended)

1. Deploy to Vercel

Deploy with Vercel

Or manually:

# Install Vercel CLI
npm install -g vercel

# Deploy
vercel

2. Configure Environment Variables

In your Vercel dashboard:

  1. Go to Settings β†’ Environment Variables
  2. Add these variables:
    • GROQ_API_KEY: Your Groq API key (get one here)
    • GROQ_MODEL: (optional) Model to use (default: llama-3.3-70b-versatile)

3. Redeploy

After adding environment variables, trigger a new deployment or use:

vercel --prod

πŸš€ Local Development

Prerequisites

  • Node.js (v18 or higher recommended)
  • npm or yarn
  • A Groq API key (get one here)

Quick Start

  1. Clone and install dependencies
git clone https://github.com/YOUR_USERNAME/GaslightGPT.git
cd GaslightGPT
npm install
  1. Set up environment variables
# Create .env file
cp .env.example .env

# Edit .env and add your GROQ_API_KEY
# GROQ_API_KEY=your_key_here
# GROQ_MODEL=llama-3.3-70b-versatile
  1. Start the development server
# Runs both the API server (port 3001) and Vite dev server (port 5173)
npm run dev

Open http://localhost:5173 in your browser.

Note: The npm run dev command uses concurrently to run both the Express API server and the Vite frontend dev server simultaneously. For production deployment, use Vercel's serverless functions instead (see deployment section above).

Alternative: Vercel Dev (Optional)

If you prefer to test with Vercel's serverless environment locally:

# Install Vercel CLI globally
npm install -g vercel

# Run with Vercel Dev
npm run vercel-dev

This will start at http://localhost:3000 but requires answering setup prompts on first run.

Environment Variables

Create a .env file based on .env.example:

# Groq Configuration
GROQ_API_KEY=your_api_key_here

# Optional: Model selection
GROQ_MODEL=llama-3.3-70b-versatile

Available models:

  • llama-3.3-70b-versatile (default, best quality and speed balance)
  • llama-3.1-8b-instant (fastest responses)
  • mixtral-8x7b-32768 (large context window)
  • gemma2-9b-it (Google's efficient model)

Full model list: https://console.groq.com/docs/models

🎯 Usage

Basic Chat

  1. Type your message in the input box
  2. Press Enter or click "Send"
  3. Watch the typing indicator as the AI responds

Advanced Features

  • Edit Messages: Click any message to edit it inline, then save
  • Copy Messages: Click the copy button (πŸ“‹) to copy message content
  • New Chat: Click the "+" button or press Cmd/Ctrl+K
  • Chat History: Click the hamburger menu to view past conversations
  • Delete Chats: Hover over a chat in the sidebar and click the trash icon
  • Settings: Click the gear icon to access theme toggle, clear chat options
  • Theme Toggle: Switch between light and dark mode in settings
  • Gaslit Labels: Toggle the "Gaslit!" badges on edited messages

Keyboard Shortcuts

  • Cmd/Ctrl + K: Start a new chat
  • Escape: Close settings dialog or sidebar (on mobile)

🎨 Design Philosophy

GaslightGPT follows a clean, modern design approach:

  • No AI slop: Removed excessive purple gradients, over-centered layouts, and stacked backdrop blurs
  • Varied spacing: Different border radii and padding for visual hierarchy
  • Subtle shadows: Single-layer shadows for depth without complexity
  • Theme-aware: Colors adapt to light/dark mode using CSS custom properties
  • Accessibility: Built on Radix UI primitives for keyboard navigation and screen readers

Security

  • Never commit your .env file to the repository
  • .env.example contains placeholder names only
  • For Vercel: Add secrets in the dashboard under Environment Variables
  • API keys are only used server-side, never exposed to the client
  • Chat history is stored locally in browser localStorage only

Troubleshooting

Vercel Deployment:

  • Make sure environment variables are set in Vercel dashboard
  • Check deployment logs in Vercel dashboard for errors
  • Verify your OpenAI API key is valid and has credits

Local Development:

  • Ensure all dependencies are installed (npm install)
  • Check that your .env file exists and contains valid values
  • Verify ports 3001 (API) and 5173 (frontend) are not in use
  • If you see "EADDRINUSE" errors, kill the process using the port
  • Check browser console for errors (F12 β†’ Console tab)

API Errors:

  • Verify your GROQ_API_KEY is correct and active
  • Check if you're hitting rate limits (Groq offers 1000 free requests)
  • Try a different model if one isn't working
  • Ensure the selected model is available on your Groq plan

TypeScript Errors:

  • Run npm run build to check for type errors
  • Ensure all .tsx files import types from @/types
  • Check that tsconfig.json is properly configured

Contributing

Contributions are welcome! Please:

  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

License

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

About

A simple web application that allows you to edit the chat history while talking to ChatGPT. This often yields fascinating and sometimes amusing results.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •