Version 1.0 - AI-Powered Astronomy Data Visualization
A web-based application designed to simplify astronomical data visualization through natural language queries. Built for educators, researchers, and students who need quick, intuitive graph generation without complex tools.
- Natural Language Queries: Describe what you want to visualize in plain English
- AI-Powered Parsing: OpenRouter integration with cost-effective LLM routing
- Single-Page Interface: All features accessible without navigation
- Real-time Visualization: Interactive charts with zoom, pan, and tooltips
- Multiple Data Formats: Support for CSV, JSON, and TXT files (up to 10MB)
- Astronomy-Specific Charts:
- Hertzsprung-Russell (HR) Diagrams
- Sky Maps (RA/Dec plots)
- Light Curves
- Redshift Histograms
- Orbital Path Plots
- Drag-and-Drop Upload: Intuitive file upload with preview
- Auto-Detection: Automatically identifies astronomy columns (RA, Dec, Magnitude, etc.)
- Large Dataset Support: Handles 10,000+ rows efficiently
- In-Memory Storage: Datasets stored in browser memory (no cloud storage costs)
- Guest Mode: Full functionality without requiring account creation
- Interactive Charts: Built with Chart.js with zoom plugin
- Multiple Export Formats: PNG, PDF, HTML
- Shareable Links: Generate links to share graphs with colleagues
- Graph History: Save and reload previous visualizations
- High-Resolution Exports: Suitable for papers and presentations
- Dark Mode: Easy on the eyes for long sessions
- Responsive Design: Works on desktop, tablet, and mobile
- Accessibility: WCAG compliant with keyboard navigation
- Large Fonts: Optimized for users 40-60 years old
- Zero Navigation: Everything on one page
- Node.js 18+ and npm/yarn
- Firebase account (free tier)
- OpenRouter API key (pay-per-use)
- Clone the repository
git clone https://github.com/yourusername/ricks-aigraph.git
cd ricks-aigraph- Install dependencies
npm install- Set up environment variables
Create a .env.local file in the root directory:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
# OpenRouter API Configuration
OPENROUTER_API_KEY=your_openrouter_api_key
# Site Configuration
NEXT_PUBLIC_SITE_URL=http://localhost:3000- Run the development server
npm run dev- Open your browser
Navigate to http://localhost:3000
-
Upload Your Data
- Drag and drop a CSV, JSON, or TXT file into the upload area
- Preview your data to verify correct parsing
- Supported astronomy columns are automatically detected
-
Enter a Query
- Type a natural language description of your desired visualization
- Click "Show Examples" for inspiration
- Press "Generate Graph" to create your visualization
-
Interact with Your Graph
- Zoom with mouse wheel
- Pan by clicking and dragging
- Hover over data points for details
- Toggle grid lines and logarithmic scales
-
Export or Share
- Download as PNG for presentations
- Export as PDF for papers
- Generate HTML for interactive embedding
- Create shareable links (requires sign-in)
Plot RA vs Dec for all stars
Scatter plot of distance vs magnitude
HR diagram: temperature vs magnitude
Hertzsprung-Russell plot with temperature and luminosity
Create an HR diagram for cluster stars
Histogram of redshifts with bin size 0.1
Distribution of stellar magnitudes
Light curve: time vs magnitude
Plot brightness over time for this variable star
Time-series of flux measurements
Sky map of galaxy positions
Plot celestial coordinates for quasars
RA and Dec scatter for Messier objects
RA,Dec,Magnitude,Distance
45.2,12.5,8.3,150.2
67.8,-23.1,9.1,245.7[
{"RA": 45.2, "Dec": 12.5, "Magnitude": 8.3, "Distance": 150.2},
{"RA": 67.8, "Dec": -23.1, "Magnitude": 9.1, "Distance": 245.7}
]The system automatically detects these column types:
- RA: Right Ascension (ra, right_ascension, alpha)
- Dec: Declination (dec, declination, delta)
- Magnitude: Apparent/Absolute magnitude (mag, magnitude, m_v, m_b)
- Distance: Parsecs, light-years (dist, distance, parsec, pc, ly)
- Redshift: Cosmological redshift (z, redshift)
- Temperature: Stellar temperature (temp, temperature, t_eff, teff)
- Luminosity: Solar luminosities (lum, luminosity, l_sun)
- Time: Julian Date, MJD (time, date, jd, mjd, hjd, bjd)
- Flux: Brightness measurements (flux, intensity, counts)
- Wavelength: Spectral wavelength (wavelength, lambda, angstrom)
Query without uploading - instant results:
- Planets: 8 solar system planets with mass, distance, diameter, moons
- Stars: 10 brightest stars with magnitude, temperature, distance
- Exoplanets: 15 confirmed exoplanets (Kepler, TRAPPIST, Proxima b, etc.)
- Variable Stars: 10 variable stars (Cepheids, Miras, RR Lyrae, Eclipsing)
- Galaxies: 6 nearby galaxies (Milky Way, Andromeda, LMC, M87, etc.)
- Spectral Lines: 8 major lines (H-alpha, H-beta, Ca II, Na D, etc.)
- Messier Objects: 5 famous deep-sky objects (M31, M42, M51, etc.)
- HR Diagram Data: 8 stars spanning main sequence to giants
- Orbital Paths: Generated elliptical orbits with any eccentricity
- Light Curves: Synthetic variable star data
- Create a Firebase project at console.firebase.google.com
- Enable Authentication (Email/Password)
- Configure OAuth Domains (Important for production):
- Go to Firebase Console โ Authentication โ Settings
- Click on the "Authorized domains" tab
- Add your production domain (e.g.,
ricks-aigraph.vercel.app) - Add any additional domains where your app will be hosted
- Note:
localhostis pre-authorized for development
- Create a Firestore database
- Enable Storage
- Copy your configuration to
.env.local
- Sign up at openrouter.ai
- Generate an API key
- Add to
.env.local - Default model:
mistralai/mistral-7b-instruct(cost-effective)
- Push your code to GitHub
- Import project to Vercel
- Add environment variables in Vercel dashboard
- Deploy
# Or use Vercel CLI
npm install -g vercel
vercel- Frontend: Next.js 14 (App Router), React 18, TypeScript
- Styling: TailwindCSS with custom dark theme
- Charts: Chart.js with react-chartjs-2 and zoom plugin
- Authentication: Firebase Auth (email/password)
- Database: Firebase Firestore
- Storage: Firebase Storage
- AI: OpenRouter API (Mistral 7B Instruct)
- Export: jsPDF, html2canvas
ricks-aigraph/
โโโ app/
โ โโโ components/ # React components
โ โโโ api/ # API routes
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Main single-page interface
โ โโโ globals.css # Global styles
โโโ lib/
โ โโโ firebase.ts # Firebase configuration
โ โโโ firestore.ts # Database operations
โ โโโ openrouter.ts # AI query parsing
โ โโโ chartConfig.ts # Chart.js configuration
โ โโโ dataParser.ts # CSV/JSON parsing
โ โโโ astronomyHelpers.ts # Astronomy-specific utilities
โ โโโ context/ # React contexts
โโโ types/
โ โโโ index.ts # TypeScript definitions
โโโ public/ # Static assets
Edit lib/openrouter.ts:
model: 'anthropic/claude-3-sonnet' // More capable but expensive
model: 'mistralai/mistral-7b-instruct' // Cost-effective defaultEdit lib/chartConfig.ts to customize chart appearance:
backgroundColor: 'rgba(68, 97, 242, 0.6)', // Change color
borderColor: 'rgba(68, 97, 242, 1)',Edit lib/dataParser.ts to add new column patterns:
const ASTRONOMY_PATTERNS = {
// Add your custom pattern
Velocity: /^(vel|velocity|v_r)$/i,
}- Upload CSV file with astronomy data
- Generate HR diagram
- Create sky map
- Export as PNG
- Export as PDF
- Create shareable link (authenticated)
- Test guest mode
- Test on mobile device
- Test keyboard navigation
- Test with screen reader
- Star Cluster Analysis: Upload Gaia data, create HR diagram
- Galaxy Survey: Upload SDSS data, create redshift histogram
- Variable Star Study: Upload time-series data, create light curve
- Exoplanet Research: Upload catalog data, create scatter plots
- Target Load Time: < 5 seconds from query to visualization
- Dataset Limit: 50,000 rows (soft limit)
- File Size Limit: 10 MB
- API Cost: ~$0.01 per 100 queries (Mistral 7B)
- Hosting: Free on Vercel Hobby tier
- Authentication: Firebase Auth with secure token management
- Data Storage: Encrypted Firestore with user-scoped access
- API Keys: Server-side only, never exposed to client
- Guest Mode: Data stored locally, not sent to servers
- No Tracking: Minimal analytics, GDPR compliant
This is a personal project for Rick's astronomy teaching needs, but suggestions are welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - See LICENSE file for details
- Check browser console for errors
- Verify dataset has at least 2 columns
- Ensure column names match query
- Verify OpenRouter API key is set
- Check API quota/billing
- Try simpler query or use example queries
- Verify all Firebase environment variables
- Check Firebase console for service status
- Ensure Firestore rules allow read/write
- OAuth Domain Error: If you see "domain is not authorized for OAuth operations":
- Go to Firebase Console โ Authentication โ Settings โ Authorized domains
- Add your production domain (e.g.,
your-app.vercel.app) - Wait a few minutes for changes to propagate
- Check file size (must be < 10MB)
- Verify file format (CSV, JSON, TXT only)
- Ensure file has proper headers
For issues or questions:
- Create an issue on GitHub
- Email: support@example.com
- Documentation: docs.example.com
- Built for Rick, astronomy educator extraordinaire
- Powered by OpenRouter AI
- Chart.js for beautiful visualizations
- Firebase for backend infrastructure
- Vercel for hosting
- Multiple dataset overlays
- Custom color schemes
- Collaborative sharing
- Advanced statistical analysis
- 3D visualizations
- Jupyter notebook integration
- Python API for programmatic access
- v1.0.0 (2025-11-05): Initial release with core features
Made with โค๏ธ for astronomy education