Skip to content

ChartGPT is an AI-powered chart generation tool that combines the power of Google Generative AI and Google Charts to simplify data visualization. With ChartGPT, users can seamlessly generate interactive and customizable charts by simply describing their data in natural language.

Notifications You must be signed in to change notification settings

VighneshNilajakar/ChartGPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ChartGPT

✨ ChartGPT is an AI-powered chart generation tool that allows users to generate stunning charts based on their input. The application uses Firebase for authentication and hosting, and Google Charts for data visualization.

πŸš€ Demo :

πŸ“‹ Table of Contents

✨ Features

  • βœ… User authentication with email/password and Google Sign-In
  • βœ… AI-powered chart generation (Gemini 2.0 Flash)
  • βœ… Download generated charts as PNG files
  • βœ… Fully responsive design (Desktop, Tablet, Mobile)
  • βœ… Modern gradient UI with smooth animations
  • βœ… Comprehensive error handling with funny messages
  • βœ… Chart type selection (Column, Bar, Line, Pie)
  • βœ… Real-time chat interface with AI
  • βœ… Input validation and error messages
  • βœ… Loading states and animations

🎨 What's New

UI/UX Improvements

  • Modern Design: Beautiful purple gradient theme with smooth animations
  • Fully Responsive: Works perfectly on desktop, tablet, and mobile devices
  • Better Typography: Enhanced fonts and spacing for better readability
  • Interactive Elements: Smooth hover effects and transitions
  • Typing Animation: Animated dots when AI is processing

Error Handling & Validation

  • βœ… Comprehensive error messages with emojis and humor
  • βœ… Input validation for authentication fields
  • βœ… Network error handling
  • βœ… API quota exceeded handling with helpful tips
  • βœ… Chart parsing error handling
  • βœ… File download error handling
  • βœ… Toast notifications for all actions

Code Quality

  • βœ… Try-catch blocks for all async operations
  • βœ… Better state management
  • βœ… Input sanitization
  • βœ… Loading state indicators
  • βœ… Button disable states during processing
  • βœ… Keyboard support (Enter to send message)

Architecture

Frontend

  • HTML/CSS: Modern, responsive frontend with mobile-first approach
  • JavaScript (ES6+): Handles user interactions, authentication, and chart generation
  • Google Charts: Data visualization library
  • Google Generative AI (Gemini 2.0 Flash): AI-powered chart data generation

Backend

  • Firebase Authentication: Secure email/password and Google Sign-In
  • Firebase Hosting: Fast, secure static file hosting

CI/CD

  • GitHub Actions: Automated deployment on push to main branch

πŸ”§ Setup and Installation

Prerequisites

  • Node.js (v14+)
  • Firebase CLI
  • Google account for Firebase
  • Google AI API key

Step 1: Clone Repository

git clone https://github.com/vighneshnilajakar/chartgpt.git
cd chartgpt

Step 2: Create Configuration File

cp public/config.example.js public/config.js

Step 3: Get Your API Keys

Firebase:

  1. Go to Firebase Console
  2. Create a new project
  3. Enable Firebase Authentication (Email/Password + Google Sign-In)
  4. Copy the configuration from Project Settings

Google Generative AI:

  1. Visit Google AI Studio
  2. Create an API key
  3. ⚠️ Keep this secret! Don't commit it to GitHub!

Step 4: Update config.js

export const firebaseConfig = {
  apiKey: "YOUR_FIREBASE_API_KEY",
  authDomain: "YOUR_PROJECT.firebaseapp.com",
  databaseURL: "https://YOUR_PROJECT.firebasedatabase.app",
  projectId: "YOUR_PROJECT_ID",
  storageBucket: "YOUR_PROJECT.firebasestorage.app",
  messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
  appId: "YOUR_APP_ID"
};

export const GENERATIVE_AI_API_KEY = "YOUR_GOOGLE_AI_API_KEY";

Step 5: Run Locally (Firebase Emulator)

firebase emulators:start --only hosting

Visit: http://localhost:5000

Step 6: Deploy to Firebase

firebase login
firebase deploy

πŸ“– Usage

1. Sign In

  • Use email/password or Google Sign-In to authenticate
  • Enter valid email and password
  • Enjoy funny error messages if something goes wrong! πŸ˜„

2. Generate Charts

  • Enter a keyword (e.g., "world population", "cryptocurrency prices")
  • Select your preferred chart type:
    • πŸ“Š Column Chart (default)
    • πŸ“ˆ Bar Chart
    • πŸ“‰ Line Chart
    • πŸ₯§ Pie Chart
  • AI will generate relevant data and visualize it
  • Watch the animated typing indicator while processing

3. Download Chart

  • Click the "⬇️ Download Chart" button
  • Chart will be saved as PNG to your downloads folder

4. Sign Out

  • Click the Sign Out button to logout
  • Your session will be cleared

❌ Error Handling

ChartGPT handles errors gracefully with helpful and funny messages:

Authentication Errors

❌ User not found! Did you forget your email address? πŸ˜…
πŸ” Wrong password! Your memory is as good as your password 🀦
πŸ“§ That email looks fishy... is it even valid? 🐟

API/Quota Errors

πŸ’° Quota exceeded! Dev made too many requests without paying. F for respect! πŸͺ¦
⏰ Oops! Dev forgot to upgrade the plan πŸ’Έ The API quota is exhausted!
πŸ”‘ Invalid API key! The dev exposed secrets on GitHub and now everything is broken! πŸ™ˆ

Validation Errors

πŸ“§ Please enter your email address! πŸ‘ˆ
πŸ”‘ Password field is empty! Enter something! πŸ‘†
πŸ˜… Empty message! Type something, anything! πŸ“

πŸ”§ Troubleshooting

"Quota exceeded" Error

This means the API rate limit has been reached. Here's how to fix it:

  1. Request Quota Increase:

    • Go to Google Cloud Console
    • Navigate to APIs & Services β†’ Quotas
    • Search for generativelanguage.googleapis.com/generate_content_requests
    • Click on it and edit the quota
    • Request increase (e.g., to 100 requests/minute)
    • Wait for approval (usually instant)
  2. Enable Billing:

    • Go to Billing in Google Cloud Console
    • Link a billing account (Google often gives $300 credits)
    • This usually provides immediate quota
  3. Wait and Retry:

    • The API resets every minute
    • Try again after a minute

"Invalid API Key" Error

  • Check your config.js file
  • Verify the API keys are copied correctly
  • Make sure keys are not expired
  • ⚠️ Never commit config.js to GitHub!

Charts Not Loading

  • Ensure JavaScript is enabled
  • Check browser console for errors (F12)
  • Verify Google Charts library is loading
  • Try a different chart type

Sign In Issues

  • Clear browser cookies/cache
  • Try incognito/private mode
  • Verify Firebase project has authentication enabled
  • Check if user account exists in Firebase

Deployment Issues

# Login to Firebase
firebase login

# Check deployment status
firebase deploy --debug

# View logs
firebase functions:log

πŸ“± Browser Compatibility

Browser Desktop Tablet Mobile
Chrome βœ… βœ… βœ…
Firefox βœ… βœ… βœ…
Safari βœ… βœ… βœ…
Edge βœ… βœ… βœ…

πŸ—οΈ Project Structure

ChartGPT/
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ index.html           # Login page
β”‚   β”œβ”€β”€ prompt.html          # Main app page
β”‚   β”œβ”€β”€ app.js              # Authentication logic
β”‚   β”œβ”€β”€ prompt.js           # Chart generation logic
β”‚   β”œβ”€β”€ styles.css          # Login page styles
β”‚   β”œβ”€β”€ prompt.css          # Main app styles
β”‚   β”œβ”€β”€ config.example.js   # API keys template
β”‚   └── config.js           # API keys (not in git)
β”œβ”€β”€ firebase.json           # Firebase config
β”œβ”€β”€ package.json            # Dependencies
└── README.md              # This file

πŸš€ Performance

  • Response Time: < 3 seconds for chart generation
  • File Size: Optimized CSS/JS with no unnecessary dependencies
  • Load Time: ~2-3 seconds on 4G connection
  • Mobile Friendly: Optimized for all screen sizes

πŸ” Security

⚠️ Important Security Tips:

  1. βœ… Never commit config.js to GitHub
  2. βœ… Use environment variables for sensitive data in production
  3. βœ… Enable Firebase rules for authentication
  4. βœ… Regularly rotate API keys
  5. βœ… Use .gitignore to exclude config.js

.gitignore Example

# API Keys
public/config.js
.env
.env.local

# Dependencies
node_modules/

# Firebase
.firebase/
.firebaserc

πŸ“Š Technologies Used

Category Technology
Frontend HTML5, CSS3, JavaScript (ES6+)
UI Library Google Charts
AI Google Generative AI (Gemini 2.0 Flash)
Authentication Firebase Auth
Hosting Firebase Hosting
Fonts Google Fonts (Poppins)
Icons Emojis πŸŽ‰

πŸ“ License

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

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How to Contribute:

  1. Fork the repository
  2. Create a 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

πŸ‘¨β€πŸ’» Author

Vighnesh Nilajakar

πŸ†˜ Support

Having issues? Here's what to try:

  1. Check the Troubleshooting section
  2. Review your Firebase configuration
  3. Check browser console for errors (F12)
  4. Open an issue on GitHub

πŸŽ‰ Special Thanks

  • Google Firebase team for excellent authentication and hosting
  • Google AI team for the amazing Generative AI API
  • Google Charts for powerful visualization tools

Enjoy creating amazing charts with AI! πŸš€βœ¨

About

ChartGPT is an AI-powered chart generation tool that combines the power of Google Generative AI and Google Charts to simplify data visualization. With ChartGPT, users can seamlessly generate interactive and customizable charts by simply describing their data in natural language.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •