Environment Variables
All environment variables are loaded from.env file in development and from Vercel dashboard in production.
See
.env.example:1-2 for the environment variable template.GEMINI_API_KEY
Google Gemini API key for AI-powered tarot reading generation.Obtain from: Google AI StudioFormat:
AIza prefix followed by 35 characters (total 39 chars)Example: AIzaSyC1234567890abcdefghijklmnopqrUsed in: src/actions/index.ts:37Security: Never exposed to client. Only accessible in server actions via import.meta.env.GEMINI_API_KEYSetting the API Key
NODE_ENV
Node.js environment mode. Automatically set by Vercel.Possible values:
development- Local development serverproduction- Production deploymenttest- Testing environment (if configured)
bun dev→developmentvercel --prod→production
Astro Configuration
Configuration is defined inastro.config.mjs.
output
Rendering mode for Astro pages.Value:
"server" (SSR - Server-Side Rendering)Effect: All routes are rendered on-demand per request, enabling:- Dynamic content generation
- Server actions (API endpoints)
- Environment variable access
- Session/cookie handling
"static"- Pre-render all pages at build time"hybrid"- Mix of static and server-rendered pages
astro.config.mjs:7adapter
Deployment adapter for SSR.Package: Location:
@astrojs/vercel (version ^9.0.4)Purpose: Transforms Astro SSR output into Vercel serverless functionsFeatures enabled:- Automatic serverless function creation
- Edge runtime support (optional)
- Environment variable injection
- Request/response handling
astro.config.mjs:8The default configuration (no options) is optimal for this project.
Package.json Scripts
dev
Command: Port override:
astro devPurpose: Start local development server with hot reloadServer: http://localhost:4321Features:- Auto-restart on code changes
- Source maps for debugging
- Fast HMR (Hot Module Replacement)
- Environment variable loading from
.env
build
Command: Vercel: This command runs automatically during deployment
astro buildPurpose: Create production-ready buildOutput directory: dist/Build steps:- Compile TypeScript
- Bundle CSS and JavaScript
- Optimize images
- Generate serverless function handlers
- Create static asset manifest
preview
Command: Use case: Test production build before deploying
astro previewPurpose: Preview production build locallyRequires: bun build must be run firstServer: http://localhost:4321Usage:astro
Command:
astroPurpose: Direct access to Astro CLIUsage:Dependencies
@astrojs/vercel
Purpose: Vercel deployment adapter for Astro SSRFeatures:
- Serverless function generation
- Edge runtime support
- Image optimization
@google/genai
Purpose: Google Gemini API client for Node.jsUsed for: AI-powered tarot reading generationModels used:
gemini-2.5-flashgemini-2.0-flashgemini-2.0-flash-lite
astro
Purpose: Core Astro frameworkFeatures used:
- Server-Side Rendering (SSR)
- Server Actions
- TypeScript support
- Zod schema validation
trustedDependencies
Purpose: Allow post-install scripts for specific packagesContains:
["protobufjs"]Reason: @google/genai depends on protobufjs, which requires post-install script to compile protocol buffersSecurity: Only listed packages can run post-install scriptsUsage Limit Configuration
Usage limits are enforced client-side via localStorage.Configuration Constants
LIMIT
Purpose: Maximum consultations per user per dayDefault:
5Enforcement: Client-side (localStorage)Bypass: Users can clear localStorage to reset limitLocation: src/components/TarotForm.astro:177Modify:WINDOW_MS
Purpose: Time window for usage limit (milliseconds)Default:
24 * 60 * 60 * 1000 (24 hours)Reset behavior: Counter resets 24 hours after first useLocation: src/components/TarotForm.astro:178Examples:STORAGE_KEY
Purpose: localStorage key for usage trackingDefault: Location:
"tarot_usage"Data structure:src/components/TarotForm.astro:179Usage limits are not server-enforced. They serve as a gentle UX boundary for a recreational app.
Usage Tracking Logic
See
src/components/TarotForm.astro:181-203 for the complete usage tracking implementation.Advanced Configuration
Custom Vercel Configuration
Createvercel.json for advanced settings (optional):
TypeScript Configuration
Astro automatically generatestsconfig.json. No manual configuration needed.
Configuration Validation
Run these checks to ensure proper configuration:All configuration is validated at build time. Missing required values will fail the build.