Skip to content

AargonGPT – An AI-powered chatbot using OpenAI's GPT model for intelligent, human-like interactions. Built with Next.js, Vercel AI SDK, Tailwind CSS and PostgreSQL. πŸš€

aargon007/aargongpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AargonGPT

A modern, high-performance AI chat application built with Next.js 15, featuring real-time messaging, session storage optimization, and comprehensive performance optimizations.

πŸš€ Features

Core Functionality

  • Real-time AI Chat - Powered by AI SDK with streaming responses
  • Session Management - Persistent chat history with optimized navigation
  • Project Organization - Organize chats into projects with color coding
  • User Authentication - Secure login/signup with JWT tokens
  • Responsive Design - Mobile-first design with glassmorphism UI

Performance Optimizations

  • Zero Layout Shift - Optimized navigation with session storage caching
  • Comprehensive Memoization - All components memoized for maximum performance
  • Efficient State Management - Zustand stores for optimal re-renders
  • Smart Caching - Session storage prevents unnecessary server requests
  • Optimized Rendering - React.memo, useCallback, and useMemo throughout

πŸ›  Tech Stack

Frontend

  • Next.js 15 - App Router with Server Components
  • React 18 - With concurrent features and Suspense
  • TypeScript - Full type safety
  • Tailwind CSS - Utility-first styling
  • Framer Motion - Smooth animations
  • AI SDK - Real-time AI streaming

Backend

  • Prisma - Type-safe database ORM
  • PostgreSQL - Relational database
  • Next.js API Routes - Serverless API endpoints
  • JWT - Secure authentication

UI Components

  • Glassmorphism Design - Modern glass-effect components
  • Auto-resizing Textarea - Dynamic input sizing
  • Syntax Highlighting - Code blocks with copy functionality
  • Markdown Rendering - Rich text support
  • Responsive Modals - Animated modal system

πŸ— Architecture

Performance-First Design

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Chat Page     │───▢│ Session Storage │───▢│  Chat ID Page   β”‚
β”‚                 β”‚    β”‚   (Cached)      β”‚    β”‚   (Instant)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                        β”‚                        β”‚
         β–Ό                        β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Memoized       β”‚    β”‚   Optimized      β”‚    β”‚  Memoized       β”‚
β”‚  Components     β”‚    β”‚   Navigation     β”‚    β”‚  Components     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Component Optimization Strategy

  • ChatPageClient - Memoized with session storage integration
  • ChatPageContainer - Memoized with useCallback for handlers
  • MessageCard - Individual message memoization
  • ChatInput - Memoized with optimized typing performance
  • AutoResizeTextarea - Memoized with useCallback for onChange
  • Modal - Memoized with useCallback for click handlers
  • All UI Components - Comprehensive memoization

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • npm or yarn

Installation

  1. Clone the repository

    git clone <repository-url>
    cd aargongpt
  2. Install dependencies

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

    cp .env.example .env

    Configure your environment variables:

    DATABASE_URL="postgresql://username:password@localhost:5432/aargongpt"
    NEXTAUTH_SECRET="your-secret-key"
    NEXTAUTH_URL="http://localhost:3000"
  4. Set up the database

    npx prisma generate
    npx prisma db push
  5. Run the development server

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

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ (main)/            # Main layout group
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”œβ”€β”€ chat/              # Chat pages
β”‚   └── layout.tsx         # Root layout
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ auth/              # Authentication components
β”‚   β”œβ”€β”€ chat/              # Chat-related components
β”‚   β”œβ”€β”€ common/            # Shared components
β”‚   β”œβ”€β”€ layout/            # Layout components
β”‚   β”œβ”€β”€ ui/                # UI components (memoized)
β”‚   └── projects/          # Project management
β”œβ”€β”€ hooks/                 # Custom React hooks
β”œβ”€β”€ lib/                   # Utility libraries
β”œβ”€β”€ services/              # API services
β”œβ”€β”€ types/                 # TypeScript type definitions
└── utils/                 # Utility functions

🎯 Performance Features

Session Storage Optimization

  • Instant Navigation - Cached messages prevent layout shifts
  • Smart Caching - Automatic cache cleanup prevents stale data
  • Fallback Strategy - Server data when cache unavailable

Component Memoization

  • React.memo - Prevents unnecessary re-renders
  • useCallback - Optimizes event handlers
  • useMemo - Caches expensive calculations
  • Custom Comparison - Precise memoization control

Rendering Optimizations

  • Virtual Scrolling - Efficient long message lists
  • Lazy Loading - On-demand component loading
  • Code Splitting - Optimized bundle sizes
  • Image Optimization - Next.js automatic optimization

πŸ§ͺ Testing

Run Tests

# Unit tests
npm test

# E2E tests
npm run test:e2e

# Performance tests
npm run test:performance

Test Coverage

  • Component Tests - React Testing Library
  • Integration Tests - API and database
  • E2E Tests - Playwright automation
  • Performance Tests - Rendering benchmarks

πŸš€ Deployment

Vercel (Recommended)

  1. Connect your GitHub repository to Vercel
  2. Configure environment variables
  3. Deploy automatically on push

Manual Deployment

# Build the application
npm run build

# Start production server
npm start

πŸ“Š Performance Metrics

Optimizations Implemented

  • βœ… Zero Layout Shift - Smooth navigation experience
  • βœ… Memoized Components - 15+ components optimized
  • βœ… Session Storage - Instant chat loading
  • βœ… Efficient Re-renders - Minimal unnecessary updates
  • βœ… Optimized Animations - Smooth Framer Motion
  • βœ… Code Splitting - Reduced initial bundle size

Performance Benefits

  • Faster Navigation - Instant chat switching
  • Smoother Typing - Optimized input handling
  • Reduced CPU Usage - Efficient rendering
  • Better Memory Management - Optimized component lifecycle
  • Improved Responsiveness - Faster UI interactions

🀝 Contributing

  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.

πŸ™ Acknowledgments

  • Next.js Team - For the amazing framework
  • AI SDK - For seamless AI integration
  • Prisma - For excellent database tooling
  • Tailwind CSS - For beautiful styling utilities
  • Framer Motion - For smooth animations

Built with ❀️ using modern web technologies and performance best practices.

About

AargonGPT – An AI-powered chatbot using OpenAI's GPT model for intelligent, human-like interactions. Built with Next.js, Vercel AI SDK, Tailwind CSS and PostgreSQL. πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published