Overview
This guide covers everything you need to install, configure, and deploy Ai Studio for production use. For a faster local setup, see the Quickstart Guide.System Requirements
Development Environment
Node.js
Version 18.0+ requiredRecommended: Node.js 20 LTS
Package Manager
npm (included with Node.js)Or use yarn/pnpm if preferred
Git
Latest versionFor cloning and version control
Code Editor
VS Code recommendedWith TypeScript/React extensions
Cloud Services
Firebase Account
- Free tier supports small to medium restaurants
- Paid tier (Blaze) required for Netlify Functions
- Create account
Google Cloud Account
- Needed for Gemini API access
- Free tier includes generous AI quotas
- Get started
Netlify Account (Optional)
- For hosting and serverless functions
- Free tier available
- Sign up
Installation Steps
1. Clone the Repository
2. Install Dependencies
Install all required packages:View Complete Dependency List
View Complete Dependency List
From
package.json:3. Firebase Project Setup
Create Firebase Project
- Go to Firebase Console
- Click “Add project” or “Create a project”
- Enter project name (e.g., “ai-studio-production”)
- Choose whether to enable Google Analytics
- Click “Create project” and wait for initialization
Enable Firestore Database
- In the Firebase Console, click “Firestore Database”
- Click “Create database”
- For development: Choose “Start in test mode”
- For production: Choose “Start in production mode”
- Select a location (choose closest to your users)
- Click “Enable”
Configure Security Rules
For production, set up proper Firestore security rules:
Adjust these rules based on your security requirements. Consider implementing authentication for better security.
4. Gemini API Configuration
Get API Key
- Visit Google AI Studio
- Sign in with your Google account
- Click “Get API key” or “Create API key”
- Select “Create API key in new project” or choose existing project
- Copy the generated key (format:
AIzaSy...)
5. Environment Configuration
Create Environment File
Copy the example environment file:Or create a new
.env.local file in the project root.Configure All Variables
Edit
.env.local with your actual values:.env.local
All variables prefixed with
VITE_ are exposed to the client-side code. The GEMINI_API_KEY without prefix is used server-side only.6. Build Configuration
Review and customizevite.config.ts if needed:
Configuration Options Explained
Configuration Options Explained
- server.port: Development server port (default: 3000)
- server.host: Bind to all network interfaces for LAN access
- plugins: Enables React Fast Refresh for hot reloading
- define: Injects environment variables at build time
- resolve.alias: Enables
@/imports for cleaner paths
Running the Application
Development Mode
Start the development server with hot reload:- Local: http://localhost:3000
- Network: http://YOUR_IP:3000 (shown in terminal)
Production Build
Create an optimized production build:dist/ directory.
Preview Production Build
Test the production build locally:Deployment Options
Option 1: Netlify (Recommended)
Set Environment Variables
In Netlify dashboard:
- Go to Site settings → Environment variables
- Add all variables from your
.env.local - Save changes
Option 2: Vercel
Option 3: Traditional Hosting
Post-Installation Setup
Initial Data Configuration
Configure Products
- Go to “Productos” tab
- Click ”+ Nuevo Producto”
- Add your menu items with:
- Name
- Category
- Price
- Description
- Image URL (optional)
Set Business Hours
- Go to “Configuración” tab
- Find “Horario” section
- Set opening hours for each day
- Add multiple time slots if needed (e.g., lunch and dinner)
Create Tables
- Go to “Mesas” tab
- Add tables with:
- Name (e.g., “Mesa 1”)
- Capacity
- Allow reservations checkbox
Configure Reservation Settings
In “Configuración” → “Reservas”:
- Duration: How long reservations last (e.g., 120 minutes)
- Min booking time: Minimum advance notice (e.g., 60 minutes)
- Slot interval: Reservation time increments (e.g., 30 minutes)
Troubleshooting
Build Errors
TypeScript errors during build
TypeScript errors during build
Symptom: Type errors prevent compilationSolution:Ensure TypeScript version is ~5.8.2 as specified in package.json.
Module resolution errors
Module resolution errors
Symptom: Cannot find module ’@/…’ or similarSolution: Verify
tsconfig.json has correct paths:Runtime Errors
Firebase initialization failed
Firebase initialization failed
Symptom: Console shows Firebase configuration errorsSolution:
- Verify all
VITE_FIREBASE_*variables in.env.local - Ensure no extra spaces or quotes in values
- Restart dev server after environment changes
- Check Firebase Console that Firestore is enabled
Gemini API errors (401, 403)
Gemini API errors (401, 403)
Symptom: AI assistant doesn’t respond, console shows authentication errorsSolution:
- Verify
GEMINI_API_KEYis correct - Check API key is enabled at AI Studio
- Ensure no billing/quota issues in Google Cloud Console
- Test API key with a simple curl:
Chat button disabled
Chat button disabled
Performance Issues
Slow Firebase queries
Slow Firebase queries
Solution: Add Firestore indexes for common queries:
- Check browser console for index creation links
- Click the link to auto-create the index
- Or manually create in Firebase Console → Firestore → Indexes
Large bundle size
Large bundle size
Solution:
- Verify tree-shaking is working
- Check for unnecessary imports
- Use production build:
npm run build - Consider code splitting for admin panel
Security Best Practices
-
Environment Variables
- Never commit
.env.localto git - Use different API keys for dev/prod
- Rotate keys periodically
- Never commit
-
Firestore Security Rules
- Don’t use test mode in production
- Implement proper authentication
- Validate data on write operations
- Use field-level security
-
API Rate Limiting
- Consider implementing rate limiting for Gemini API
- Monitor usage in Google Cloud Console
- Set up billing alerts
-
CORS Configuration
- Configure Firebase to only accept requests from your domain
- Set up proper CORS headers in Netlify Functions
-
Data Validation
- Validate all user inputs
- Sanitize data before storing in Firestore
- Implement server-side validation for critical operations
Next Steps
API Reference
Explore the codebase APIs and services
WhatsApp Integration
Set up the WhatsApp bot for mobile customers
Admin Features
Master the admin dashboard capabilities
Core Features
Learn about AI assistants and other features
Support
If you encounter issues not covered in this guide:- Check browser console (F12) for error messages
- Review Firebase Console logs
- Verify environment variables are loaded correctly
- Test with a fresh installation
For production deployments, consider implementing monitoring and logging solutions to track errors and performance metrics.
