Vercel-ready automation system that:
- onboards businesses with brand and menu context,
- generates daily platform-specific social posts,
- saves progress to Google Sheets,
- saves generated images to Google Drive,
- stores tenants and post history in Supabase.
- Next.js App Router (TypeScript)
- Supabase (Postgres)
- Google APIs (Sheets + Drive)
- Hostinger cron ping to Vercel endpoint
npm install
npm run dev- Copy
.env.exampleto.env.local. - Add your keys and IDs.
- Keep
CRON_SECRETprivate and use the same value in Hostinger cron header. - Set
ADMIN_BASIC_AUTH_USERandADMIN_BASIC_AUTH_PASSWORDbefore exposing/admin.
- Content generation uses Mistral:
MISTRAL_API_KEYMISTRAL_MODEL(default:mistral-small-latest)
- Optional text fallback uses Google AI Studio (Gemini):
GOOGLE_AI_STUDIO_API_KEYGOOGLE_AI_STUDIO_MODEL(default:gemini-2.0-flash)
- Rich image generation uses Hugging Face Inference API:
HUGGING_FACE_API_KEYHUGGING_FACE_IMAGE_MODEL(default:black-forest-labs/FLUX.1-schnell)
- Open Supabase SQL editor.
- Run supabase/schema.sql.
- Add
SUPABASE_URLandSUPABASE_SERVICE_ROLE_KEYto.env.local.
- Create a Google Cloud service account.
- Enable Google Drive API and Google Sheets API.
- Share the target Drive folder and Sheet with the service account email.
- Fill these env vars:
GOOGLE_SERVICE_ACCOUNT_EMAILGOOGLE_SERVICE_ACCOUNT_PRIVATE_KEYGOOGLE_DRIVE_FOLDER_IDGOOGLE_SHEETS_ID
Configure Hostinger cron to call:
POST https://<your-vercel-domain>/api/cron/daily-run
Header: x-cron-secret: <CRON_SECRET>
Recommended start schedule: once per day in off-peak hours.
POST /api/onboardingsaves tenant onboarding data.POST /api/cron/daily-runruns daily automation for active tenants.GET /api/healthbasic health check.
/adminis protected by HTTP Basic Auth.- Security headers are applied through
middleware.ts. - No API keys are sent to the client bundle; all provider calls stay server-side.
- Use
SUPABASE_SERVICE_ROLE_KEYonly on the server. - Keep all secrets in
.env.localor your deployment platform's secret store.
- User submits onboarding form.
- Tenant saved in Supabase.
- Daily cron triggers automation.
- System generates text + image per selected platform.
- Image saved to Drive, progress appended to Sheets.
- Post record saved in Supabase.
- If model API env vars are empty, app uses local fallback templates and SVG generation.
- If platform tokens are empty, posts are saved as
manual_requireddrafts. - This minimizes operator cost on free tiers and enables controlled scaling later.
- Preferred text model: Mistral small latest for fast smoke testing and predictable latency.
- Optional fallback text model: Google AI Studio Gemini Flash class model.
- Fallback text mode: built-in prompt templates when no model key is configured.
- Rich image generation: Hugging Face Inference API model set by
HUGGING_FACE_IMAGE_MODEL. - Zero-cost fallback image mode: built-in SVG rendering when no Hugging Face key is configured.
- Replace platform publish stubs in src/lib/platforms.ts with direct API integrations.
- Add auth and tenant admin dashboard.
- Add queue worker for high concurrency.