Express app that exposes POST /api/code-explanation and calls Google Gemini via @google/genai.
Create .env in this directory:
GEMINI_API_KEY=your_gemini_api_key_here
PORT=3001
FRONTEND_URL=http://localhost:5173| Variable | Purpose |
|---|---|
GEMINI_API_KEY |
Required. Gemini / Google AI API key. |
PORT |
HTTP port (if unset, the app defaults to 3002 in server.js). |
FRONTEND_URL |
Allowed origin for CORS (use your Vite dev URL, e.g. http://localhost:5173). |
Never commit .env with real secrets.
npm install
npm run devThe server listens on http://localhost:<PORT>.
Body (JSON):
{
"code": "string",
"language": "string"
}Success (200):
{
"explanation": "markdown string",
"language": "javascript"
}Error: JSON with an error string. Upstream Gemini failures are parsed so clients can show messages such as model overload (503-style) in a readable form.
Configured in server.js (see MODEL constant). Change there if you switch Gemini models.
- Project README — full stack setup and screenshot.