Skip to content

Walker-Gideon/walkwise-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WalkWise Proxy

A minimal Express server that proxies chat requests from the WalkWise frontend to the Groq API. It exists for one reason: to keep the Groq API key off the client.

Why This Exists

The WalkWise chatbot needs to call an LLM provider (Groq) to generate responses. Calling Groq directly from the browser would require exposing the API key in client-side code, since anything bundled into a Vite app (VITE_* env vars) is visible to anyone who opens DevTools.

This server sits between the frontend and Groq:

WalkWise (Vercel) → walkwise-proxy (Render) → Groq API

The Groq key lives only in this server's environment variables. The client never sees it.

Endpoints

POST /api/chat

Accepts a conversation and forwards it to Groq.

Request body:

{
  "messages": [
    { "role": "user", "content": "Explain recursion simply" },
    { "role": "assistant", "content": "Recursion is..." },
    { "role": "user", "content": "Can you give an example?" }
  ]
}

Response: the raw Groq chat completion response. The text of the reply is at:

response.choices[0].message.content

GET /health

Returns OK. Used to check the server is alive and to "warm up" the free-tier instance before a demo.

Local Setup

npm install

Create a .env file in the root:

GROQ_API_KEY=your_groq_key_here
PORT=3000

Run it:

npm start

Server starts at http://localhost:3000.

Deployment (Render)

  1. Push this repo to GitHub
  2. Create a new Web Service on Render, connect the repo
  3. Build command: npm install
  4. Start command: npm start
  5. Add environment variable: GROQ_API_KEY
  6. Deploy

Render assigns a public URL (e.g. https://walkwise-proxy.onrender.com) — this is what the frontend calls.

Notes

  • Free tier cold starts: Render's free instance spins down after inactivity. The first request after idle time can take 20–30 seconds. Hit /health a few minutes before a demo to warm it up.
  • CORS: currently open (cors() with no restrictions). Tighten this to the deployed WalkWise domain once the frontend URL is final.
  • Model: currently using llama-3.3-70b-versatile. Change in server.js if needed.

Stack

  • Express
  • node-fetch (native fetch, Node 18+)
  • dotenv
  • cors

About

A minimal Express proxy server that secures the Groq API key for WalkWise's AI study assistant feature, keeping it off the client.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors