Skip to content

A modern, responsive AI chat assistant built with Next.js 15, TypeScript, AI-sdk, AI Elements and Google's Gemini AI. Features real-time streaming responses, beautiful syntax highlighting, and a polished dark/light theme.

Notifications You must be signed in to change notification settings

osamashehta/AI-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

πŸ€– AI Assistant

A modern, responsive AI chat assistant built with Next.js 15, TypeScript, AI-sdk, AI Elements and Google's Gemini AI. Features real-time streaming responses, beautiful syntax highlighting, and a polished dark/light theme.

✨ Features

  • πŸš€ Real-time Streaming: Watch AI responses appear character by character
  • πŸ’¬ Smart Conversations: Powered by Google's Gemini 2.0 Flash model
  • 🎨 Beautiful UI: Modern design with smooth animations and transitions
  • πŸŒ“ Dark/Light Mode: Seamless theme switching with system preference detection
  • πŸ“ Syntax Highlighting: Professional code block rendering with multiple language support
  • πŸ”„ Suggested Prompts: Quick-start conversation with predefined suggestions
  • πŸ“± Responsive Design: Works perfectly on desktop, tablet, and mobile
  • ⚑ Error Handling: Smart error messages with actionable guidance
  • 🎯 Rate Limit Display: User-friendly quota and rate limit notifications

πŸ› οΈ Tech Stack

  • Framework: Next.js 15 with App Router

  • Language: TypeScript

  • AI SDK: @ai-sdk/react for streaming responses

  • AI Elements: AI Elements AI Elements is a component library and custom registry built on top of shadcn/ui to help you build AI-native applications faster. It provides pre-built components like conversations, messages and more

  • AI Provider: Google Gemini 2.0 Flash model

  • Styling: Tailwind CSS v4 with custom components

  • Theme: next-themes for dark mode

  • Icons: Lucide React for beautiful icons

  • Code Highlighting: Custom syntax highlighting with professional themes

  • Font: Geist for optimal readability

πŸš€ Demo

Live Demo: https://ai-assistant-rho-rose.vercel.app/

Repository: https://github.com/osamashehta/AI-Assistant

πŸ“‹ Prerequisites

  • Node.js 18.17 or later
  • pnpm, npm, or yarn
  • Google AI API key (free tier available)

⚑ Quick Start

  1. Clone the repository

    git clone https://github.com/osamashehta/AI-Assistant.git
    cd AI-Assistant
  2. Install dependencies

    pnpm install
    # or
    npm install
    # or
    yarn install
  3. Set up environment variables

    cp .env.example .env.local

    Edit .env.local and add your Google AI API key:

    GOOGLE_GENERATIVE_AI_API_KEY=your_api_key_here
  4. Get your API key

    • Visit Google AI Studio
    • Create a new API key
    • Copy and paste it into your .env.local file
  5. Run the development server

    pnpm dev
    # or
    npm run dev
    # or
    yarn dev
  6. Open your browser Navigate to http://localhost:3000

🎯 Usage

Basic Chat

  • Type your message in the input field
  • Press Enter or click the Send button
  • Watch the AI response stream in real-time

Suggested Prompts

  • Use the suggestion chips for quick conversations
  • Topics include AI trends, programming, and technology

Theme Switching

  • Click the theme toggle in the top-left corner
  • Supports light, dark, and system preference modes

Code Discussions

  • Ask for code examples or explanations
  • Enjoy beautiful syntax highlighting with proper themes

πŸ”§ Configuration

Environment Variables

Variable Description Required Default
GOOGLE_GENERATIVE_AI_API_KEY Your Google AI API key Yes -

Customization

Modify suggestions: Edit the suggestions array in src/app/page.tsx:

const suggestions = [
  "What are the latest trends in AI?",
  "How does machine learning work?",
  // Add your custom suggestions here
];

Theme colors: Customize colors in src/app/globals.css:

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  /* Modify other color variables */
}

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/chat/route.ts      # AI chat API endpoint
β”‚   β”‚   β”œβ”€β”€ globals.css            # Global styles and themes
β”‚   β”‚   β”œβ”€β”€ layout.tsx             # Root layout with theme provider
β”‚   β”‚   └── page.tsx               # Main chat interface
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ai-elements/           # Chat UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ conversation.tsx   # Conversation container
β”‚   β”‚   β”‚   β”œβ”€β”€ message.tsx        # Message components
β”‚   β”‚   β”‚   └── suggestion.tsx     # Suggestion chips
β”‚   β”‚   β”œβ”€β”€ shared/               # Shared components
β”‚   β”‚   β”‚   β”œβ”€β”€ Container.tsx     # Layout container
β”‚   β”‚   β”‚   └── theme-toggle.tsx  # Theme switcher
β”‚   β”‚   └── ui/                   # Base UI components
β”‚   └── lib/
β”‚       └── utils.ts              # Utility functions
β”œβ”€β”€ public/                       # Static assets
β”œβ”€β”€ .env.example                  # Environment variables template
└── package.json                  # Dependencies and scripts

🎨 Features in Detail

AI Streaming

  • Real-time message streaming using Vercel AI SDK
  • Supports conversation history and context
  • Graceful error handling with retry mechanisms

Code Highlighting

  • Syntax highlighting for 50+ programming languages
  • Professional light and dark themes
  • Line highlighting and proper indentation
  • Copy-friendly code formatting

Responsive Design

  • Mobile-first responsive layout
  • Touch-friendly interactive elements
  • Optimized for all screen sizes
  • Smooth animations and transitions

Error Handling

  • Smart quota limit detection
  • User-friendly error messages
  • Actionable guidance and helpful links
  • Automatic retry suggestions with countdowns

πŸ”’ Rate Limits

The free tier of Google AI includes:

  • 50 requests per day for Gemini 2.0 Flash
  • Rate limiting applies automatically
  • Upgrade to paid tiers for higher limits

πŸš€ Deployment

Deploy on Vercel (Recommended)

  1. Push to GitHub

    git push origin main
  2. Deploy with Vercel

    • Visit vercel.com
    • Import your GitHub repository
    • Add environment variables in the Vercel dashboard
    • Deploy automatically
  3. Set Environment Variables

    • Go to your Vercel project settings
    • Add GOOGLE_GENERATIVE_AI_API_KEY with your API key
    • Redeploy if needed

Other Platforms

  • Netlify: Build command: pnpm build, Publish directory: out
  • Railway: Supports Next.js out of the box
  • Digital Ocean: Use App Platform with Node.js

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some 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.

πŸ™ Acknowledgments

πŸ“§ Contact


⭐ Don't forget to star this repository if you found it helpful!

About

A modern, responsive AI chat assistant built with Next.js 15, TypeScript, AI-sdk, AI Elements and Google's Gemini AI. Features real-time streaming responses, beautiful syntax highlighting, and a polished dark/light theme.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published