Modern marketing intelligence application built with Svelte + Vite and powered by xAI Grok API with real-time streaming responses.
# Install dependencies
npm install
# Start development server
npm run dev
# Open http://localhost:5173
For local development with a backend API:
# Copy the example environment file
cp env.local.example .env.local
# Edit .env.local with your backend URL
VITE_API_URL=http://localhost:8000 # or your backend URL
# Install Vercel CLI
npm install -g vercel
# Deploy to preview
vercel
# Deploy to production
vercel --prod
Critical: Set VITE_API_URL
in Vercel Dashboard for each environment.
Via Vercel Dashboard:
VITE_API_URL
with your backend URLVia CLI:
# Production
vercel env add VITE_API_URL production
# Enter: https://your-backend.railway.app
# Preview (for PR deployments)
vercel env add VITE_API_URL preview
# Enter: https://your-backend-staging.railway.app
# Development
vercel env add VITE_API_URL development
# Enter: http://localhost:8000
Important: Variables with VITE_
prefix are exposed to the client. Never include secrets in VITE_*
variables.
Deploy the FastAPI backend separately to Railway, Fly.io, or similar:
Railway:
# In your backend directory
railway login
railway init
railway up
# Set environment variable
railway variables set XAI_API_KEY=your_key_here
railway variables set ALLOWED_ORIGINS=https://your-frontend.vercel.app
Fly.io:
# In your backend directory
flyctl auth login
flyctl launch
flyctl secrets set XAI_API_KEY=your_key_here
flyctl secrets set ALLOWED_ORIGINS=https://your-frontend.vercel.app
marketing_agent_svelte/
โโโ src/
โ โโโ components/ # Svelte components
โ โ โโโ AnalysisSelector.svelte
โ โ โโโ ChatInterface.svelte
โ โ โโโ FileUpload.svelte
โ โโโ stores/ # Svelte stores (state management)
โ โ โโโ chat.ts
โ โโโ lib/ # Utilities
โ โ โโโ api.ts # API client & SSE handling
โ โ โโโ markdown.ts # Secure markdown rendering
โ โโโ types/ # TypeScript types
โ โ โโโ index.ts
โ โโโ App.svelte # Root component
โ โโโ main.ts # Entry point
โ โโโ app.css # Global styles
โโโ public/ # Static assets
โโโ index.html # HTML template
โโโ vercel.json # Vercel configuration
โโโ vite.config.ts # Vite configuration
โโโ package.json # Dependencies
โโโ README.md # This file
The frontend communicates with a FastAPI backend via:
/api/chat
(POST)/api/*
to backend URLFormData {
message: string;
session_id?: string;
analysis_type?: 'sentiment' | 'campaign' | 'competitor';
file?: File;
}
data: {"chunk": "partial response..."}
data: {"chunk": "more content..."}
data: {"done": true, "session_id": "abc123"}
--color-bg-primary: #000000 /* Pure black background */
--color-brand-primary: #3b82f6 /* Brand blue */
--color-accent-green: #10b981 /* Success/positive */
--color-accent-orange: #f59e0b /* Warning/moderate */
--color-accent-red: #ef4444 /* Error/negative */
backdrop-filter: blur(20px)
for glass panelsrgba(0, 0, 0, 0.4)
1px solid rgba(255, 255, 255, 0.08)
# Build optimized production bundle
npm run build
# Preview production build locally
npm run preview
# Type checking
npm run check
# Initialize git (if not already done)
git init
git add .
git commit -m "Initial commit"
# Push to GitHub
git remote add origin https://github.com/your-org/your-repo.git
git branch -M main
git push -u origin main
Set these in Vercel Dashboard โ Settings โ Environment Variables:
Variable | Production Value | Preview Value | Development Value |
---|---|---|---|
VITE_API_URL |
https://api.example.com |
https://api-staging.example.com |
http://localhost:8000 |
VITE_ENV |
production |
preview |
development |
VITE_API_URL
set in Vercel Dashboardvercel
(preview)vercel --prod
Security headers are pre-configured in vercel.json
:
MIT - Built for marketing professionals, powered by xAI Grok.