This is a React Single Page Application (SPA) built with Vite and TypeScript. It uses @google/genai for AI features.
- Node.js: Ensure you have Node.js installed locally.
- API Key: You need a valid Google Gemini API Key. Get one at aistudio.google.com.
-
Install dependencies:
npm install
-
Create a
.envfile in the root directory:API_KEY=your_actual_api_key_here
(Note: For Vite, use
VITE_API_KEYif you adjust thevite.config.ts, but this project usesdefinein config to injectprocess.env.API_KEY). -
Run the development server:
npm run dev
- Push to GitHub: Create a repository on GitHub and push this code.
- Import to Vercel:
- Go to Vercel.
- Click "Add New" > "Project".
- Import your GitHub repository.
- Configure Project:
- Framework Preset: Vite
- Root Directory:
./ - Environment Variables: Add a new variable:
- Key:
API_KEY - Value:
your_gemini_api_key
- Key:
- Deploy: Click Deploy.
- Note: The included
vercel.jsonensures that refreshing pages works correctly (SPA routing).
- Push to GitHub.
- Import to Netlify:
- Go to Netlify.
- "Add new site" > "Import an existing project".
- Connect GitHub.
- Build Settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Environment Variables:
- Go to "Site settings" > "Build & deploy" > "Environment".
- Add
API_KEYwith your key.
- Deploy.
- Note: The included
netlify.tomlhandles redirects for SPA routing.
Since GitHub Pages is static hosting, you need to set up a workflow or use the gh-pages package.
- Update
vite.config.ts: Setbase: '/your-repo-name/'. - Install gh-pages:
npm install gh-pages --save-dev - Add script to
package.json:"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d dist" }
- Environment Variables: GitHub Pages doesn't support server-side env vars easily. You might need to make the API Key public (NOT RECOMMENDED) or use a proxy.
- Warning: For a secure deployment with API keys, Vercel or Netlify is preferred over GitHub Pages for this specific app structure.
If you are using Supabase for the backend (future state), you can deploy the frontend to Vercel/Netlify as described above. Supabase itself usually hosts the Database and Auth, not the frontend UI directly (though they have Edge Functions).
This is a client-side application. Your API Key is embedded in the build. For production usage, it is highly recommended to move the AI interaction logic to a backend server (e.g., Vercel Functions, Netlify Functions, or a dedicated Node.js server) to keep your API Key secret.
For this Proof of Concept (PoC), the key is injected via build configuration. Ensure you restrict your API Key in the Google AI Studio console to specific domains (e.g., your Vercel URL) to prevent misuse.