This contains everything you need to run your app locally.
View your app in AI Studio: https://ai.studio/apps/drive/1V0rn7pwslaxnFRTYfBazPPHU4RVq-Jr8
Prerequisites: Node.js
-
Install dependencies:
npm install -
Add your API keys to
.env(see .env.example). Keys are only used by the API server, never by the frontend. -
Start both the API and the app in one go:
npm run dev:all
This runs the API server (port 3001) and Vite (port 3000) together. The app proxies
/apito the server.Alternatively, use two terminals:
- Terminal 1:
npm run server(API on 3001) - Terminal 2:
npm run dev(Vite on 3000)
- Terminal 1:
On Vercel, the middleware is implemented as serverless functions, not a long-lived Express server:
- Each file under
api/becomes a separate serverless endpoint:api/plot-details.ts→POST /api/plot-detailsapi/refine-plot.ts→POST /api/refine-plotapi/characters.ts→POST /api/charactersapi/next-episode.ts→POST /api/next-episode
- The frontend (Vite build in
dist/) is served as static files. Thevercel.jsonrewrites all non-/apiroutes toindex.htmlfor client-side routing. - Environment variables (e.g.
OPENROUTER_API_KEY,AI_PROVIDER) must be set in the Vercel project: Settings → Environment Variables. They are only available in the serverless functions, so API keys never reach the browser. - Deploy with the Vercel CLI (
vercel) or by connecting your repo in the Vercel dashboard. No need to run the Expressserver/on Vercel; theapi/routes replace it.
