Skip to content

mongodb-industry-solutions/genai-in-car-voice-assistant-backend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenAI-Powered In-Car Voice Assistant Backend

This repo contains the backend component used by the GenAI-Powered In-Car Voice Assistant demo which connects the client application to PowerSync and provides endpoints for token generation, public JWKS keys and handling writes to the source MongoDB Atlas database.

Local Setup

  1. Use nvm to configure the Node.js environment or download/install Node.js v20
  2. Install dependencies
pnpm install
  1. Create an .env file and set the following variables
POWERSYNC_PUBLIC_KEY=
POWERSYNC_PRIVATE_KEY=
MONGO_URI=mongodb+srv://<username>:<password>@<cluster>/<database_name>?appName=<app_name>
NODE_ENV=development

Request a new public/private key from PowerSync Support.

  1. Build
pnpm build
  1. Run
pnpm start

This stars the backend locally and uses the default express functions to start and listen for incoming requests on port http://localhost:3000.

Deployment

This application is configured to run on GoogleCloud Functions. Follow the steps below to deploy it.

  1. Authenticate with GCP
gcloud auth login
  1. Set your project: gcloud config set project YOUR_PROJECT_ID
  2. Deploy the function with environment variables
gcloud functions deploy api \
	--entry-point api \
	--runtime nodejs20 \
	--trigger-http \
	--allow-unauthenticated \
	--gen2 \
	--set-env-vars POWERSYNC_PUBLIC_KEY=<value>,POWERSYNC_PRIVATE_KEY=<value>,MONGO_URI=<value>,NODE_ENV=production

Testing

Get the function URL: gcloud functions describe api --format='value(httpsTrigger.url)'

  • Token: curl -X GET https://REGION-PROJECT_ID.cloudfunctions.net/api/token
  • JWKS: curl -X GET https://REGION-PROJECT_ID.cloudfunctions.net/api/jwks
  • POST Data: curl -X PUT -H "Content-Type: application/json" -d '{"key": "value"}' https://REGION-PROJECT_ID.cloudfunctions.net/api/data

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.0%
  • JavaScript 2.0%